[yt-users] iterating through data in AMRCoveringGrid

Elizabeth Tasker taskere at mcmaster.ca
Fri May 13 10:23:36 PDT 2011


That's great -- thank you!

Elizabeth

Stephen Skory wrote:
> Hi Elizabeth,
>
>   
>> cube = pf.h.covering_grid(4,
>>                         left_edge=[16.4299, 10.8963, 16.0],
>>                         right_edge=[18.4299, 12.8963, 16.02],
>>                         dims=[258,258,4],
>>                         fields=["PotentialField"])
>>
>> But I'm now not sure how to get to the data! I'd like to write a loop in the
>> form:
>>
>> k = 0, 3
>> j=0, 257
>> i = 0, 257
>> something = data(i,j,k)*etc
>>     
>
> You can get data fields out of covering grid like any other yt data object:
>
>   
>>>> D = cube['Density']
>>>>         
>
> D will be an array with the same shape as your covering grid. You
> don't have to add a field to your pf.h.covering_grid for it to be
> accessible in the fashion above, either.
>
> Let me know if I didn't answer your question!
>
>
>   




More information about the yt-users mailing list