Re: ESMF Regridding

From: Travis, Katherine <ktravis_at_nyahnyahspammersnyahnyah>
Date: Thu Feb 21 2013 - 09:58:49 MST

Mary,
Im sorry, it worked with the file you sent me. (I have ncl 6.1.2) However, I tried to replace the original input file with a second input file with a finer grid, and it crashed using the conserve method.
The files are: ESMF_regrid_15_MHtestKT.ncl, and NEI08_2006_459x299_Jan_wkday_rw.nc
Thanks
Katie

From: Mary Haley <haley@ucar.edu<mailto:haley@ucar.edu>>
Date: Thursday, February 21, 2013 11:22 AM
To: Katherine Travis <ktravis@fas.harvard.edu<mailto:ktravis@fas.harvard.edu>>
Cc: ncl-talk USERS <ncl-talk@ucar.edu<mailto:ncl-talk@ucar.edu>>
Subject: Re: ESMF Regridding

What version of NCL do you have? Are you running the ESMF_regrid_15.ncl script that I sent you ?

I just ran this with V6.1.2 and it works fine. I uncommented "Opt@Debug = True" and here's what the output gives me when it reaches the "conserve" regridding part:

. . .

(0) ESMF_regrid_gen_weights: the following command is about to be executed on the system:
(0) 'ESMF_RegridWeightGen --source SrcSCRIP.nc --destination DstSCRIP.nc --weight Curv_2_1x1_conserve.nc --method conserve --src_regional --dst_regional -i --64bit_offset'
(0) --------------------------------------------------
(0) ESMF_regrid_gen_weights: output from 'ESMF_RegridWeightGen':
(0) Starting weight generation with these inputs:
(1) Source File: SrcSCRIP.nc
(2) Destination File: DstSCRIP.nc
(3) Weight File: Curv_2_1x1_conserve.nc
(4) Source File is in SCRIP format
(5) Source Grid is a regional grid
(6) Source Grid is a logically rectangular grid
(7) Destination File is in SCRIP format
(8) Destination Grid is a regional grid
(9) Destination Grid is a logically rectangular grid
(10) Regrid Method: conserve
(11) Pole option: NONE
(12) Ignore unmapped destination points
(13) Output weight file in 64bit offset NetCDF file format
(14)
(15) Completed weight generation successfully.
(16)
(0) --------------------------------------------------
(0) ESMF_regrid_gen_weights: 'ESMF_RegridWeightGen' was successful.
(0) ESMF_regrid_with_weights: regridding using interpolation weights ...
(0) ESMF_regrid_with_weights: Source Grid:
(0) rank: 2
(0) dimensions: 277 349
(0) original source rank: 3
(0) latitude min/max: 0.897945/85.3326
(0) longitude min/max:148.642/357.43
(0) ESMF_regrid_with_weights: Destination Grid:
(0) dimensions: 85 209
(0) latitude min/max: 1/85
(0) longitude min/max:149/357
(0) ESMF_regrid_with_weights: retrieving interpolation weights ...
(0) ESMF_regrid_with_weights: calling sparse_matrix_mult to apply weights...
(0) ESMF_regrid_with_weights: dividing results by frac_b...
(0) (currently for conserve interpolation only)
(0) ESMF_regrid_with_weights: dstData
(0) Dimensions: 402 85 209
(0) minSrcData: 229.758
(0) maxSrcData: 400.008
(0) minDstData: 231.09
(0) maxDstData: 400.008
(0) ESMF_copy_varcoords: detected a rectilinear grid.
(0) If you know your grid is rectilinear, then set
(0) opt@DstGridType = "rectilinear" to
(0) prevent this potentially slow test.

--Mary

On Feb 21, 2013, at 9:01 AM, Travis, Katherine wrote:

Mary
Thank you,
When I run the "conserve" regridding again, I still get this error:
PET0 ESMCI_Regrid_F.C:119 c_esmc_regrid_create() Invalid argument - Src contains a concave cell

Can you help with this?
Thanks
Katie

From: Mary Haley <haley@ucar.edu<mailto:haley@ucar.edu>>
Date: Thursday, February 21, 2013 10:34 AM
To: Katherine Travis <ktravis@fas.harvard.edu<mailto:ktravis@fas.harvard.edu>>
Cc: ncl-talk USERS <ncl-talk@ucar.edu<mailto:ncl-talk@ucar.edu>>
Subject: Re: ESMF Regridding

Hi Katie,

You have a few issues with the code.

First, there's an error with:

    Opt@DstLLCorner = (/round(minlat,0),round(minlat,0)/)

it should be:

   Opt@DstLLCorner = (/round(minlat,0),round(minlon,0)/)

The SrcGridCornerLat/DstGridCornerLat options are not being used correctly. You need to provide the corners of *each* lat/lon center point, and not just the corners of your domain. You don't appear to have an n x 4 array on your file that defines lat/lon grid corners, so comment those two lines and let ESMF_regrid try to guess at the corners.

Lastly, for ESMF_regrid to guess at the corners, it seems to prefer the longitudes to go from 0 to 360, so you need to do this:

   lon2d = where(lon2d.lt.0,lon2d+360,lon2d)
   datAir@lon2d=lon2d

See attached.

--Mary

On Feb 20, 2013, at 8:51 AM, Travis, Katherine wrote:

> Dennis,
> Thank you.
> The script is loaded: ESMF_regrid_15.ncl.
> For some reason air.2m.mon.mean.nc forced me to rename it to send, so it
> is called test.nc.
> Thanks
> Katie
>
> On 2/20/13 9:37 AM, "Dennis Shea" <shea@ucar.edu<mailto:shea@ucar.edu>> wrote:
>
>> Hello
>>
>> offline here .......
>>
>> Can you please send your file and script to
>>
>> ftp ftp.cgd.ucar.edu<http://ftp.cgd.ucar.edu>
>> anonymous
>> <use your email address for the password>
>> cd incoming
>> put ...
>> put ...
>> quit
>>
>> Send email to me (shea@ucar.edu<mailto:shea@ucar.edu>) and/or Mary (haley@ucar.edu<mailto:haley@ucar.edu>)
>> after you have successfully completed the transfer.
>>
>> Note that for security reasons, you cannot list the contents of this
>> directory, and neither can we. We need to know the *exact* names of the
>> files in order to retrieve them.
>>
>> Thx
>> D
>>
>> On 2/20/13 7:16 AM, Travis, Katherine wrote:
>>> Dennis,
>>> Thanks. This variable was short, so I unpacked to float. However
>>> conserve regridding still crashes on the destination corners of the
>>> grid.
>>> You can see below I have the source corners, but not the destination.
>>> When
>>> I try to provide corners, the program gives me this:
>>>
>>> 20130220 091610.975 ERROR PET0 ESMF_Grid.F90:5238
>>> ESMF_GridCreateFrmScripDistGrd Wrong argument specified - - Bad corner
>>> array in SCRIP file
>>>
>>> netcdf air.2m.mon.mean {
>>> dimensions:
>>> time = UNLIMITED ; // (402 currently)
>>> y = 277 ;
>>> x = 349 ;
>>> nbnds = 2 ;
>>> variables:
>>> int Lambert_Conformal ;
>>> Lambert_Conformal:grid_mapping_name =
>>> "lambert_conformal_conic" ;
>>> Lambert_Conformal:standard_parallel = 50., 50. ;
>>> Lambert_Conformal:longitude_of_central_meridian =
>>> -107. ;
>>> Lambert_Conformal:latitude_of_projection_origin = 50. ;
>>> Lambert_Conformal:false_easting = 5632642.22547 ;
>>> Lambert_Conformal:false_northing = 4612545.65137 ;
>>> short air(time, y, x) ;
>>> air:units = "K" ;
>>> air:long_name = "Monthly Air Temperature at 2 m" ;
>>> air:scale_factor = 0.003799786f ;
>>> air:add_offset = 275.5f ;
>>> air:unpacked_valid_range = 151.f, 400.f ;
>>> air:precision = 0.003799786f ;
>>> air:actual_range = 229.7579f, 310.9593f ;
>>> ©
>>> // global attributes:
>>> :standardpar1 = 50. ;
>>> :standardpar2 = 50.000001 ;
>>> :centerlon = -107. ;
>>> :centerlat = 50. ;
>>> :latcorners = 1.000001f, 0.897945f, 46.3544f,
>>> 46.63433f ;
>>> :loncorners = -145.5f, -68.32005f, -2.569891f,
>>> 148.6418f ;
>>> :stream = "s1" ;
>>> :title = "Monthly NARR" ;
>>> :Conventions = "CF-1.0" ;
>>> :history = "created 2005 by Jeff Whitaker" ;
>>> :institution = "National Centers for Environmental
>>> Prediction" ;
>>> :platform = "Model" ;
>>> :references =
>>> "http://wwwt.emc.ncep.noaa.gov/mmb/rreanl/index.html\n<http://wwwt.emc.ncep.noaa.gov/mmb/rreanl/index.html/n>",
>>>
>>> "http://www.esrl.noaa.gov/psd/data/gridded/data.narr.html" ;
>>> :NCO = "4.0.0" ;
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 2/20/13 12:57 AM, "Dennis Shea" <shea@ucar.edu<mailto:shea@ucar.edu>> wrote:
>>>
>>>> Before proceeding, could you please do a
>>>>
>>>> %> ncdump -h air.2m.mon.mean.nc | less
>>>>
>>>> What numeric type is the variable "air" ?
>>>>
>>>> If it is type 'short', then you *must* unpack prior to use.
>>>> Use 'short2flt' located in 'contributed.ncl'
>>>> http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml
>>>>
>>>> datAir = short2flt( sfile->air )
>>>> printVarSummary(datAir)
>>>> print("datAir: min="+min(datAir)+" max="+max(datAir))
>>>>
>>>> Perhaps you were getting the "large errors" cuz you did not unpack.
>>>>
>>>>
>>>>
>>>> On 2/19/13 5:20 PM, Travis, Katherine wrote:
>>>>> Hi,
>>>>> Could anyone who uses the ESMF_regridding.ncl routine tell me how to
>>>>> properly set the following options?
>>>>> I am trying to regrid sparse emissions data on a regional (US) 12km by
>>>>> 12km curvilinear grid to a 1x1degree grid, and the bilinear and path
>>>>> methods give me large errors.
>>>>> I am trying to use the conserve method, but I get the error that my
>>>>> grid corners are bad. Here is how I am currently trying to set them
>>>>> up:
>>>>>
>>>>> srcFile = "air.2m.mon.mean.nc"
>>>>> sfile = addfile(srcFile,"r")
>>>>> datAir = sfile->air
>>>>> lat = sfile->lat
>>>>> lon = sfile->lon
>>>>>
>>>>> Opt@SrcGridCornerLat = (/min(lat(0,:)),min(lat(:,0)),
>>>>> max(lat(0,:)),max(lat(:,0))/)
>>>>> Opt@SrcGridCornerLon = (/min(lon(0,:)),min(lon(:,0)),
>>>>> max(lon(0,:)),max(lon(:,0))/)
>>>>> Opt@DstGridCornerLat = (/1,1,11,47/)
>>>>> Opt@DstGridCornerLon = (/-144,-179,-68, 179/)
>>>>>
>>>>> Thank you,
>>>>> --
>>>>> Katherine R. Travis
>>>>> PhD Student
>>>>> Harvard University
>>>>> SEAS
>>>>> ktravis@fas.harvard.edu<mailto:ktravis@fas.harvard.edu>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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 Thu Feb 21 10:06:06 2013

This archive was generated by hypermail 2.1.8 : Fri Feb 22 2013 - 17:42:16 MST