[yt-users] gradient field in yt3

Yuan Li bear0980 at gmail.com
Thu Aug 13 12:30:13 PDT 2015


Traceback (most recent call last):
  File "logP.py", line 11, in <module>
    a=dd["gas","logP_gradient_y"]
  File
"/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py",
line 253, in __getitem__
    self.get_data(f)
  File
"/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py",
line 751, in get_data
    self._generate_fields(fields_to_generate)
  File
"/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py",
line 771, in _generate_fields
    fd = self._generate_field(field)
  File
"/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py",
line 290, in _generate_field
    tr = self._generate_fluid_field(field)
  File
"/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py",
line 308, in _generate_fluid_field
    rv = self._generate_spatial_fluid(field, ngt_exception.ghost_zones)
  File
"/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py",
line 318, in _generate_spatial_fluid
    rv = self.ds.arr(np.empty(self.ires.size, dtype="float64"), units)
  File "/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/units/yt_array.py",
line 332, in __new__
    units = Unit(input_units, registry=registry)
  File
"/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/units/unit_object.py",
line 204, in __new__
    unit_data = _get_unit_data_from_expr(unit_expr, registry.lut)
  File
"/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/units/unit_object.py",
line 496, in _get_unit_data_from_expr
    unit_data = _get_unit_data_from_expr(expr, unit_symbol_lut)
  File
"/Users/yuanli/source/yt3/yt-x86_64/src/yt-hg/yt/units/unit_object.py",
line 504, in _get_unit_data_from_expr
    "objects." % str(unit_expr))
yt.units.unit_object.UnitParseError: Cannot parse for unit data from '()'.
Please supply an expression of only Unit, Symbol, Pow, and Mulobjects.

On Thu, Aug 13, 2015 at 3:28 PM, Nathan Goldbaum <nathan12343 at gmail.com>
wrote:

>
>
> On Thu, Aug 13, 2015 at 2:22 PM, Yuan Li <yuan at astro.columbia.edu> wrote:
>
>> Hi all:
>>
>> I am having trouble creating a gradient field in yt3. What I want is the
>> gradient of logP, where logP is defined as:
>>
>> @derived_field(name="logP",units="")
>> def _logP(field,data):
>>     return numpy.log(numpy.array(data["gas","pressure"]))
>>
>> Then I add the gradient field:
>>
>> pf.add_gradient_fields(("gas","logP"))
>>
>
>> which seems to work and I can find it in pf.derived_field_list.
>>
>> But if I try to use it, I get this error message:
>> yt.units.unit_object.UnitParseError: Cannot parse for unit data from
>> '()'. Please supply an expression of only Unit, Symbol, Pow, and Mulobjects.
>>
>
> Can you pastebin the full traceback?
>
>
>>
>> Is this because logP does not have a unit?
>>
>> Also, I had another unrelated question about the gradient fields:
>> Can I add the gradient fields globally instead of to a specific dataset?
>>
>>
> Not right now, no.
>
>
>>
>> Thanks!
>> Yuan
>>
>> _______________________________________________
>> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20150813/d1b694d2/attachment.htm>


More information about the yt-users mailing list