[ncl-talk] Questions for ESMF_unstruct_to_1deg

Sujeong Lim sjlim1202 at gmail.com
Wed Nov 11 03:24:45 MST 2015


Dear.

I want to convert my unstructured file to 1x1 grid file. ( My model output
is similar with the CAM-SE.)
 Ex) T (time, lev, ncol) -> T (time,lev,lat,lon)
Since I have a missing value in the vertical levels, I will do interpolate
horizontal first, and vertical.

As a test, I tried to run the 'ESMF_unstruct_to_0.25deg.ncl'

In my thinking, I have to change the missing value.
And it has a problem to generate the weighting.
Could you help this problems?

I attached my script and bottoms are my errros.
------

(0)     write_grid_description: source lat dims = (86400)
(0)     write_grid_description: source lon dims = (86400)
(0)     write_grid_description: source grid type is 'unstructured'
(0)     unstructured_to_ESMF: triangulating the data ... this can be slow
(0)     min/max ElementVertices = 0/86399
(0)     unstructured_to_ESMF: total number of elements created: 172796

GCTAREA: The three input points must be distinct.
GCTAREA: The three input points must be distinct.
GCTAREA: The three input points must be distinct.
...

(0) unstructured_to_ESMF: Element Area: min:-1.60316e-13 max:1e+30
(0) write_grid_description: destination grid type is '1deg'
(0) curvilinear_to_SCRIP: calculating grid corners...
(0) curvilinear_to_SCRIP: no lat values are at the poles, so
(0)        calculating grid corners using
(0)        calc_SCRIP_corners_noboundaries...
(0) calc_SCRIP_corners_noboundaries
(0)      min/max original lat: -89/89
(0)      min/max original lon: 0/359
(0) calc_SCRIP_corners_noboundaries
(0)      min/max Extlat2d: -90/90
(0)      min/max Extlon2d: -1/360
(0) calc_SCRIP_corners_noboundaries
(0)      min/max ExtGridCenter_lat: -89.5/89.5
(0)      min/max ExtGridCenter_lon: -0.5/359.5
(0) ESMF_regrid_gen_weights: number of processors used: 1
(0) --------------------------------------------------
(0) ESMF_regrid_gen_weights: the following command is about to be executed
on the system:
(0) 'ESMF_RegridWeightGen --source source_grid_file.nc --destination
destination_grid_file.nc --weight unstruct_to_rect.nc --method bilinear
--src_type ESMF -i --64bit_offset'
(0) --------------------------------------------------
sh: ESMF_RegridWeightGen: command not found
(0) ESMF_regrid_gen_weights: output from 'ESMF_RegridWeightGen':
(0)      missing
(0) --------------------------------------------------
fatal:The result of the conditional expression yields a missing value. NCL
can not determine branch, see ismissing function
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 2291 in
file
/app/compilers/gcc/4.7.1/applib1/NCARG/6.1.2/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 3166 in
file
/app/compilers/gcc/4.7.1/applib1/NCARG/6.1.2/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 76 in file
ESMF_unstruct_to_0.25deg.ncl


 Thanks,



-- 



--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151111/58d10ba5/attachment.html 
-------------- next part --------------
;----------------------------------------------------------------------
; ESMF_unstruct_to_0.25deg.ncl
;
; This is an NCL/ESMF template file for regridding from an
; unstructured grid to a 0.25 degree grid. It uses ESMF_regrid
; to do the regridding.
;
; This script can be easily modified to do use something other than
; a 0.25 degree grid: "1x1", "G64", "5deg", etc.
;
; The unstructured grid is assumed to be contained in a NetCDF file.
;
; Search for lines with ";;---Change (likely)" or ";;---Change (maybe)".
; These are the lines you will likely or maybe have to change.
;
; Of course, you'll probably want to change other aspects of this
; code, like the options for plotting (titles, colors, etc).
;
; For more information on ESMF_regrid, see:
;
;    http://www.ncl.ucar.edu/Document/Functions/ESMF/ESMF_regrid.shtml
;----------------------------------------------------------------------
; This example uses the ESMF application "ESMF_RegridWeightGen" to
; generate the weights.
;
; For more information about ESMF:
;
;        http://www.earthsystemmodeling.org/
;
; This script uses built-in functions that are only available in
; NCL V6.1.0-beta and later.
;----------------------------------------------------------------------
load "./gsn_code.ncl"
load "./gsn_csm.ncl"
load "./contributed.ncl"
load "./ESMF_regridding.ncl"

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

;---Get variable to regrid
    var_name = "T"                      ;;---Change (likely)
    var      = sfile->$var_name$(0,:,:)       ;;---Change (likely)
    src_lat  = sfile->lat                   ;;---Change (maybe)
    src_lon  = sfile->lon                   ;;---Change (maybe)

;---Set up regridding options
    Opt                = True

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

    Opt at SrcGridLat       = src_lat
    Opt at SrcGridLon       = src_lon
    Opt at SrcRegional      = False            ;;--Change (maybe)
    Opt at SrcInputFileName = src_file          ; optional, but good idea
    Opt at SrcMask2D        = where(.not.ismissing(var(0,:)),1,0) ; Necessary if has
                                                          ; missing values.

    ;Opt at DstGridType      = "0.25deg"        ; destination grid
    Opt at DstGridType      = "1deg"        ; destination grid
    ;Opt at DstTitle         = "World Grid 0.25 degree resolution"
    Opt at DstTitle         = "World Grid 1 degree resolution"
    ;Opt at DstLLCorner      = (/-89.75d,   0.00d /)      ;;--Change (maybe)
    Opt at DstLLCorner      = (/-89.0d,   0.0d /)      ;;--Change (maybe)
    ;Opt at DstURCorner      = (/ 89.75d, 359.75d /)      ;;--Change (maybe)
    Opt at DstURCorner      = (/ 89.0d, 359.0d /)      ;;--Change (maybe)

    Opt at ForceOverwrite   = True
    Opt at Debug            = True
    Opt at PrintTimings     = False;True

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

    printVarSummary(var_regrid)

;----------------------------------------------------------------------
; 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","unstruct_to_0.25deg")
    wks = gsn_open_wks("ps","unstruct_to_1deg")

;---Resources to share between both plots
    res                      = True              ; Plot mods desired

    res at gsnDraw              = False
    res at gsnFrame             = False

    res at gsnMaximize          = True              ; Maximize plot

    res at cnFillOn             = True              ; color plot desired
    res at cnLinesOn            = False             ; turn off contour lines
    res at cnLineLabelsOn       = False             ; turn off contour labels
    res at cnFillMode           = "RasterFill"      ; turn raster on

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

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

    res at lbLabelBarOn         = False      ; Will turn on in panel later

    res at mpFillOn             = False

;---Resources for plotting regridded data
    res at gsnAddCyclic = False            ;;---Change (maybe)
    ;res at tiMainString  = "0.25 degree grid (" + Opt at InterpMethod + ")"
    res at tiMainString  = "1 degree grid (" + Opt at InterpMethod + ")"

    plot_regrid = gsn_csm_contour_map(wks,var_regrid,res)

;---Resources for plotting original data
    res at gsnAddCyclic = False            ;;---Change (maybe)
    res at sfXArray     = src_lon
    res at sfYArray     = src_lat
    res at tiMainString = "Original unstructured grid (" + \
                        dimsizes(src_lon) + " cells)"

    plot_orig = gsn_csm_contour_map(wks,var,res)

;---Draw both plots in a panel
    pres                   = True
    pres at gsnMaximize       = True
    pres at gsnPanelLabelBar  = True

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


More information about the ncl-talk mailing list