Re: ESMF

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 02 2012 - 09:21:23 MDT

Hi SK,

We don't specifically have an example of this, but going from a rectilinear grid to a curvilinear grid is not too difficult.

The main thing you need to do is read off the lat/lon from both files, and set the appropriate options before you call ESMF_regrid to regrid a variable.

Let's assume the following:

   - NCEP file (source file) is called "NCEP.nc"
   - the WRF file (destination file) is "wrfout.nc"
   - the variable you want to regrid from the NCEP file is "RELHUM"
   - the lat/lon arrays on the NCEP file are 1D coordinate arrays attached to RELHUM
   - the lat/lon arrays on the WRF file are called "XLAT", "XLONG" (and three-dimensional)

Here's what the regridding part of your script would look like:

;---Open both files and get the lat/lon arrays
    sfile = addfile("NCEP.nc","r")
    dfile = addfile("wrfout.nc","r")

    rh = sfile->RELHUM ; variable to regrid
    dstlat = dfile->XLAT(0,:,:) ; Select only the first
    dst_on = dfile->XLONG(0,:,:) ; time step for now.

;---Set up options for regridding
    Opt = True

;---Source file (NCEP) options
    Opt@SrcRegional = True ; Default is False

;---Destination file (WRF) options
    Opt@DstGridLat = dstlat
    Opt@DstGridLon = dstlon
    Opt@DstRegional = True ; Default is False

    Opt@ForceOverwrite = True
    ;Opt@PrintTimings = True
    ;Opt@Debug = True
;
; Regrid the data. "rh" contains 1D coordinate arrays,
; so these are used automatically as the "source" grid.
;
    Opt@InterpMethod = "bilinear" ; this is the default, "patch" and "conserve" are also available

    rh_regrid = ESMF_regrid(rh,Opt)
    printVarSummary(rh_regrid)

Note: because the WRF grid is curvilinear, this means that the lat/lon values cannot be
represented as 1D coordinate arrays like they are on the NCEP grid. This means
that when you do a "printVarSummary" of "rh_regrid", you won't see any lat/lon
information.

Usually, what you want to do at this point, is write this data out to a file, or plot it.
If you write it to a file, you should do something like this:

;---Add additional attribute information to rh_regrid to further describe it
  rh_regrid@coordinates = "latitude longitude"
  rh_regrid@description = "RELHUM regridded from NCEP global reanlysis 1x1 degree to WRF output grid"

  fout = addfile("NCEP_2_WRF.nc","c")
  fout->RELHUM = rh_regrid
  fout->latitude = dstlat
  fout->longitude = dstlon

Of course, you may also want to write some additional information to the NCEP_2_WRF.nc file, like the date created, the regridding method used, etc.

--Mary

On Jun 30, 2012, at 3:37 AM, sk wrote:

> Hi There,
> Is there example of using ESMF to interpolate NCEP global reanalysis 1x1 degree on WRF output grid?
> Regards,
> SK
> _______________________________________________
> 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 Jul 2 09:21:37 2012

This archive was generated by hypermail 2.1.8 : Tue Jul 03 2012 - 15:40:39 MDT