Regrid from rectilinear grid to unstructured grid(clm data)

From: ±èÀοø <rladlsdnjs88_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 25 2013 - 04:52:48 MDT

Dear NCL experts

Hello.

I tried to regrid from a rectilinear grid to an unstructured grid.

But, there is some problem.

I attached the result which has some problem.

In lower panel, there is missing value over land area of polar region.

For my experiments, I need the data which doesn't include the missing value
over land area.

I attached ncl code as follows.

Could you let me know about corrigendum in my code?

Thanks in advance.

===========================================

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/esmf/ESMF_regridding.ncl"

begin
;--Data file containing source grid
    src_file = "gfs.t00z.pgrb2f00.nc" ;;---Change (likely)
    sfile = addfile(src_file,"r")

;---Get variable to regrid
    varname = "TMP_P0_L1_GLL0" ;;---Change (likely)
    var = sfile->$varname$ ; Assumption is that "var"
; var =var-273.15
                                       ; contains coordinate arrays.
    printVarSummary(var) ; Make sure it has coord arrays.

;---Data file containing destination grid
    dst_file = "clmi.BCN.2000-01-01_0.47x0.63_gx1v6_simyr2000_c121001.nc<http://clmi.bcn.2000-01-01_0.47x0.63_gx1v6_simyr2000_c121001.nc/>"
        ;;---Change (likely)
    dfile = addfile(dst_file,"r")
    dst_lat = dfile->cols1d_lat ;;---Change (likely)
    dst_lon = dfile->cols1d_lon ;;---Change (likely)

;---Set up regridding options
    Opt = True

;---"bilinear" is the default. "patch" and "conserve" are other options.
    Opt@InterpMethod = "bilinear" ;;---Change (maybe)

    Opt@WgtFileName = "rect_to_unstruct.nc"

;
; These next two lines only needed if "var" doesn't
; contain coordinate arrays.
;

    Opt@SrcRegional = True ;;--Change (maybe)
    Opt@SrcInputFileName = src_file ; optional, but good idea
    Opt@SrcMask2D = where(.not.ismissing(var),1,0) ; Necessary if
has missing values.
    Opt@Pole ="teeth"

    Opt@DstGridType = "unstructured"
    Opt@DstGridLat = dst_lat ; destination grid
    Opt@DstGridLon = dst_lon
   Opt@DstRegional = True ;;--Change (maybe)
   Opt@DstMask2D = where(.not.ismissing(dst_lat).and.\
                          .not.ismissing(dst_lon),1,0) ; Necessary if
lat/lon

    Opt@DstLLCorner = (/-90.00d, 0.00d /) ;;--Change (maybe)
    Opt@DstURCorner = (/ 90.00d, 360.00d /) ;;--Change (maybe)
    ; has missing values.

    Opt@ForceOverwrite = True
    Opt@PrintTimings = True
    Opt@Debug = True

    var_regrid = ESMF_regrid(var,Opt) ; Do the regridding

    printVarSummary(var_regrid) ; Check that everything
    printMinMax(var_regrid,0) ; looks okay.

;----------------------------------------------------------------------
; Plotting section
;
; This section creates filled contour plots of both the original
; data and the regridded data, and panels them.
;----------------------------------------------------------------------
   wks = gsn_open_wks("ps","rect_to_unstruct")

   res = True

    res@gsnMaximize = True

    res@gsnDraw = False
    res@gsnFrame = False

   res@cnFillOn = True
   res@cnLinesOn = False
   res@cnLineLabelsOn = False
   res@cnFillMode = "RasterFill"

   res@lbLabelBarOn = False ; Turn on later in panel

; res@mpMinLatF = min(src_lat)
; res@mpMaxLatF = max(src_lat)
; res@mpMinLonF = min(src_lon)
; res@mpMaxLonF = max(src_lon)

;;--Change (maybe)
   mnmxint = nice_mnmxintvl( min(var), max(var), 18, False)
   res@cnLevelSelectionMode = "ManualLevels"
   res@cnMinLevelValF = mnmxint(0)
   res@cnMaxLevelValF = mnmxint(1)
   res@cnLevelSpacingF = mnmxint(2)

;---Resources for plotting original data
   res@gsnAddCyclic = False ;;---Change (maybe)
   res@tiMainString = "Original rectilinear grid"
;
   plot_orig = gsn_csm_contour_map(wks,var,res)

;---Resources for plotting regridded data

; res@mpFillOn = True
; res@mpOceanFillColor = "white"
; res@mpLandFillColor = "transparent"
; res@mpFillDrawOrder = "postdraw"

   res@gsnAddCyclic = False ;;---Change (maybe)
   res@tiMainString = "Unstructured grid (" + Opt@InterpMethod + ")"
   res@sfXArray = dst_lon
   res@sfYArray = dst_lat
   res@trGridType = "TriangularMesh"
   plot_regrid = gsn_csm_contour_map(wks,var_regrid,res)

;---Compare the plots in a panel
   pres = True
   pres@gsnMaximize = True
   pres@gsnPanelLabelBar = True

   gsn_panel(wks,(/plot_orig,plot_regrid/),(/2,1/),pres)

end

-- 
-- 
In-Won Kim
Intergrated Climate System Modeling Lab.
Department of Environmental Atmospheric Sciences
599-1 Daeyeon-dong, Nam-gu
Pukyong National University,
Busan, S.Korea
Tel. +82-51-629-6643
Fax +82-51-629-7991


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

rect_to_unstruct.jpg
Received on Wed Sep 25 04:53:01 2013

This archive was generated by hypermail 2.1.8 : Tue Oct 01 2013 - 14:41:43 MDT