[yt-users] Is it possible to get grid size from an enzo AMR data?

Britton Smith brittonsmith at gmail.com
Sat Nov 29 01:21:56 PST 2014


Hi Reju,

Yes, the "dx" field is the cell width, so that will do what you want.  It
will be in units of length and will likely default to code_length, but you
can convert it to anything you like.

Additionally, I recommend the following procedure for creating your field:

def my_new_field(field, data):
    return data['dx']*data['dx']*data['CRFraction']

ds = yt.load(...)
ds.add_field("CRF_flux", function=my_new_field,
             take_log=False, units=SOME_UNITS)

Adding the field directly to your loaded dataset is now the preferred
method.  Notice, you can also specify the units that you want the field
returned in.

Britton

On Fri, Nov 28, 2014 at 9:49 PM, Reju Sam John <rejusamjohn at gmail.com>
wrote:

> Hi Britton,
> Actually I was confused with what a gird is. Now I understood that, want
> I actually need is the cell size. Thanks Britton for your kind information.
> What I am trying to accomplish?
> I am trying to define a new field which has the dimension of flux (say
> CRF_flux) . I think the following definition would work.
>
> @derived_field(name = "CRF_flux",take_log=False)
> def my_new_field(field, data):
>     return data['dx']*data['dx']*data['CRFraction']  # along with some
> unit conversion constants.
>
> Where 'CRFraction' is one of my user defined field. I think data['dx'] is
> equivalent to the cell size, isn't it ? One more doubt, what will be the
> unit of the field 'dx'? Is it in code unit?
> Once again thanks for your suggestions and information.
> Thank You.
>
>
> On Fri, Nov 28, 2014 at 8:14 PM, Britton Smith <brittonsmith at gmail.com>
> wrote:
>
>> Hi Reju,
>>
>> When you say (grid size), do you mean the number of cells in a single
>> grid?  If so, that may be a bit tricky.  When you create a data container,
>> a field isn't necessarily evaluated on a grid object, but on the cells
>> contained within the container.  Can you explain what it is you are trying
>> to accomplish?  There may be another way to do it.
>>
>> Britton
>>
>> On Wed, Nov 26, 2014 at 11:20 AM, Reju Sam John <rejusamjohn at gmail.com>
>> wrote:
>>
>>> Thanks Britton.
>>> If I want to define a field like * (grid size)*x *, where 'x' is
>>> another user defined field, is it possible with the above method?
>>> Thank you
>>>
>>> On Wed, Nov 26, 2014 at 4:42 PM, Britton Smith <brittonsmith at gmail.com>
>>> wrote:
>>>
>>>> Hi Reju,
>>>>
>>>> If what you want is to get the size of each AMR grid, then for a given
>>>> dataset, ds, you can access the list of all AMR grids as ds.index.grids.
>>>> Then, for example, you can get the shape of the first grid with
>>>> ds.index.grids[0].shape.
>>>>
>>>> Britton
>>>>
>>>> On Wed, Nov 26, 2014 at 10:45 AM, Reju Sam John <rejusamjohn at gmail.com>
>>>> wrote:
>>>>
>>>>> Dear all,
>>>>> Is it possible to take grid size from an enzo AMR data?
>>>>> Thanks
>>>>>
>>>>> --
>>>>> Reju Sam John
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>
>>>>
>>>
>>>
>>> --
>>> Reju Sam John
>>>
>>> _______________________________________________
>>> 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
>>
>>
>
>
> --
> Reju Sam John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20141129/e06583f6/attachment.html>


More information about the yt-users mailing list