Downgrading Grid Resolution in yt

Hello everyone, Does anyone know of a way to universally downgrade the grid refinement by 1 level in yt (for an enzo output)? I know that one can resample an output to any arbitrary maximum refinement level using a covering grid (or a smoothed covering grid), but the result only "downgrades" data at the highest levels of refinement. What I'm instead looking for is a method to "downgrade" the resolution of the data at every grid element regardless of its refinement. For example, if I have a two adjacent grids, one with 10 levels of refinement and the other with 3, I would like them resampled at 9 and 2, respectively, as opposed to 9 and 3, which is what happens in the case of the covering grid. Additionally, it might be nice to retain the AMR structure of the original output, so that the memory consumption is relatively low (much lower than an equivalent covering grid). This technique would be very useful for resolution studies to determine the effects of poorer resolution on post-processing analysis. Anyway, has anyone played around with this? If not, I'll look into writing something up in the next few weeks, but I figured I'd ask. Cameron -- Cameron Hummels PhD Candidate, Astronomy Department of Columbia University Public Outreach Director, Astronomy Department of Columbia University NASA IYA New York State Student Ambassador http://outreach.astro.columbia.edu PGP: 0x06F886E3

Hi Cameron, On Fri, Jun 1, 2012 at 11:53 AM, Cameron Hummels <chummels@astro.columbia.edu> wrote:
Hello everyone,
Does anyone know of a way to universally downgrade the grid refinement by 1 level in yt (for an enzo output)? I know that one can resample an output to any arbitrary maximum refinement level using a covering grid (or a smoothed covering grid), but the result only "downgrades" data at the highest levels of refinement. What I'm instead looking for is a method to "downgrade" the resolution of the data at every grid element regardless of its refinement.
For example, if I have a two adjacent grids, one with 10 levels of refinement and the other with 3, I would like them resampled at 9 and 2, respectively, as opposed to 9 and 3, which is what happens in the case of the covering grid. Additionally, it might be nice to retain the AMR structure of the original output, so that the memory consumption is relatively low (much lower than an equivalent covering grid).
This technique would be very useful for resolution studies to determine the effects of poorer resolution on post-processing analysis. Anyway, has anyone played around with this? If not, I'll look into writing something up in the next few weeks, but I figured I'd ask.
This might be a dumb question, but have you looked at examining the grid cells that your level 10 grid covers at level 9? I also believe that if you ask for a covering grid at level 9, and it covers grids at level 10, it will not use the level 10 grids when calculating the constituent values. There's this trick we do to figure out if the child masking should be taken into account with covering grids, and the criteria is: is this the final level we want to sample to? -Matt
Cameron
-- Cameron Hummels PhD Candidate, Astronomy Department of Columbia University Public Outreach Director, Astronomy Department of Columbia University NASA IYA New York State Student Ambassador http://outreach.astro.columbia.edu PGP: 0x06F886E3
_______________________________________________ yt-dev mailing list yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org

Hi Matt,
This might be a dumb question, but have you looked at examining the grid cells that your level 10 grid covers at level 9?
I also believe that if you ask for a covering grid at level 9, and it covers grids at level 10, it will not use the level 10 grids when calculating the constituent values. There's this trick we do to figure out if the child masking should be taken into account with covering grids, and the criteria is: is this the final level we want to sample to? That sounds great. So all I want to do is simply ignore child masking data from levels on the highest level of refinement. But again, is
I do not know how to use yt to look at the contents of a grid cell on a different level than its highest level of refinement. Looking over the documentation, it does not appear that this functionality is included. I suppose I could get into the sourcecode of covering_grid, but I thought I'd ask here first. there any function which does this publicly, or is it all buried in covering_grid? Cameron

On Jun 1, 2012 12:01 PM, "Cameron Hummels" <chummels@astro.columbia.edu> wrote:
Hi Matt,
This might be a dumb question, but have you looked at examining the grid cells that your level 10 grid covers at level 9?
I do not know how to use yt to look at the contents of a grid cell on a
different level than its highest level of refinement. Looking over the documentation, it does not appear that this functionality is included. I suppose I could get into the sourcecode of covering_grid, but I thought I'd ask here first. pf.h.grids has an array of grids. This is definitely in the docs. You can get their LeftEdge and RightEdge, and they also have the get_global_startindex function which gives it to you in level-relative integers.
I also believe that if you ask for a covering grid at level 9, and it covers grids at level 10, it will not use the level 10 grids when calculating the constituent values. There's this trick we do to figure out if the child masking should be taken into account with covering grids, and the criteria is: is this the final level we want to sample to?
That sounds great. So all I want to do is simply ignore child masking
data from levels on the highest level of refinement. But again, is there any function which does this publicly, or is it all buried in covering_grid? What I am getting at is that you could just use covering grid and specify a lower level than the highest.
Cameron
_______________________________________________ yt-dev mailing list yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org

Hi Matt, Thanks for the quick responses!
pf.h.grids has an array of grids. This is definitely in the docs. You can get their LeftEdge and RightEdge, and they also have the get_global_startindex function which gives it to you in level-relative integers.
I'll look into this, thanks!
I also believe that if you ask for a covering grid at level 9, and it covers grids at level 10, it will not use the level 10 grids when calculating the constituent values. There's this trick we do to figure out if the child masking should be taken into account with covering grids, and the criteria is: is this the final level we want to sample to?
That sounds great. So all I want to do is simply ignore child
masking data from levels on the highest level of refinement. But again, is there any function which does this publicly, or is it all buried in covering_grid?
What I am getting at is that you could just use covering grid and specify a lower level than the highest.
Your suggestion will not universally downgrade the resolution by 1, it will only downgrade the resolution of items at the *top* level of refinement by 1, but grids on lower refinement levels will remain the same. I'm looking for something that will downgrade refinement everywhere by 1, including regions at lower refinement. Any ideas on this, or is this just going to take an additional set of homemade functions inspecting each grid individually as per get_global_startindex() from above? Thanks again for all of the help with this! Cameron

On Fri, Jun 1, 2012 at 12:26 PM, Cameron Hummels <chummels@astro.columbia.edu> wrote:
Hi Matt,
Thanks for the quick responses!
pf.h.grids has an array of grids. This is definitely in the docs. You can get their LeftEdge and RightEdge, and they also have the get_global_startindex function which gives it to you in level-relative integers.
I'll look into this, thanks!
I also believe that if you ask for a covering grid at level 9, and it covers grids at level 10, it will not use the level 10 grids when calculating the constituent values. There's this trick we do to figure out if the child masking should be taken into account with covering grids, and the criteria is: is this the final level we want to sample to?
That sounds great. So all I want to do is simply ignore child masking data from levels on the highest level of refinement. But again, is there any function which does this publicly, or is it all buried in covering_grid?
What I am getting at is that you could just use covering grid and specify a lower level than the highest.
Your suggestion will not universally downgrade the resolution by 1, it will only downgrade the resolution of items at the *top* level of refinement by 1, but grids on lower refinement levels will remain the same. I'm looking for something that will downgrade refinement everywhere by 1, including regions at lower refinement.
Any ideas on this, or is this just going to take an additional set of homemade functions inspecting each grid individually as per get_global_startindex() from above?
I think I am starting to understand. You don't want to use the (created-by-your-sim-code) lower-resolution, overlapped-with data because you want the high resolution stuff downgraded a level. I believe this is what happens, by the way, in AMR codes. But moving beyond that, I guess what I see as being a possibility will require understanding *how* you want to degrade the resolution (i.e., ensuring your conservation equations are satisfied) and then applying something like this: # this simply averages my_new_array = na.zeros( [i/2 for i in cg["Density"].shape], dtype="float64") for i in range(2): for j in range(2): for k in range(2): my_new_array += cg["Density"][i::2,j::2,k::2] my_new_array /= 8.0 There may be additional issues (and my code might be wrong, I am wondering if I messed up the slicing there) but something like this would certainly take the number of cells and combine octs into a single cell. -Matt
Thanks again for all of the help with this!
Cameron
_______________________________________________ yt-dev mailing list yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org

Hi Cameron, The grid_collection_max_level that I just added in 63ff8d95dc50 should do most of what you're looking for. Here's some example code: http://paste.yt-project.org/show/2413/ -Matt On Fri, Jun 1, 2012 at 2:59 PM, Matthew Turk <matthewturk@gmail.com> wrote:
On Fri, Jun 1, 2012 at 12:26 PM, Cameron Hummels <chummels@astro.columbia.edu> wrote:
Hi Matt,
Thanks for the quick responses!
pf.h.grids has an array of grids. This is definitely in the docs. You can get their LeftEdge and RightEdge, and they also have the get_global_startindex function which gives it to you in level-relative integers.
I'll look into this, thanks!
I also believe that if you ask for a covering grid at level 9, and it covers grids at level 10, it will not use the level 10 grids when calculating the constituent values. There's this trick we do to figure out if the child masking should be taken into account with covering grids, and the criteria is: is this the final level we want to sample to?
That sounds great. So all I want to do is simply ignore child masking data from levels on the highest level of refinement. But again, is there any function which does this publicly, or is it all buried in covering_grid?
What I am getting at is that you could just use covering grid and specify a lower level than the highest.
Your suggestion will not universally downgrade the resolution by 1, it will only downgrade the resolution of items at the *top* level of refinement by 1, but grids on lower refinement levels will remain the same. I'm looking for something that will downgrade refinement everywhere by 1, including regions at lower refinement.
Any ideas on this, or is this just going to take an additional set of homemade functions inspecting each grid individually as per get_global_startindex() from above?
I think I am starting to understand. You don't want to use the (created-by-your-sim-code) lower-resolution, overlapped-with data because you want the high resolution stuff downgraded a level. I believe this is what happens, by the way, in AMR codes. But moving beyond that, I guess what I see as being a possibility will require understanding *how* you want to degrade the resolution (i.e., ensuring your conservation equations are satisfied) and then applying something like this:
# this simply averages my_new_array = na.zeros( [i/2 for i in cg["Density"].shape], dtype="float64") for i in range(2): for j in range(2): for k in range(2): my_new_array += cg["Density"][i::2,j::2,k::2] my_new_array /= 8.0
There may be additional issues (and my code might be wrong, I am wondering if I messed up the slicing there) but something like this would certainly take the number of cells and combine octs into a single cell.
-Matt
Thanks again for all of the help with this!
Cameron
_______________________________________________ yt-dev mailing list yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
participants (2)
-
Cameron Hummels
-
Matthew Turk