Recalculating derived fields in Gadget Binary Dataset
Hi all! Is there any possible way to modify a (non-derived) field in a Gadget Binary Dataset and update the computation of the derived (in particular, deposited) fields to reflect this change? For example, I would like to substract a fixed velocity from all Gas particles (as to account for the Sun's velocity) and recalculate the smoothed velocity fields accordingly. As a reference, modifying the in-disk fields the following way works, but has no effect on the derived_fields: ds = yt.load('path/to/dataset', unit_base = unit_base) for i in range(num_particles): ds.r['Gas', 'Velocities'][i] -= ds.arr([100,100,100], 'code_velocity') #substracting some fixed array Any help would be very much appreciated. Thanks is advance (and happy holidays!) Martin
Hi Martin, One way you can do this is with the bulk_velocity field parameter. You would utilize data.get_field_parameters("bulk_velocity") and you would set it beforehand with data_object.set_field_parameter("bulk_velocity"). I think, though, from parsing your exact question, that you are likely in a situation where you need a derived field rather than using an on-disk field, as the on-disk field doesn't work with in-memory modifications. I also suspect you might be able to speed up your calculation a fair bit if you got rid of the iteration: ds.r['Gas','Velocities'] - ds.arr( ... ) You also probably want to assign this to another variable, as well. On Tue, Dec 25, 2018 at 12:07 PM <martincarusso@gmail.com> wrote:
Hi all!
Is there any possible way to modify a (non-derived) field in a Gadget Binary Dataset and update the computation of the derived (in particular, deposited) fields to reflect this change? For example, I would like to substract a fixed velocity from all Gas particles (as to account for the Sun's velocity) and recalculate the smoothed velocity fields accordingly.
As a reference, modifying the in-disk fields the following way works, but has no effect on the derived_fields:
ds = yt.load('path/to/dataset', unit_base = unit_base) for i in range(num_particles): ds.r['Gas', 'Velocities'][i] -= ds.arr([100,100,100], 'code_velocity') #substracting some fixed array
Any help would be very much appreciated. Thanks is advance (and happy holidays!) Martin _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Hi Matthew, thank you for your answer! How would setting the bulk_velocity field parameter modify derived fields in the Dataset object? As I can see from the documentation, an example of use would be: ad = ds.all_data() ad.set_field_parameter("bulk_velocity", yt.YTArray([-100.,200.,300.], "km/s")) Can this be used to update deposited velocity fields in the original Dataset object?
I also suspect you might be able to speed up your calculation a fair bit if you got rid of the iteration:
ds.r['Gas','Velocities'] - ds.arr( ... )
You also probably want to assign this to another variable, as well.
By the way, I included that loop as to provide an example of how I was modifying the in-disk fields in the Dataset object, if that helps. Thanks again, Martin
participants (2)
-
martincarusso@gmail.com
-
Matthew Turk