cnerg/snippets

Script to find minimum/max values in a mesh

kkiesling opened this issue · 4 comments

I am finding more and more that I need this though I haven't been able to think through how to actually do this, so maybe someone else has an idea of how to do it: Given a mesh file with a set of tags, find the minimum (non-zero) value and the maximum value for that tag on the mesh. I am guessing PyNE and numpy could be used to do this.

Also, as a next level script related to this (and I am not sure if this is of use to anyone besides me): Find the maximum or minimum difference between adjacent voxels for a tag on any given mesh.

Task 1 is fairly straight forward - load into pyne as a mesh and just get min/max from there.

Task 2 is more complicated - need to convert 1D index of mesh voxels to 3D index and compare values that way

Task 2 can probably be done with numpy.reshape() and numpy.gradient()?

I think np.reshape() would definitely be useful in that task, but it doesn't look like np.gradient() is exactly what is needed (although that would also be useful to have).

My thinking is that I need to know what the maximum absolute difference between two adjacent mesh voxels is because I cannot use isosurface values that are smaller than that max difference. I don't think gradient quite calculates the right thing.