[yt-users] yt-3.0 derived field

Junhwan Choi (최준환) choi.junhwan at gmail.com
Sun Jan 4 19:20:11 PST 2015


Hi yt user,

I start to use yt-3.x version for the gadget analyses.
Although I have previously used the yt-2.6x version for the enzo
analyses, I find that there are many differences between two.
[Now, I find that new yt is significantly improved than previous one
but I need some adjustment..]
Here, I have a question regarding to derived field.
Since, my gadegt outputs only have InterenalEnergy, I need to make a
derived field for temperature as follow:
==============
@derived_field(name=("gas","temperature"), units="K")
def _temperature(field, data):
    BOLTZMANN   = 1.3806e-16
    PROTONMASS  = 1.6726e-24
    GAMMA       = 5.0 / 3.0
    H_MASSFRAC = 0.76
    mu = 4.0 / (3.0 * H_MASSFRAC + 1.0 + 4.0 * H_MASSFRAC *
data["gas","ElectronAbundance"])
    return data["gas","InternalEnergy"]*(GAMMA-1)*mu*PROTONMASS/BOLTZMANN

================

and try to make phase diagram and got the following error message:
.....
yt : [INFO     ] 2015-01-04 19:56:35,791 Max Value is 4.03205e-21 at
30150.5327224731445312 31066.5464401245117188 29380.5456161499023438
Traceback (most recent call last):
  File "phase.py", line 32, in <module>
    weight_field=None)
  File "/Users/jhchoi/common/src/yt/yt/visualization/profile_plotter.py",
line 699, in __init__
    fractional=fractional)
  File "/Users/jhchoi/common/src/yt/yt/data_objects/profiles.py", line
1331, in create_profile
    for f, l in zip(bin_fields, logs)]
  File "/Users/jhchoi/common/src/yt/yt/data_objects/derived_quantities.py",
line 482, in __call__
    rv = super(Extrema, self).__call__(fields, non_zero)
  File "/Users/jhchoi/common/src/yt/yt/data_objects/derived_quantities.py",
line 56, in __call__
    sto.result = self.process_chunk(ds, *args, **kwargs)
  File "/Users/jhchoi/common/src/yt/yt/data_objects/derived_quantities.py",
line 490, in process_chunk
    fd = data[field]
  File "/Users/jhchoi/common/src/yt/yt/data_objects/data_containers.py",
line 240, in __getitem__
    self.get_data(f)
  File "/Users/jhchoi/common/src/yt/yt/data_objects/data_containers.py",
line 661, in get_data
    self._generate_fields(fields_to_generate)
  File "/Users/jhchoi/common/src/yt/yt/data_objects/data_containers.py",
line 687, in _generate_fields
    fd.convert_to_units(fi.units)
  File "/Users/jhchoi/common/src/yt/yt/units/yt_array.py", line 416,
in convert_to_units
    new_units = self._unit_repr_check_same(units)
  File "/Users/jhchoi/common/src/yt/yt/units/yt_array.py", line 402,
in _unit_repr_check_same
    self.units, self.units.dimensions, units, units.dimensions)
yt.utilities.exceptions.YTUnitConversionError: Unit dimensionalities
do not match. Tried to convert between dimensionless (dim 1) and K
(dim (temperature)).

It looks that new yt become a bit picky on the units.
In this derived field, the unit contribution from BOLTZMANN and
PROTONMASS is not recognized and it causes error, I think.
How can I resolve this error?
Moreover, how can I make derived field without sensitive unit matching?
Sometimes, I used derived field when I need to convert log units for
visualization, and when dealing with the dimensionless field.

Thank you for help,
Junhwan



More information about the yt-users mailing list