Absorption Spectrum from Gadget snapshot problem
Hello! I have a custom gadget snapshot distributed onto four files, and I'm trying to make an absorption spectrum from a LOS through the middle of the box parallel to the x-axis. To this end, I have done: lr = LightRay(fname, load_kwargs={'unit_base' : my_unit_base, 'field_spec' : my_field_def}) lr.make_light_ray(start_position=[0.0, 25000.0, 25000.0], end_position=[50000.0, 25000.0, 25000.0], solution_filename='lrsol.txt', data_filename='lr.h5', fields=['temperature', 'density'], get_los_velocity=True) sp = AbsorptionSpectrum(4862.4, 4949.04, 3000) my_label = 'HI Lya' field = 'H_number_density' wavelength = 1215.67 f_value = 4.164E-01 gamma = 6.265E+08 mass = 1.00794 sp.add_line(my_label, field, wavelength, f_value, gamma, mass, label_threshold=1e10) wl, flux = sp.make_spectrum('lr.h5', output_file='spectrum.txt', line_list_file='lines.txt', use_peculiar_velocity=True) And I get the error: KeyError: "Unable to open object (Object 'h_number_density' doesn't exist)" I didn't post the traceback because it's kind of long. I have two questions. First: When calling make_light_ray and passing it fields, do I need to pass it H_number_density? Second: Does yt read in those fields from the gadget snapshot, or does it calculate them from the data in the snapshot (for example, a standard gadget snapshot does not write the temperature, but rather the internal energy)? Thanks! -Jared
On Wed, Aug 19, 2015 at 3:34 PM, Jared Coughlin <Jared.W.Coughlin.29@nd.edu> wrote:
Hello! I have a custom gadget snapshot distributed onto four files, and I'm trying to make an absorption spectrum from a LOS through the middle of the box parallel to the x-axis. To this end, I have done:
lr = LightRay(fname, load_kwargs={'unit_base' : my_unit_base, 'field_spec' : my_field_def}) lr.make_light_ray(start_position=[0.0, 25000.0, 25000.0], end_position=[50000.0, 25000.0, 25000.0], solution_filename='lrsol.txt', data_filename='lr.h5', fields=['temperature', 'density'], get_los_velocity=True)
sp = AbsorptionSpectrum(4862.4, 4949.04, 3000) my_label = 'HI Lya' field = 'H_number_density' wavelength = 1215.67 f_value = 4.164E-01 gamma = 6.265E+08 mass = 1.00794
sp.add_line(my_label, field, wavelength, f_value, gamma, mass, label_threshold=1e10)
wl, flux = sp.make_spectrum('lr.h5', output_file='spectrum.txt', line_list_file='lines.txt', use_peculiar_velocity=True)
And I get the error: KeyError: "Unable to open object (Object 'h_number_density' doesn't exist)" I didn't post the traceback because it's kind of long.
We usually use a pastebin for this, e.g. paste.yt-project.org.
I have two questions. First: When calling make_light_ray and passing it fields, do I need to pass it H_number_density? Second: Does yt read in those fields from the gadget snapshot, or does it calculate them from the data in the snapshot (for example, a standard gadget snapshot does not write the temperature, but rather the internal energy)? Thanks!
It can do both. If the hydrogen number density is available on disk, you might need to add it as a known alias to h_number_density in the gadget frontend. We already do this for the Enzo frontend, for example. It's also possible to add a derived field to the gadget frontend that calculates the hydrogen number density based on other fields. That's how the OWLS/EAGLE frontend does it. As a stopgap, it should be possible to create a derived field in your script that defines ('gas', 'h_number_density'). I've never actually tried to get this to work, so I don't know if there might be obscure issues. Cameron can likely comment on the light ray specific issues you're running into.
-Jared
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Jared,
I have two questions. First: When calling make_light_ray and passing it fields, do I need to pass it H_number_density? Second: Does yt read in those fields from the gadget snapshot, or does it calculate them from the data in the snapshot (for example, a standard gadget snapshot does not write the temperature, but rather the internal energy)? Thanks!
When you run sp.add_line(), you're trying to add a line associated with a field, in this case, you're associating it with the "H_number_density" field. AbsorptionSpectrum expects that field to be present in the light ray (in this case lr.h5) when you run make_spectrum(). The "H_number_density" field is a grid-celled neutral hydrogen number density, which is present in some simulation outputs, however, I do not know if it is automatically populated for the custom gadget dataset on which you're running. Do you trace the neutral hydrogen in your gadget simulation? If so, does it spit out to a particle field that you can then deposit into a grid-based field? Or were you looking to approximate the HI number density in yt by making some assumptions based on the density, temperature, radiation field, etc.? Cameron -- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org
I do not write the hydrogen number density to the snapshot. I was planning on adding it post-processing. I read about the setup functions, but I don't really understand how they work. I already have a routine in place that gets n_HI from the density and temperature in the snapshot. Are set up functions the tool I should be using? -Jared Hi Jared,
I have two questions. First: When calling make_light_ray and passing it fields, do I need to pass it H_number_density? Second: Does yt read in those fields from the gadget snapshot, or does it calculate them from the data in the snapshot (for example, a standard gadget snapshot does not write the temperature, but rather the internal energy)? Thanks!
When you run sp.add_line(), you're trying to add a line associated with a field, in this case, you're associating it with the "H_number_density" field. AbsorptionSpectrum expects that field to be present in the light ray (in this case lr.h5) when you run make_spectrum(). The "H_number_density" field is a grid-celled neutral hydrogen number density, which is present in some simulation outputs, however, I do not know if it is automatically populated for the custom gadget dataset on which you're running. Do you trace the neutral hydrogen in your gadget simulation? If so, does it spit out to a particle field that you can then deposit into a grid-based field? Or were you looking to approximate the HI number density in yt by making some assumptions based on the density, temperature, radiation field, etc.? Cameron -- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Jared, Yes, the setup functions are what you should use to postprocess the dataset prior to using the make_spectrum() call. Essentially, just create whatever derived field you choose (in this case H_number_density) using the setup function and then make_spectrum() should work ok. Cameron On Thu, Aug 20, 2015 at 8:43 AM, Jared Coughlin <Jared.W.Coughlin.29@nd.edu> wrote:
I do not write the hydrogen number density to the snapshot. I was planning on adding it post-processing. I read about the setup functions, but I don't really understand how they work. I already have a routine in place that gets n_HI from the density and temperature in the snapshot. Are set up functions the tool I should be using? -Jared Hi Jared,
I have two questions. First: When calling make_light_ray and passing it fields, do I need to pass it H_number_density? Second: Does yt read in those fields from the gadget snapshot, or does it calculate them from the data in the snapshot (for example, a standard gadget snapshot does not write the temperature, but rather the internal energy)? Thanks!
When you run sp.add_line(), you're trying to add a line associated with a field, in this case, you're associating it with the "H_number_density" field. AbsorptionSpectrum expects that field to be present in the light ray (in this case lr.h5) when you run make_spectrum(). The "H_number_density" field is a grid-celled neutral hydrogen number density, which is present in some simulation outputs, however, I do not know if it is automatically populated for the custom gadget dataset on which you're running. Do you trace the neutral hydrogen in your gadget simulation? If so, does it spit out to a particle field that you can then deposit into a grid-based field? Or were you looking to approximate the HI number density in yt by making some assumptions based on the density, temperature, radiation field, etc.?
Cameron -- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org
Just one final question: what is the gamma parameter that is required by add_line()? I'm assuming it's the photoionization rate at the redshift in question. What units should it be in (I'm assuming s^-1, but I just thought I'd be sure)? -Jared On Thu, Aug 20, 2015 at 2:03 PM, Cameron Hummels <chummels@gmail.com> wrote:
Hi Jared,
Yes, the setup functions are what you should use to postprocess the dataset prior to using the make_spectrum() call. Essentially, just create whatever derived field you choose (in this case H_number_density) using the setup function and then make_spectrum() should work ok.
Cameron
On Thu, Aug 20, 2015 at 8:43 AM, Jared Coughlin < Jared.W.Coughlin.29@nd.edu> wrote:
I do not write the hydrogen number density to the snapshot. I was planning on adding it post-processing. I read about the setup functions, but I don't really understand how they work. I already have a routine in place that gets n_HI from the density and temperature in the snapshot. Are set up functions the tool I should be using? -Jared Hi Jared,
I have two questions. First: When calling make_light_ray and passing it fields, do I need to pass it H_number_density? Second: Does yt read in those fields from the gadget snapshot, or does it calculate them from the data in the snapshot (for example, a standard gadget snapshot does not write the temperature, but rather the internal energy)? Thanks!
When you run sp.add_line(), you're trying to add a line associated with a field, in this case, you're associating it with the "H_number_density" field. AbsorptionSpectrum expects that field to be present in the light ray (in this case lr.h5) when you run make_spectrum(). The "H_number_density" field is a grid-celled neutral hydrogen number density, which is present in some simulation outputs, however, I do not know if it is automatically populated for the custom gadget dataset on which you're running. Do you trace the neutral hydrogen in your gadget simulation? If so, does it spit out to a particle field that you can then deposit into a grid-based field? Or were you looking to approximate the HI number density in yt by making some assumptions based on the density, temperature, radiation field, etc.?
Cameron -- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Cameron Hummels NSF Postdoctoral Fellow Department of Astronomy California Institute of Technology http://chummels.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (3)
-
Cameron Hummels
-
Jared Coughlin
-
Nathan Goldbaum