[ncl-talk] ESMF regrid fails when mask applied on multiple time steps

Dennis Shea shea at ucar.edu
Thu Sep 10 08:09:14 MDT 2015


Just looking at the netCDF file,

    minlon = min(lon)
    maxlon = max(lon)
    minlat  = min(lat)
    maxlat = max(lat)

    print("lat_range="+(maxlat-minlat))
    print("lon_range="+(maxlon-minlon))

    print("nlat="+toint((maxlat-minlat)/0.0818))
    print("mlon="+toint((maxlon-minlon)/0.0818))

(0) lat_range=0.108334
(0) lon_range=0.508331

(0) nlat=1
(0) mlon=6

===
Is this correct???

I speculate that under-the-hood NCL's interface to the ESMF software
is 'confused' by this.

Is there something wrong with the source file?

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

Re:

   ; WORKS
   ;swe = infile->Snow_Water_Equivalent_with_State_Model_variable_type(0,:,:)
   ; FAILS
   ;swe = infile->Snow_Water_Equivalent_with_State_Model_variable_type
   ; (:,:,:)

FYI:
The most efficient way to read in a complete variable from a nc/nc4,
hdf4/hdf5, grb1/2 files is to not use the (:,:,:).
Use


    swe = short2flt(infile->Snow_Water_Equivalent_with_State_Model_variable_type)
          ; (:,:,:)

    printVarSummary(swe)      ; [time | 2] x [latitude | 14] x [longitude | 62]
    printMinMax(swe, 0)       ; min=-9999   max=2214


Although your use of -9999 should be acceptable, I would suggest the following

; assign _FillValue

    swe at _FillValue = toshort(-9999)   ; swe is type short
    printVarSummary(swe)
    printMinMax(swe, 0)       ;  min=0   max=2214

; subsequently

   ;Opt at SrcGridMask = where(swe.eq.-9999,0,1)
    Opt at SrcGridMask = where(ismissing(swe),0,1)

D


On Wed, Sep 9, 2015 at 9:14 PM, Neil Berg <neil.berg14 at gmail.com> wrote:
>
> On Sep 9, 2015, at 8:01 PM, Neil Berg <neil.berg14 at gmail.com> wrote:
>
> Hello all,
>
> I am having an issue using ESMF_regrid after masking out water grid cells
> (marked by -9999) in my source array when ingesting all times in the 3D
> array (ntim x nlat x nlon).  There is no issue if I only read in the first
> time step, hence making the input 2D (nlat x nlon).  The lat/lon grid is the
> same for all time steps and I’ve included both a small sample of the source
> array data (snodas_tmp.nc) and the relevant code below.
>
> The error message when including multiple time steps is:
>
> fatal:Eq: Dimension size, for dimension number 0, of operands does not
> match, can't continue
>
> Any tips for using ESMF_regrid with a mask over multiple time steps?
>
> Thanks in advance,
>
> Neil
>
>
>
>
>
>     source_file = “./snodas_tmp.nc"
>
>     infile = addfile(source_file, "r")
>     ; WORKS
>     ;swe =
> infile->Snow_Water_Equivalent_with_State_Model_variable_type(0,:,:)
>     ; FAILS
>     swe =
> infile->Snow_Water_Equivalent_with_State_Model_variable_type(:,:,:)
>     lat = infile->latitude
>     lon = infile->longitude
>
>     minlon = min(lon)
>     maxlon = max(lon)
>     minlat = min(lat)
>     maxlat = max(lat)
>
>     Opt = True ; Regridding options
>
>     Opt at SrcFileName = "snodas_SrcSCRIP.nc" ; Output files
>     Opt at DstFilename = "snodas_DstSCRIP.nc"
>     Opt at ForceOverwrite = True
>
>     Opt at SrcTitle = source_file
>
>     Opt at DstGridType = ".0818deg" ; destination grid of 9km or .0818 degrees
>     Opt at DstLLCorner = (/minlat, minlon/)
>     Opt at DstURCorner = (/maxlat, maxlon/)
>
>     Opt at SrcRegional = True ; regional grid source
>     Opt at DstRegional = True ; regional grid destination
>
>     ; need to mask out water pts, marked as -9999
>     Opt at SrcGridMask = where(swe.eq.-9999,0,1)
>
>     Opt at InterpMethod = "bilinear"
>     Opt at WgtFileName = "snodas_Swath_2_Rect_bilinear.nc"
>
>     swe_regrid = ESMF_regrid(swe,Opt)
>
>
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


More information about the ncl-talk mailing list