On Mon, Aug 8, 2016 at 2:49 PM, Rasmi Elasmar wrote:
Hi all,

I'm trying to gaussian smooth a 3D field of gas. I'm convolving the field with a gaussian kernel, but my results look odd. I think this might be because of how I'm reshaping my data. You can see my scripts here and here, and a more detailed explanation with plots here.

My suspicion (and someone from astropy's) is that I'm reshaping data improperly. I access the fields like this:
Which gives me a 1D array of length (1024^3) = 1073741824. To convolve this with a 3D gaussian kernel, I attempt to reshape the 1D array into its original 3D shape:
density = density.reshape(ds.domain_dimensions)
Which gives me a 3D 1024^3 matrix, but I'm not sure if this is correct. Does this correctly transform the 1D data from ds.all_data()[field] back into its 3D grid, or are things being misaligned somehow? Is there a better way to access a certain field's data in 3D without getting it in 1D first and reshaping?

HI Ramsi,

As you've discovered, yt data objects return data as a flattened, unordered 1D array. Simply reshaping the data as you've done will not produce what you're expect them to produce, since the data are unordered.

It sounds like you're dealing with a uniform resolution dataset, and what I'm saying to you probably doesn't make much sense in that context, but keep in mind that yt can deal with multiresolution data natively, where this flattened, unordered representation is the most convenient way to deal with the data.

For this particular use case, I'd bet that what you really want is either a covering_grid data object or an arbitrary_grid data object:

A covering grid is a uniform resolution 3D version of the data object. For multiresolution data, this will simply sample the data at a single resolution level, using nearest neighbor interpolation where the data are too coarse, and sampling when the data are too finely resolved. Covering grids are somewhat restrictive, as the resolution of the grid much be a power-of-two multiple of the coarsest resolution of your data.

Arbitrary_grid lets you create uniform resolution data at an arbitrary position or resolution, so it's a bit more flexible, although it's not necessarily as "honest" a representation of the original dataset.

Hope that helped clear things up, please let us know if you have additional questions.

-Nathan

Thanks,

Rasmi

_______________________________________________
yt-dev mailing list
yt-dev@lists.spacepope.org
http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org