[yt-users] Fwd: calculate the Xray emissivity

Andrea Negri negri.andre at gmail.com
Sun Nov 20 12:24:29 PST 2016


Hi Britton,

thanks, this was the problem. The unit was already in the file, but I
named the attribute "field_unit" instead of "field_units".
Now it works and the numbers make sense.

Cheers,
Andrea

On 20 November 2016 at 19:04, Britton Smith <brittonsmith at gmail.com> wrote:
> Hi Andrea,
>
> I am not an expert on the GDF format, but the problem seems to be that your
> fields are not getting the appropriate units defined for them.  For example,
> you can see this by doing:
> ds=yt.load('GDFhdfaa.0000073.hdf5')
> print (ds.r[("gas", "density")])
>
> You'll notice that they come up as dimensionless.  I believe you can correct
> this by adding an attribute called "field_units" to each dataset with a
> string that indicates the units of the data.  For example, with density, you
> would have "g/cm**3".
>
> Britton
>
> On Sun, Nov 20, 2016 at 4:19 AM, Andrea Negri <negri.andre at gmail.com> wrote:
>>
>> Hi all,
>>
>> I'm using yt to analize ZEUS simulations. I have been able to remap
>> all the native fields on a custom AMR grid that I created, and I load
>> the data in the GDF format.
>>
>> I'm very happy with this, but when I try to calculate the Xray
>> emissivity using this little script here:
>>
>> import yt
>> from yt.analysis_modules.spectral_integrator.api import \
>>      add_xray_emissivity_field
>>
>> ds=yt.load('GDFhdfaa.0000073.hdf5')
>> xray_fields = add_xray_emissivity_field(ds, 0.2, 8.0,
>> with_metals=False, constant_metallicity=0.5)
>> plot = yt.ProjectionPlot(ds, 'x', 'xray_luminosity_0.2_8.0_keV')
>>
>> I get the error:
>>
>> Traceback (most recent call last):
>>   File "./xray.py", line 11, in <module>
>>     plot = yt.ProjectionPlot(ds, 'x', 'xray_luminosity_0.2_8.0_keV')
>>   File
>> "/home/andrea/.yt-dev/yt-conda/src/yt-hg/yt/visualization/plot_window.py",
>> line 1495, in __init__
>>     max_level=max_level)
>>   File
>> "/home/andrea/.yt-dev/yt-conda/src/yt-hg/yt/data_objects/construction_data_containers.py",
>> line 263, in __init__
>>     self.get_data(field)
>>   File
>> "/home/andrea/.yt-dev/yt-conda/src/yt-hg/yt/data_objects/construction_data_containers.py",
>> line 337, in get_data
>>     self._handle_chunk(chunk, fields, tree)
>>   File
>> "/home/andrea/.yt-dev/yt-conda/src/yt-hg/yt/data_objects/construction_data_containers.py",
>> line 437, in _handle_chunk
>>     d = chunk[field] * dl
>>   File
>> "/home/andrea/.yt-dev/yt-conda/src/yt-hg/yt/data_objects/data_containers.py",
>> line 281, in __getitem__
>>     self.get_data(f)
>>   File
>> "/home/andrea/.yt-dev/yt-conda/src/yt-hg/yt/data_objects/data_containers.py",
>> line 1295, in get_data
>>     self._generate_fields(fields_to_generate)
>>   File
>> "/home/andrea/.yt-dev/yt-conda/src/yt-hg/yt/data_objects/data_containers.py",
>> line 1346, in _generate_fields
>>     raise YTFieldUnitError(fi, fd.units)
>> yt.utilities.exceptions.YTFieldUnitError: The field function
>> associated with the field '('gas', 'H_number_density')' returned data
>> with units 'dimensionless/g' but was defined with units 'cm**-3'.
>>
>>
>>
>> I tried to check the GDF frontend, but I'm able to understand if the
>> error is there or somewhere else... You can find a very light dataset
>> in the GDF format in attachment, if you want ot reproduce the error.
>> You need to download both files, since in the GDF file there are some
>> hard links to the amr2 file (still an hdf5 file).
>> I tried both the stable and the developer version of yt, and the error
>> is the same.
>>
>> Any ideas? I really think that my GDF file is correct, since I'm able
>> to slice and project all the native fields (density, temperature,
>> velocities...).
>>
>>
>> Thanks,
>> Andrea
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>


More information about the yt-users mailing list