Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

How to create the .png file

  1. Preferred method:
    1. Here we follow a procedure developed by Oksana Guba where we draw the PNG image on top of a background image of a cubed-sphere grid.  This allows one to have better control over the refined region’s boundaries and avoid notches and other types of glitches in the transition region.  
    If
    1. SQuadGen generates the
    fine region will be (for example) NE120 (¼ degree), make a uniform NE60.g file (exactly half the resolution of the fine region). 
  2. This can be done via; SQuadGen --resolution 60 --refine_level 0 --output NE60.g
  3. Create a lat/lon plot of this NE60 mesh, without any borders or axis, and convert to a PNG file with an aspect ratio of 2.  The final resolution should be something like 2048x4096.
    • You can convert SQuadGen output to PNG using gridplot.ncl in the SQuadGEN test directory.

  4. Here's an example of the kind of file you want:  Image Removed
    1. refinement region by using pointwise sampling of an input PNG image.  The input PNG is a grayscale representation of a regular latitude-longitude grid (under equirectangular projection) with the shading determining the level of refinement: white for the coarse grid and black where maximum refinement is desired.  Shades of gray can be used to impose an intermediate level of refinement.  To determine the refinement region on the cubed-sphere mesh, each volume on the cubed-sphere grid is sampled from the PNG image to determine the desired level of refinement on that grid.  The transition region is then built around each refinement region using "paving" tiles, with optional smoothing of edges.
      • The following PNG image can be used as a template for drawing your refinement region so that grid lines are parallel to cubed-sphere arcs. This PNG file will be used as a background image in Photoshop or GIMP.  The PNG of the refined region is then drawn on top of this image (in a separate layer).
    Create a PNG of the same dimensions as the file above which is transparent where the coarse grid is used and black where refinement is needed.
  5. For best results, create a PNG that is transparent (so you can see the NE60 grid behind it) and then fill in, in white, the elements that should be refined to NE120. 
  6. For best results the border should follow the grid lines, or go at a 45 degree angle (i.e. over 1 element, then down 1 element, and repeat).  
  7. Save the new PNG (without the background image).  Here we assume the file is called newmesh.png
  8. An example of the PNG file:
      •   You can set the transparency between layers at, i.e. 50% with the grayscale image in front of the template.  When you are ready to save the image, you can change the transparency to 0% and export the image as a PNG.
      •  Image Added
      • An example PNG file with refinement over the central Atlantic is depicted below.  We will assume this file is called "newmesh.png": Image Modified
    1. Use SQuadGen to create the refined grid:
      ./SQuadGen --refine_file  newmesh.png --refine_level 3 --refine_type LOWCONN \
      --resolution 16 --smooth_type SPRING --smooth_dist 3 --smooth_iter 20 \
      --output newmesh.g
    2. Plot the final grid and make sure it does not have any highly deformed elements.
      • Please note:  If you use the LOWCONN option for --refine_type, try to avoid six elements around one point by editing the white parts of the PNG.  Six elements around a point is unavoidable with the CUBIT option.  
      • The mesh generated by the PNG file above is:
    3. Image Modified
  1. Alternative Method:
    • An additional method may be easier if you are interested in relatively structured shapes.
    • Create a white PNG with 2x1 dimensions (e.g., 2048x4096) in Paint/Paintbrush/your favorite tool. Add the refinement patch (ex: a rectangle) as a solid black shape.
    • NOTE: geographical placement can be roughly controlled by running ImageMagick’s composite routine which overlays a world_map PNG (included in SQuadGen) with your refinement. Adjust newmesh.png accordingly
      composite -watermark 50% -gravity center world_map_2.png newmesh.png overlay.png
    • ./SQuadGen --refine_file  newmesh.png --refine_level 3 --refine_type CUBIT \
      --resolution 15 --smooth_type SPRING --smooth_dist 3 --smooth_iter 20 \
      --output newmesh.g --invert
    • NOTE: “--invert” will invert the refinement/non-refined patterns (“--invert” required for black refinement patches on white background, not needed for white on black)
    • Use vi (or other text editor) to modify refine_map.dat in the SQuadGen directory. This is a map which controls the cubed-sphere elements at the level of refinement at each location. (0 indicates no refinement, 1 indicates 1 level of refinement, etc.). Here you can fix notches/cutouts in the transition region caused by the the remapping from the lat-lon projection of the PNG to the cubed sphere grid.
    • ./SQuadGen --refine_file  newmesh.png --refine_level 3 --refine_type CUBIT \
      --resolution 15 --smooth_type SPRING --smooth_dist 3 --smooth_iter 20 \
      --output newmesh.g --invert --loadcsrefinementmap
      The “--loadcsrefinementmap” while force SQuadGen to use the now-modified refine_map.dat file.

...