[yt-dev] Native field discussion

Casey W. Stark caseywstark at gmail.com
Mon May 6 15:50:01 PDT 2013


Hey Nathan.

Thanks for the reminder about `ensure_cgs`. Definitely helps to see the
pseudocode too. Users could also write out the array.convert_to(...) in the
field function for whatever obscure units. I guess this is similar to the
fields with the units tacked on to the name, but much cleaner.

I think making the code to universal field mapping more explicit will be
very helpful. I've been confused about where some derived fields come from
many times!


On Mon, May 6, 2013 at 3:39 PM, Nathan Goldbaum <goldbaum at ucolick.org>wrote:

> Hey Casey,
>
> That's pretty much what I was thinking, although I wanted to add a little
> bit of syntactic sugar so the CGS conversion happens automatically:
>
> http://paste.yt-project.org/show/3443/
>
> The ensure_cgs decorator would simply call convert_to_cgs on the returned
> YTArray.  The nice thing about this is the flow of data is clear, things
> come in to the field definition code units and leave in CGS.  This also
> eliminates the need for the unit conversion functions that are scattered
> throughout the frontends and universal_fields.py.
>
> This has the nice feature that each of the code frontends will need to
> explicitly define mappings to the CGS fields (like Density) needed by
> universal fields.
>
> -Nathan
>
>
> On Mon, May 6, 2013 at 3:33 PM, Casey W. Stark <caseywstark at gmail.com>wrote:
>
>> Hey yt.
>>
>> Nathan and I had a cool idea as an extension of the units work, but I am
>> hitting a yt internals knowledge wall writing a YTEP. I would like some
>> input on technical details or general feelings before I move ahead with the
>> write-up.
>>
>> One of the things mentioned in the units YTEP is handling code units.
>> Basically each frontend static output should register the code units. In
>> Nyx for instance, we would do something like registering "code_length" as
>> Mpccm, "code_mass" as Msun, etc. Then any field from the dataset can be
>> loaded in code units with something like
>> dd["density"].in_units("code_density").
>>
>> This got us thinking -- why load native fields in CGS now? Instead, we
>> can define native fields exactly as they are on disk and users who want
>> code units will never have to convert by hand again. If frontend developers
>> define the fields and units on disk, and some mapping to the universal
>> fields, we shouldn't have to define or convert units anywhere else.
>>
>> I made a quick and dirty example of what we're thinking here:
>> http://paste.yt-project.org/show/3441/
>>
>> So, is something like this a good idea? Is it realistic? Would this make
>> for a simpler field info container? Nathan, is there anything I missed?
>>
>> - Casey
>>
>> _______________________________________________
>> yt-dev mailing list
>> yt-dev at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
>>
>>
>
> _______________________________________________
> yt-dev mailing list
> yt-dev at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-dev-spacepope.org/attachments/20130506/a74393c4/attachment.html>


More information about the yt-dev mailing list