[ncl-talk] Missing values after ESMF regridding

Mary Haley haley at ucar.edu
Fri Mar 16 16:07:03 MDT 2018


Hi Bian,

There were three main issues with your script.

The first one I already mentioned. These two lines only cover half of the
northern hemisphere:

    Opt at DstLLCorner       = (/ 0.25d,   0.25d/)
    Opt at DstURCorner       = (/89.75d, 179.75d/)

You need to change this to:

    Opt at DstLLCorner       = (/ 0.25d, -180.00d/)
    Opt at DstURCorner       = (/89.75d,  179.75d/)

Second, since your swe2d variable has missing values in it, you need to
specify these locations when you set SrcMaskGrid:

    Opt at SrcMask2D         = where(ismissing(lat2d).or.ismissing(swe2d),0,1)

Third, since your destination grid doesn't cover the whole globe, you need
to set:

    Opt at DstRegional       = True
​

I don't think the DstRegional is required in general, because your
longitudes *do* wrap around the whole globe, but I don't think it hurts.


I've included a modified version of your script and the image it produces.


Let me know if you have any questions.  I'm in a bit of a hurry, so I
decided to just send this along without a lot of detail, but hopefully the
script is self-explanatory.


Regards,


--Mary



On Thu, Mar 15, 2018 at 1:54 PM, Mary Haley <haley at ucar.edu> wrote:

> Hi Bian,
>
> I'm looking into this.
>
> Meanwhile, I see that your original data goes from -180 to 180, but the
> lower left corner and upper right corner of the destination grid was set to:
>
>     Opt at DstLLCorner       = (/ 0.25d,   0.25d/)
>     Opt at DstURCorner       = (/89.75d, 179.75d/)
>
> This is restricting your data in the longitude direction to go from 0.25
> and 179.75. Perhaps you meant for this to be:
>
>     Opt at DstLLCorner       = (/ 0.25d, -180.00d/)
>     Opt at DstURCorner       = (/89.75d,  179.75d/)
>
> However, this still doesn't fix the issue, so I'm looking into it further.
> I'm wondering if this is a missing value issue, because I noticed that your
> lat/lon has some missing values in it.
>
> --Mary
>
>
>
> On Thu, Mar 15, 2018 at 2:08 AM, Bian Qingyun <bianqy at tea.ac.cn> wrote:
>
>>
>>
>> Hello,
>>
>> I'm regridding AMSR-E L3 daily snow following the examples on NCL website
>> http://www.ncl.ucar.edu/Applications/Scripts/ESMF_regrid_13.ncl and hdf
>> website http://hdfeos.org/zoo/index_openNSIDC_Examples.php#AMSR_E.
>>
>> All is fine,but there are missing values along 90°E and 90°W after
>> regridding while there are no missing values in original data along and
>> near 90°E and 90°W 。
>>
>> Below is my script. I also attached the AMSR-E data file in case.
>>
>> ----------------------
>>
>> ----------------------
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"
>>
>> begin
>> ;-----read data
>>     srcFileName = "AMSR_E_L3_DailySnow_V09_20100311.hdf"
>> ; Source file
>>     eos_file   = addfile(srcFileName + ".he2","r")
>>     lon2d       = eos_file->GridLon_Northern_Hemisphere
>>     lat2d       = eos_file->GridLat_Northern_Hemisphere
>>   ; Process NAN (1e51) fillValue for LAMAZ geolocation.
>>     lon2d=where(lon2d .gt. 1000, -999.0, lon2d)
>>     lat2d=where(lat2d .gt. 1000, -999.0, lat2d)
>>     lon2d at _FillValue = -999.0
>>     lat2d at _FillValue = -999.0
>>
>>
>>     hdf_file = addfile(srcFileName, "r")
>>   ; Read the dataset.
>>     hdf_data = hdf_file->SWE_NorthernDaily
>>
>>   ; Filter out invalid range values.
>>   ; See "Table 2. Pixel Values ofr the SWE Feids" from [2].
>>     hdf_data = where(hdf_data .gt. 240, hdf_data at _FillValue, hdf_data)
>>
>>   ; Prepare data for plotting by converting type.
>>     swe2d = tofloat(hdf_data)
>>     swe2d at _FillValue = tofloat(hdf_data at _FillValue)
>>
>>   ; Multiply by two according to data spec [2].
>>     swe2d = 2 * swe2d
>>
>>   ; You can get the description of data set from the data spec [2].
>>     swe2d at long_name = "Northern Hemisphere 5-day Snow Water Equivalent
>> ~C~ (" + hdf_data at hdf_name + ")"
>>     swe2d at units = "mm"
>>   ; Associate data with lat/lon.
>>     swe2d at lon2d = lon2d
>>     swe2d at lat2d = lat2d
>>
>> ;-----ESMF regridding
>>     Opt                   = True            ; Options for regridding
>>
>>     Opt at SrcFileName       = "EASE_SCRIP.nc"  ; Output files
>>     Opt at DstFileName       = "NH_SCRIP.nc"
>>     Opt at WgtFileName       = "EASE_2_NH_patch.nc"
>>     Opt at ForceOverwrite    = True
>>     Opt at SrcMask2D         = where(ismissing(lat2d),0,1)
>>     Opt at SrcGridLat        = lat2d
>>     Opt at SrcGridLon        = lon2d
>>
>>     Opt at DstGridType       = "0.25deg"       ; Destination grid
>>     Opt at DstTitle          = "Northern Hemisphere 0.25 resolution"
>>     Opt at DstLLCorner       = (/ 0.25d,   0.25d/)
>>     Opt at DstURCorner       = (/89.75d, 179.75d/)
>>
>>     Opt at InterpMethod      = "bilinear"   ; Careful! Patch method takes a
>> long time
>>
>>     Opt at Debug           = True
>>
>>     swe_regrid = ESMF_regrid(swe2d,Opt)    ; Regrid swe
>>     printVarSummary(swe_regrid)
>>
>> ;----------------------------------------------------------------------
>> ; Plotting section
>> ;----------------------------------------------------------------------
>>     wks = gsn_open_wks("x11","ESMF_regrid")     ; send graphics to PNG
>> file
>>
>>     res                     = True              ; Plot mods desired.
>>     res at gsnMaximize         = True              ; Maximize plot
>>
>>     res at gsnDraw             = False
>>     res at gsnFrame            = False
>>
>>     res at cnFillOn            = True              ; color plot desired
>>     res at cnFillPalette       = "amwg"            ; set color map
>>     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 cnLevelSelectionMode= "ExplicitLevels" ; set explicit contour
>> levels
>>     res at cnLevels            = (/-300,-250,-200,-150,-100,   \
>>                                 0,1,5,10,25,100,200,300,400/)
>>
>>     res at lbLabelBarOn        = False              ; turn on in panel
>>
>>     res at trGridType          = "TriangularMesh"   ; allow missing
>> coordinates
>>
>>
>>     res at gsnPolar            = "NH"               ; specify the hemisphere
>>     res at mpMinLatF           = 35
>>
>> ;---Plot original data.
>>     res at gsnAddCyclic = False
>>     res at sfXArray     = lon2d
>>     res at sfYArray     = lat2d
>>     res at tiMainString = "Original EASE grid (" +
>> str_join(dimsizes(lat2d),",") + ")"
>>     res at trGridType = "TriangularMesh"
>>     res at cnFillMode = "RasterFill"
>>
>>     plot_orig   = gsn_csm_contour_map_polar(wks,swe2d,res)
>>
>>     delete(res at sfXArray)
>>     delete(res at sfYArray)
>>
>> ;---Plot regridded data.
>>     res at gsnAddCyclic = True
>>
>>     dims = tostring(dimsizes(swe_regrid))
>>     res at tiMainString = "Regridded to 0.25 degree grid (" + \
>>                        str_join(dims," x ") + ")"
>>
>>     plot_regrid = gsn_csm_contour_map_polar(wks,swe_regrid,res)
>>
>> ;---Compare the plots in a panel
>>     pres                    = True
>>     pres at gsnMaximize        = True
>>     pres at gsnPanelLabelBar   = True
>>     pres at lbLabelFontHeightF = 0.01
>>     pres at pmLabelBarWidthF   = 0.8
>>
>>     gsn_panel(wks,(/plot_orig,plot_regrid/),(/1,2/),pres)
>> end
>>
>> ---------------------------
>>
>> ---------------------------
>>
>> Any suggestions are appreciated! Thank you!
>>
>> Best,
>>
>> Qingyun
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180316/6a655306/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: swe_regrid.png
Type: image/png
Size: 304007 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180316/6a655306/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: regrid_mod.ncl
Type: application/octet-stream
Size: 4626 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180316/6a655306/attachment-0001.obj>


More information about the ncl-talk mailing list