[yt-users] iterating through data in AMRCoveringGrid

Stephen Skory s at skory.us
Fri May 13 10:11:11 PDT 2011


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!


-- 
Stephen Skory
s at skory.us
http://stephenskory.com/
510.621.3687 (google voice)



More information about the yt-users mailing list