Re: bug(?) in rectilinear_to_SCRIP and related functions

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 20 2012 - 11:54:43 MDT

Bill and others,

This issue should be fixed in the next version (6.1.0) of NCL.

Meanwhile, you can use the attached ESMF_regridding.ncl script in place of the one in $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl

Note: this should only affect people who are using the "conserve" method and are not already providing their own grid corners.

--Mary

On Jun 7, 2012, at 12:59 PM, Bill Sacks wrote:

> Hi Mary,
>
> Thanks a lot for your reply. Indeed, find_SCRIP_corners gives the expected result for my test case.
>
> I understand your recommendation of providing your own corners for complicated grids. But it seems like it would be very useful to have a reasonable default for simple grids (e.g., rectilinear grids), since creating the corner arrays is the most error-prone part of creating a SCRIP grid file, in my mind.
>
> Thanks again,
> Bill
>
> On Jun 7, 2012, at 12:05 PM, Mary Haley wrote:
>
>> Hi Bill,
>>
>> The calc_SCRIP_corners function is intentionally fixing the edge points to be the same as the original lat/lon points.
>>
>> There's an older routine, find_SCRIP_corners that doesn't do this. If you want to try this, make your own copy of:
>>
>> $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
>>
>> and change
>>
>> ;; find_SCRIP_corners(lat2d,lon2d,grid_corner_lat,grid_corner_lon,Opt)
>> calc_SCRIP_corners(lat2d,lon2d,grid_corner_lat,grid_corner_lon,Opt)
>>
>> to:
>>
>> find_SCRIP_corners(lat2d,lon2d,grid_corner_lat,grid_corner_lon,Opt)
>> ;; calc_SCRIP_corners(lat2d,lon2d,grid_corner_lat,grid_corner_lon,Opt)
>>
>> Can you let me know if this fixes your problem?
>>
>> As I mentioned before, the corners are only needed if you are doing "conserve" regridding.
>>
>> If you have a complicated grid and need to do "conserve" regridding, then we *highly* recommend you
>> provide your own lat/lon corners, via the "GridCornerLat"/"GridCornerLon" attributes (or
>> "SrcGridCornerLat"/"SrcGridCornerLon" and "DstGridCornerLat"/"DstGridCornerLon" if you're using
>> ESMF_regrid).
>>
>> The LLCorner/URCorner attributes are only recognized by latlon_to_SCRIP, which is a basic function
>> for creating grids via strings like "1x1", "1deg", "G64", etc. I think I need to fix some documentation
>> so that these attributes are only mentioned in the latlon_to_SCRIP function page.
>>
>> --Mary
>>
>>
>> On May 31, 2012, at 12:41 PM, Bill Sacks wrote:
>>
>>> 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
>>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Wed Jun 20 11:54:51 2012

This archive was generated by hypermail 2.1.8 : Mon Jun 25 2012 - 09:57:23 MDT