Re: Regrid NCEP grid(2.5x2.5) to unstructured SEgrid(clm data)

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Sep 30 2013 - 14:59:16 MDT

Hi,

I don't really have enough information, because I don't know what your "destination" latitude and longitude values look like. Did you verify that you have lat/lon values over the polar regions?

However, I noticed you set:

> Opt@SrcRegional = True ;;--Change (maybe)
> Opt@DstRegional = True ;;--Change (maybe)

It looks to me like you have a global grid, so set these to False, or don't set them at all.

Also, try commenting out:

> Opt@Pole ="teeth"

If you continue to have problems, it would help if I could have your updated script and data. Please see:

http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP

Thanks,

--Mary

On Sep 25, 2013, at 4:44 AM, ±èÀοø <rladlsdnjs88@gmail.com> wrote:

> Hello. Mary
>
> 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" ;;---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
>
>
>
>
>
>
> 2013/9/17 Mary Haley <haley@ucar.edu>
> We have several templates for ESMF regridding that might be more useful than this particular example:
>
> http://www.ncl.ucar.edu/Applications/Templates/#ESMF
>
> In your case, you want to go from a rectilinear grid to an unstructured grid, so take a look at the "ESMF_rect_to_unstruct.ncl" script.
>
> The template indicates where you need to change something with a "change likely" type of comment.
>
> --Mary
>
> On Sep 16, 2013, at 7:09 PM, ±èÀοø <rladlsdnjs88@gmail.com> wrote:
>
> > Thank you very much for reply.
> >
> > I have one more question.
> >
> > In my case I don't have weight file.
> >
> > So I think I might utilize the ESMF_regird_25.ncl.
> >
> > Well, example ESMF_regrid_25.ncl shows how to regrid CLM data to FVgrid
> >
> > On the contrary I have to regrid NCEP grid to CLM data.
> >
> > Is it also possible to regrid using the example ESMF_regrid_25.ncl without modifying the script?
> >
> > If It needs to modify the script, would you explain about that?
> >
> > Regards
> >
> > Miss Kim
>
>
>
>
> --
> --
> 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
> <rect_to_unstruct.jpg>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Sep 30 14:59:25 2013

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