bug(?) in rectilinear_to_SCRIP and related functions

From: Bill Sacks <sacks_at_nyahnyahspammersnyahnyah>
Date: Thu May 31 2012 - 12:41:35 MDT

Hi,

First: I am very happy to see the new ncl functions related to creating SCRIP grids -- thanks for this!

However: It looks like there is a bug in rectilinear_to_SCRIP and related functions, specifically in the determination of the corners in all of the cells on the edge of the domain. All of these edge cells have their outer edges exactly at the center of the cell – that is, the edge cells are just half the width that they should be.

The following script illustrates the problem:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"

begin
lat = (/39.,40.,41./)
lon = (/89.,90.,91./)
Opt = True
Opt@LLCorner = (/38.5,88.5/)
Opt@URCorner = (/41.5,91.5/)
Opt@ForceOverwrite = True
Opt@Debug = True
rectilinear_to_SCRIP("test.nc", lat, lon, Opt)
end

This gives the following screen output:

(0) curvilinear_to_SCRIP: calculating grid corners...
(0) calc_SCRIP_corners
(0) min/max original lat: 39/41
(0) min/max original lon: 89/91
(0) calc_SCRIP_corners
(0) min/max grid_corner_lat2d: 39/41
(0) min/max grid_corner_lon2d: 89/91
(0) calc_SCRIP_corners
(0) min/max grid_corner_lat: 39/41
(0) min/max grid_corner_lon: 89/91

An ncdump of the resulting file gives:

data:

 grid_dims = 3, 3 ;

 grid_center_lat = 39, 39, 39, 40, 40, 40, 41, 41, 41 ;

 grid_center_lon = 89, 90, 91, 89, 90, 91, 89, 90, 91 ;

 grid_imask = 1, 1, 1, 1, 1, 1, 1, 1, 1 ;

 grid_corner_lat =
  39, 39, 39.5, 39.5,
  39, 39, 39.5, 39.5,
  39, 39, 39.5, 39.5,
  39.5, 39.5, 40.5, 40.5,
  39.5, 39.5, 40.5, 40.5,
  39.5, 39.5, 40.5, 40.5,
  40.5, 40.5, 41, 41,
  40.5, 40.5, 41, 41,
  40.5, 40.5, 41, 41 ;

 grid_corner_lon =
  89, 89.5, 89.5, 89,
  89.5, 90.5, 90.5, 89.5,
  90.5, 91, 91, 90.5,
  89, 89.5, 89.5, 89,
  89.5, 90.5, 90.5, 89.5,
  90.5, 91, 91, 90.5,
  89, 89.5, 89.5, 89,
  89.5, 90.5, 90.5, 89.5,
  90.5, 91, 91, 90.5 ;
}

As you can see, both the screen output and the ncdump indicate that the corners of the edge cells are the same as the cell centers.

It looks like this problem arises in calc_SCRIP_corners, in the code for the edge and corner cells.

Also, a related problem is that, as far as I can tell, the LLCorner and URCorner attributes aren't used by most of these *_to_SCRIP routines (though I may be missing something in that respect).

I would propose a solution like: determine the southern corner latitudes of a cell on the southern edge of the domain as: (center_lat – (northern_corner_lat – center_lat)).

Thank you,
Bill
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 31 12:41:44 2012

This archive was generated by hypermail 2.1.8 : Tue Jun 12 2012 - 13:58:38 MDT