
Hello all, I am making some profile plot for Gadget simualtion using yt (Version = 3.5.dev0 Changeset = ba2b2efe8962), but the resulting plot unit is mismatched with both yt-3 & 4.[The x-axis unit is extremly big 1e22kpc] I tested my script with Gadget example file (http://yt-project.org/data/GadgetDiskGalaxy.tar.gz), but that has same problem. The below is my script. import numpy import yt bb=100000 pf=yt.load('snapshot_200.hdf5' ,bounding_box=[[-bb,bb], [-bb, bb], [-bb,bb]]) figure_width=100 def _particle_position_cylindrical_z_abs(field, data): return numpy.abs(data[("PartType0", "particle_position_cylindrical_z")]) pf.add_field(("PartType0", "particle_position_cylindrical_z_abs"), function=_particle_position_cylindrical_z_abs, take_log=False, particle_type=True, units="kpc") v, cen = pf.h.find_max(("gas", "density")) sp = pf.sphere(cen, (0.5*figure_width, "kpc")) sp.set_field_parameter("normal", (0,0,1)) pf.field_info[("PartType0", "particle_position_cylindrical_z_abs")].take_log = False p = yt.ProfilePlot(sp, ("PartType0", "particle_position_cylindrical_z_abs"), ("PartType0", "density"), weight_field=None, n_bins=80, x_log=False, accumulation=False) p.set_unit(("PartType0", "density"), 'g/cm**3') p.set_unit(("PartType0", "particle_position_cylindrical_z_abs"), 'kpc') p.show() This is the resulting plot of the Gadget example file of yt, https://drive.google.com/file/d/1FGx2izfsnGrwP26SZ6JlfuIegz8eGVKo/view?usp=s... Could I get some advice for this problem? Thank you in advance! Eun-jin

Hello Eunjin I don't know much about Gadget data, but I think you have to give "unit_base" while loading the Gadget data. I am a bit confused with the data_file, it shows the "BoxSize" to be 64000 - but don't understand in which units. Because set_unit works very well for profile plotting. I think the main issue is with the correct "unit_base" specification. It by default taking length units in "kpc" for 64000 box size. Please clear my confusion as well. Thanks -Prateek On Wed, May 8, 2019 at 11:59 AM Eunjin Shin <shinphy8@gmail.com> wrote:
Hello all,
I am making some profile plot for Gadget simualtion using yt (Version = 3.5.dev0 Changeset = ba2b2efe8962), but the resulting plot unit is mismatched with both yt-3 & 4.[The x-axis unit is extremly big 1e22kpc] I tested my script with Gadget example file ( http://yt-project.org/data/GadgetDiskGalaxy.tar.gz), but that has same problem. The below is my script.
import numpy import yt bb=100000 pf=yt.load('snapshot_200.hdf5' ,bounding_box=[[-bb,bb], [-bb, bb], [-bb,bb]]) figure_width=100
def _particle_position_cylindrical_z_abs(field, data): return numpy.abs(data[("PartType0", "particle_position_cylindrical_z")]) pf.add_field(("PartType0", "particle_position_cylindrical_z_abs"), function=_particle_position_cylindrical_z_abs, take_log=False, particle_type=True, units="kpc")
v, cen = pf.h.find_max(("gas", "density")) sp = pf.sphere(cen, (0.5*figure_width, "kpc")) sp.set_field_parameter("normal", (0,0,1))
pf.field_info[("PartType0", "particle_position_cylindrical_z_abs")].take_log = False p = yt.ProfilePlot(sp, ("PartType0", "particle_position_cylindrical_z_abs"), ("PartType0", "density"), weight_field=None, n_bins=80, x_log=False, accumulation=False) p.set_unit(("PartType0", "density"), 'g/cm**3') p.set_unit(("PartType0", "particle_position_cylindrical_z_abs"), 'kpc') p.show()
This is the resulting plot of the Gadget example file of yt,
https://drive.google.com/file/d/1FGx2izfsnGrwP26SZ6JlfuIegz8eGVKo/view?usp=s...
Could I get some advice for this problem? Thank you in advance!
Eun-jin _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org

Hi Prateek, Thank you so much for your reply. I gave "unit_base" same as my simulation when loading data, but It gives same result. So I think I need another solution. I guess the box size unit is just default in the loading unless setting unit_base. In Gadget simulation, the code unit length is "kpc", so I guess the unit is "kpc". Thank you Eun-jin
participants (2)
-
Eunjin Shin
-
Prateek Gupta