[yt-users] Field existence check
Matthew Turk
matthewturk at gmail.com
Wed May 27 15:39:23 PDT 2009
Hi Dave,
It should be the same call to add field. However, the more I think
about it, the more I think it will default to using the data field
over the derived field, and so you should be safe adding it as a
derived field in *all* cases. I have conducted a few experiments and
this seems to be true over here.
You should check this by adding a field that supplies bad values, or
raises an exception. However, from my reading of the
AMRGridPatch.get_data function, I believe it will first try the data
reader and then fall back to generating it on the fly.
hierarchy.field_list *only* contains fields it finds in the data
files, and that is what the grid type checks against.
AMRData.get_data also checks against this list and will generate the
field if it is not there.
Can you give it a shot, let us know if this is not the case?
-Matt
On May 27, 2009, at 3:14 PM, David Collins <dcollins at physics.ucsd.edu>
wrote:
>> pf = load("my_data")
>> if not "DavesField" in pf.h.field_list:
>> add_field(...)
>
>
> add_field is the same one I've been using from lagos?
>
> I have some datasets that have this field, some that don't, all being
> used at the same time. Can I sometimes add the field, sometimes not?
>
> Thanks a bunch,
>
> d.
>
>>
>> Hope that helps!
>>
>> -Matt
>>
>> On Wed, May 27, 2009 at 2:45 PM, david collins
>> <antpuncher at gmail.com> wrote:
>>> Hi--
>>>
>>> I have a derived quantity that I only write to disk in some
>>> simulations. Is there a way to check for the existence of a field
>>> in
>>> the data set, so that if it doesn't exist I can derive it?
>>>
>>> Thanks,
>>> d.
>>> _______________________________________________
>>> 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
>>
>>
> _______________________________________________
> 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