[yt-users] hierarchy.io.pop, projection
David Collins
dcollins at physics.ucsd.edu
Mon Oct 25 16:07:18 PDT 2010
Awesome, thanks.
d.
On Mon, Oct 25, 2010 at 3:24 PM, Matthew Turk <matthewturk at gmail.com> wrote:
> Hi Dave,
>
> This is the field detection mechanism, to determine if a field is
> available to be used. It's how the list derived_field_list is
> constructed upon hierarchy instantiation, and it's how dependencies
> are calculated.
>
> If you look in the definition of the FieldDetector object
> (yt/data_objects/field_info_container) you can see where the IO
> mechanism is mocked up in the locally-defined class (which violates
> the yt style guide, I see now) fake_hierarchy and its nested fake_io.
> Add the pop method to the fake_io object, identical to _read_data_set.
>
> Go ahead and push the changes when you've made them, this is a valuable change.
>
> Best,
>
> Matt
>
> On Mon, Oct 25, 2010 at 3:20 PM, david collins <antpuncher at gmail.com> wrote:
>> Hi, Everybody!
>>
>> In order to ensure all my units are being done correctly, I have a
>> field 'TE' that forces 'TotalEnergy' to be read off disk, like this:
>>
>> def _TE(field,data):
>> return data.hierarchy.io.pop(data, 'TotalEnergy')
>>
>> lagos.add_field("TE", function=_TE,
>> validators=[lagos.ValidateGridType()])
>>
>> This lets me circumvent the assumptions that yt makes on a field by
>> that name, specifically unit conversion. However, I can't seem to
>> project it. I get the error, below. Does anyone have any ideas of
>> either different ways to do this, or ways around the projection error?
>>
>> Thanks,
>> d.
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "tmp.py", line 9, in <module>
>> mp.plot()
>> File "/home/dccollin/yt/uber.py", line 398, in plot
>> fig = self.add_plots(field,axis,FirstOne)
>> File "/home/dccollin/yt/uber.py", line 676, in add_plots
>> **extra_args)
>> File "/projects/lca-group/local-dev/lib/python2.6/site-packages/yt-2.0dev-py2.6-linux-x86_64.egg/yt/raven/plot_collection.py",
>> line 719, in add_projection
>> **field_parameters)
>> File "/projects/lca-group/local-dev/lib/python2.6/site-packages/yt-2.0dev-py2.6-linux-x86_64.egg/yt/lagos/BaseDataTypes.py",
>> line 1205, in __init__
>> self._refresh_data()
>> File "/projects/lca-group/local-dev/lib/python2.6/site-packages/yt-2.0dev-py2.6-linux-x86_64.egg/yt/lagos/BaseDataTypes.py",
>> line 237, in _refresh_data
>> self.get_data()
>> File "/projects/lca-group/local-dev/lib/python2.6/site-packages/yt-2.0dev-py2.6-linux-x86_64.egg/yt/lagos/BaseDataTypes.py",
>> line 1380, in get_data
>> self._get_dependencies(fields), self.hierarchy.io)
>> File "/projects/lca-group/local-dev/lib/python2.6/site-packages/yt-2.0dev-py2.6-linux-x86_64.egg/yt/lagos/ParallelTools.py",
>> line 1438, in _get_dependencies
>> deps += ensure_list(fi[field].get_dependencies(pf=self.pf).requested)
>> File "/projects/lca-group/local-dev/lib/python2.6/site-packages/yt-2.0dev-py2.6-linux-x86_64.egg/yt/lagos/field_info_container.py",
>> line 297, in get_dependencies
>> self(e)
>> File "/projects/lca-group/local-dev/lib/python2.6/site-packages/yt-2.0dev-py2.6-linux-x86_64.egg/yt/lagos/field_info_container.py",
>> line 318, in __call__
>> dd = self._function(self, data)
>> File "xtra_fields.py", line 161, in _TE
>> dataset = data.hierarchy.io.pop(data, 'TotalEnergy')
>> AttributeError: 'fake_io' object has no attribute 'pop'
>>
>>
>> --
>> Sent from my Stone Tablet and carried by my Pterodactyl.
>> _______________________________________________
>> 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
>
--
Sent from my Stone Tablet and carried by my Pterodactyl.
More information about the yt-users
mailing list