Re: Question about new ESMF regridding programs

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 18 2012 - 10:28:36 MDT

Hi Michelle,

If your lat/lon arrays are both 2-dimensional, then you want to use "curvilinear_to_SCRIP".

If your lat/lon arrays are one-dimensional, where the lat array is the same length as the Y dimension of your data, and the lon array is the same length as the X dimension of your data, then use "rectilinear_to_SCRIP".

It might be easier for you to use "ESMF_regrid" instead of the individual xxxx_to_SCRIP routines. ESMF_regrid will try to figure out what kind of lat/lon data you have, and internally call the appropriate "xxxx_to_yyyyyy" routines for you.

The reason you might use xxxx_to_yyyyy over ESMF_regrid is if you are only interested in generating the description files and/or the weight files, for use by other programs.

If you interested in regridding a particular variable, then ESMF_regrid may be better. Does your "temp_pert" have coordinate arrays already attached to it? If so, then the following code might work for you instead of the individual calls to xxxx_to_SCRIP:

Opt = True

Opt@InterpMethod = "bilinear" ; the default

Opt@SrcFileName = "bccr_src_SCRIP.nc" ; if not specified, then "source_grid_file.nc" will be used
Opt@DstFileName = "bccr_dst_SCRIP.nc" ; if not specified, then "destination_grid_file.nc" will be used
Opt@WgtFileName = "bcc_bilinear.nc" ; if not specified, then "weights_file.nc" will be used

Opt@DstGridType = "1x1"
Opt@DstTitle = "BCCR lat/lon grid" ; optional

Opt@ForceOverwrite = True ; will overwrite the source, destination, and weight files everytime you run the script
Opt@CopyVarCoords = True

;---The source grid will be determined by "temp_pert" coordinate arrays
temp_pert_regrid = ESMF_regrid(temp_pert,Opt)

--Mary

On Jun 18, 2012, at 7:37 AM, Michelle Cipullo wrote:

> Hi,
>
> I'm working on regridding some of the IPCC AR4 model data, and I'm having issues regridding with the srcFile/srcGrid. I followed the example pretty much verbatim, but my issue is I'm not sure which type of method_to_SCRIP to use. I have the description in the header below, it's a global model (I commented the official min/max lat/lons). I thought it would be a lat/lon, but I'm not sure...
>
> The script is below
>
> Thanks for you time
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"
> ;--------------------------------------------------------
> ; Interpolate a file bilinear
> ; Michelle Cipullo
> ; 6/15/12
> ; bccr_bcm2_0 is a Gaussian Grid
> ;T63L31: A triangular truncation T63 with “linear” reduced Gaussian grid equivalent to T42 quadratic grid (2.8 °). See: Hortal and Simmonds (1991) for description of the linear reduced grid.
> ; After plotting it appears to be a lat/lon grid
> ;---------------------------------------------
>
> begin
>
> Opt = True
>
> ;------Interpolation method and addinf files
>
> method = (/"bilinear"/)
> srcFileName = "bccr_Feb_A2.nc"
> destFile = "bccr_dest.nc" ;not a file i have
>
> ;-------Output/input
> srcGridName = "bccr_src_SCRIP.nc" ;file to create
> dstGridName = "bccr_dst_SCRIP.nc" ;file to create
> wgtFile_b = "bcc_bilinear.nc" ;file to create
>
>
>
> bccr = addfile(srcFileName,"r")
> temp_pert = bccr->diff(:,:,:)
> bccr_lat = bccr->lat
> bccr_lon = bccr->lon
>
> ;____0 is treated as missing value, so fill it____
>
> temp_pert = where(temp_pert.eq.0,temp_pert@_FillValue,temp_pert)
>
> ;_____Check region/assign region___
>
> minlon = min(bccr_lon)
> maxlon = max(bccr_lon)
>
> minlat = min(bccr_lat)
> maxlat = max(bccr_lat)
>
> print("min/max lat = " +minlat+"/" +maxlat) ; -87.8638/87.8638
> print("min/max lon = " +minlon+"/"+maxlon) ; 0/357.188
>
> ;_______Convert to a SCRIP convention file____
>
> Opt = True
> Opt@ForceOverwrite = True
> Opt@PrintTimings = True
> Opt@Title = "BCCR lat/lon grid"
>
>
> latlon_to_SCRIP(dstGridName,"1x1",Opt)
>
> delete(Opt)
>
> Opt = True
> Opt@ForceOverwrite = True
> Opt@PrintTimings = True
>
>
>
> curvilinear_to_SCRIP(srcGridName,bccr_lat,bccr_lon,Opt) ;tried rectilinear as well and lat/lon. (?)
>
> delete(Opt)
>
>
> _______________________________________________
> 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 Mon Jun 18 12:29:19 2012

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