Visualizing the GFDL AM3 cubed-sphere grid with Ferret

Left-click any thumbnail image for a zoomable PDF.
Right-click and select "View Image" for a larger PNG image.

See also: Orthographic views of the AM3 cubed-sphere grid

Setup for tracer examples:

Note: Uses the data in data.tgz. Unpack with
tar -xzvf data.tgz
This will create a directory called "data" containing NetCDF files for the individual tiles.

! define a variable that will display a grid checkerboard,
! with different colors for each face
let checker_t = 2*(pcsf_face-1)+mod(i+j,2)

! Load all of the tile files, and define data variables
! and vertex variables.
def sym var zsurf
can dat/all
rep/name=s/range=1:6 (\
   use "data/00491208.atmos_daily.tile`s`.nc";\
   let checker`s`=checker_t[gxy=($var)[d=`($var),r=dsetnum`]];\
   let var`s`=var[d=`($var),r=dsetnum`];\
   use "data/00491208.grid_spec.tile`s`.nc";\
   let lon`s`=grid_lon[d=`grid_lon,r=dsetnum`];\
   let lat`s`=grid_lat[d=`grid_lat,r=dsetnum`];\
   )

def sym win_reset ppl cross 0\; ppl color 6 100 100 100\; ppl shaset reset
def sym retitle set var/title="\`(\$var)[d=1],r=title\`"/unit="\`(\$var)[d=1],r=unit\`" var_cube

Longitude/latitude checkerboard of tracer cells

When setting a region, always include n+1 vertices to bracket your n gridpoints. Each limit of the region should extend just beyond a cell center without including the next vertex. Ferret will then automatically include the bracketing cell vertices, because their edges sit at the cell centers. If you fail to set the region properly, Ferret may plot the cells displaced a half-cell away from their actual locations.
set window/aspect=.75/size=.3 1
($win_reset); palette categorical_12_step
can region
set grid abstract

def sym c1 shade/nokey/lev=(0,12,1)/hl=35:395:30/vl=-90:90:45/title="grid checkerboard"
def sym c2 checker\`pcsf_face\`,lon\`pcsf_face\`,lat\`pcsf_face\`
def sym c2shf checker\`pcsf_face\`,lon\`pcsf_face\`+360,lat\`pcsf_face\`

! plot the first face
let pcsf_face = 1; ($c1)/set ($c2)
ppl xlab; ppl ylab
ppl xfor (i5,''LONE''); ppl yfor (i5,''LAT'')
ppl axlint 2 1; ppl axnmtc 2 2; ppl shade

! plot the remaining faces, with 2 copies in longitude to handle wraparound
($c1)/nolab/ov ($c2shf)
rep/name=s/range=2:6 (let pcsf_face = `s`;\
   ($c1)/nolab/ov ($c2); ($c1)/nolab/ov ($c2shf))

! overlay land and lon/lat lines
go land
rep/name=s/range=50:380:15 (plot/ov/vs/nolab/line=6 `s`*{1,1}, 1e6*{-1,1})
rep/name=s/range=-75:75:15 (plot/ov/vs/nolab/line=6 1e6*{-1,1},`s`*{1,1})

Stereographic checkerboard of tracer cells

Uses plot_cubesphere_stereo_north.jnl, plot_cubesphere_face.jnl, and draw_ring.jnl

set window/aspect=1.05/size=.3 1
($win_reset); palette categorical_12_step

let min_lat = 40
go plot_cubesphere_stereo_north \
   "shade/lev=(0,12,1)/nolab" checker lon lat `45+35` `min_lat`

go mp_graticule 35 395 15 -75 75 15 6 1

! define a global grid for land overlays
def ax/x=0:360:360 pcso_xdum
def ax/y=`min_lat`:90:30 pcso_ydum
def grid/x=pcso_xdum/y=pcso_ydum pcso_gdum
set grid pcso_gdum
go mp_land 7 " " " " " " " " " " 0

! crop the plot at the minimum latitude
let pcso_rmin = 2*(tan(pi/4 - min_lat*pi/180/2))
let pcso_rmax = 2*(tan(pi/4 - (-80)*pi/180/2))
go draw_ring 0 0 `(pcso_rmin+pcso_rmax)/2` " " " " \
   `pcso_rmin-pcso_rmax` "poly/ov/nolab/pal=white/line=6"

Orthographic checkerboard of tracer cells

Uses plot_cubesphere_ortho.jnl and plot_cubesphere_face.jnl

set window/aspect=1.05/size=.3 1
($win_reset); palette categorical_12_step

go plot_cubesphere_ortho "shade/nolab/lev=(0,12,1)" checker lon lat 260 60 1

go mp_graticule 35 395 15 -75 75 15 6 1

! define a global grid for land overlays
def ax/x=0:360:360 pcso_xdum
def ax/y=-90:90:180 pcso_ydum
def grid/x=pcso_xdum/y=pcso_ydum pcso_gdum
set grid pcso_gdum
go mp_land 7 " " " " " " " " " " 0

Unfolded representations of the cube

The following examples use def_cubesphere_unfold.jnl

Stair

A 3x4 staircase configuration, half empty. This preserves the order and orientation of the tiles as found in the input NetCDF files, with tile 1 at the bottom left and tile 6 at the top right.
set window/aspect=.85/size=.3 1
($win_reset); palette dark_terrestrial

go def_cubesphere_unfold var " " STAIR
def sym var zsurf; let var = ($var); ($retitle)
shade var_cube; contour/ov/nolab/lev=(30)/si=100 var_cube

Rectangle

A 2x3 rectangle that preserves the connections through the IndoPacific and North America. The Antarctic and Atlantic tiles are tossed into the top left corner, with their original orientations but separated from their neighboring tiles. This is the most compact layout.
set window/aspect=.85/size=.3 1
($win_reset); palette dark_terrestrial

go def_cubesphere_unfold var " " RECTANGLE
def sym var zsurf; let var = ($var); ($retitle)
shade var_cube; contour/ov/nolab/lev=(30)/si=100 var_cube
plot/ov/vs/nolab/line=6 .5+48*{0,1,1,,1,2,2},.5+48*{1,1,2,,1,1,2}

Equatorial strip, poles connected through the Americas

Unfold the cube with the equatorial tiles in the middle row, and the Arctic and Antarctic tiles attached above and below. The equatorial tiles numbered {1,2,4,5} and those are the only valid choices for EQ_START, ARC_ATTACH, and ANTARC_ATTACH. The equatorial tiles to which the polar tiles are attached are selected with ARC_ATTACH and ANTARC_ATTACH; default connects through the Americas. The first equatorial tile on the left is selected with EQ_START. This is a 3x4 layout, half empty.
set window/aspect=.85/size=.3 1
($win_reset); palette dark_terrestrial

go def_cubesphere_unfold var " " EQUATOR
def sym var zsurf; let var = ($var); ($retitle)
shade var_cube; contour/ov/nolab/lev=(30)/si=100 var_cube

Equatorial strip, poles connected to different tiles

set window/aspect=.85/size=.3 1
($win_reset); palette dark_terrestrial

go def_cubesphere_unfold var " " EQUATOR 1 5 4
def sym var zsurf; let var = ($var); ($retitle)
shade var_cube; contour/ov/nolab/lev=(30)/si=100 var_cube

Arctic-centered cross

A 4x3 cross that preserves connections with the Arctic, and connects through the specified ANTARC_ATTACH equatorial tile to the Antarctic. Default connects through the Americas. EQ_START does not affect this layout.
set window/aspect=1.25/size=.3 1
($win_reset); palette dark_terrestrial

go def_cubesphere_unfold var " " ARCTIC
def sym var zsurf; let var = ($var); ($retitle)
shade var_cube; contour/ov/nolab/lev=(30)/si=100 var_cube

Antarctic-centered cross

A 4x3 upside-down cross that preserves connections with the Antarctic, and connects through the specified ARC_ATTACH equatorial tile to the Arctic. Default connects through the Americas. EQ_START does not affect this layout.
set window/aspect=1.25/size=.3 1
($win_reset); palette dark_terrestrial

go def_cubesphere_unfold var " " ANTARCTIC
def sym var zsurf; let var = ($var); ($retitle)
shade var_cube; contour/ov/nolab/lev=(30)/si=100 var_cube

Andrew Wittenberg -- 14 August 2008