Hi,
I want to write a script in yt that reads in data from a simulation output, extracts a 3-dimensional grid from it of a set size at a fixed resolution and then iterate through the data points calculating various properties.
I think I can do this using covering_grid using the example in the cookbook:
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
I feel this should be obvious but I can't figure out the AMRCoveringGrid object!
Thanks,
Elizabeth
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!
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!