[ncl-talk] Problem with ESMF_regrid
music piano
musicpianoljy at gmail.com
Sun Nov 12 09:02:26 MST 2017
Hi, Tomoko
Would you try to use printVarSummary(var) to see what type of the data is ?
On Sat, Nov 11, 2017 at 10:50 PM, Tomoko Koyama <Tomoko.Koyama at colorado.edu>
wrote:
> Hello,
>
> I am trying to regrid Sea Ice Area Fraction and Sea Ice Thickness data
> from some CMIP5 daily data to EASE 100km grid.
> The following script works for Sea Level Pressure, Near-Surface
> Temperature, Geopotential Height etc. but not for those ice parameters.
>
> The error message is “Assignment type mismatch, right hand side can't be
> coerced to type of left hand side” occurring at regridding;
> var_regrid = ESMF_regrid(var,Opt)
>
> Does anyone see why this might be???
>
> Thank you in advance,
> Tomoko
>
>
> +++++++++++++++++
> + Error message +
> +++++++++++++++++
>
> Copyright (C) 1995-2015 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.3.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> (0) get_src_grid_info: source lat dims = (384)
> (0) get_src_grid_info: source lon dims = (320)
> (0) get_src_grid_info: source grid type is 'rectilinear'
> (0) curvilinear_to_SCRIP: calculating grid corners...
> (0) curvilinear_to_SCRIP: one or more lat values are at the
> (0) poles, so calculating grid corners using
> (0) calc_SCRIP_corners_boundaries...
> (0) calc_SCRIP_corners_boundaries
> (0) min/max original lat: 1/384
> (0) min/max original lon: 1/320
> fatal:Assignment type mismatch, right hand side can't be coerced to type
> of left hand side
> ^Mfatal:["Execute.c":8575]:Execute: Error occurred at or near line 770 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
>
> ^Mfatal:["Execute.c":8575]:Execute: Error occurred at or near line 1744
> in file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
>
> ^Mfatal:["Execute.c":8575]:Execute: Error occurred at or near line 1822
> in file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
>
> ^Mfatal:["Execute.c":8575]:Execute: Error occurred at or near line 3851
> in file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
>
> ^Mfatal:["Execute.c":8575]:Execute: Error occurred at or near line 3983
> in file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl
>
> ^Mfatal:["Execute.c":8573]:Execute: Error occurred at or near line 86
>
> ++++++++++
> + Script +
> ++++++++++
>
> 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"
>
> method = "bilinear"
> model = "CCSM4"
> gridtype = "latlon"
>
> rdiri = "/work/koyama_sice"
> in_diri = "/home/koyama/CMIP5/data/input"
> esmf_diri = in_diri + "/" + model
>
> begin
> ; Source grid
> srcGridDiri = rdiri + "/" + model
> fili = systemfunc("cd " + srcGridDiri + " ; ls sic*.nc")
> nfil = dimsizes(fili)
>
> ; Destination grid
> dstGridDiri ="/home/koyama/CMIP5/data/grid_coord"
> dstFileName = "NRims180x180.nc"
> dstGridFili = dstGridDiri + "/" + dstFileName
> dfile = addfile(dstGridDiri + "/" + dstFileName, "r")
> lat2d = dfile->latitude
> lon2d = dfile->longitude
>
> do ifil = 0, nfil-1
> srcGridFili = fili(ifil)
> sfile = addfile(srcGridDiri + "/" + srcGridFili, "r")
> dSizes = getfiledimsizes(sfile)
> var = sfile->sic
>
> lat1d = ndtooned(lat2d)
> lon1d = ndtooned(lon2d)
> lon1d = where(lon1d.lt.0,360.0+lon1d,lon1d)
> latlon_dims = dimsizes(lat2d) ; 180x180
>
> Opt = True
>
> Opt at ForceOverwrite = True
>
> Opt at SrcFileName = esmf_diri + "/" + model +"_SCRIP.nc" ;
> output file names
> Opt at DstFileName = esmf_diri + "/" + "EASE_ESMF.nc"
> Opt at WgtFileName = esmf_diri + "/" + model +"_2_EASE_"+method+".nc"
>
> Opt at SrcInputFileName = srcGridFili ; optional, but good
> idea
> Opt at DstInputFileName = dstGridFili
>
> Opt at SkipSrcGrid = False
> Opt at SkipDstGrid = False
> Opt at SkipWgtGen = False
> Opt at DstESMF = True
>
> Indexes = ind(.not.ismissing(lon1d))
> Opt at DstGridType = "unstructured" ; Destination grid
> Opt at DstGridLat = lat1d(Indexes) ; Strip off missing data
> Opt at DstGridLon = lon1d(Indexes)
>
> Opt at RemapIndexes = True ; This is necessary to
> remap
> Opt at Indexes = Indexes ; regridded values back to
> Opt at IndexesDims = latlon_dims ; locations on
> destination grid
>
> Opt at InterpMethod = method
>
> Opt at Debug = True
> Opt at PrintTimings = True
>
> Opt at CopyVarCoords = False ; we can't copy the
> coords because
> ; the weights on the file
> are only
> ; for the non-missing
> lat/lon values.
>
> Opt at SrcGridMask = where(ismissing(var(0,:,:)),0,1)
>
> var_regrid = ESMF_regrid(var,Opt) ; Regrid var
>
> copy_VarAtts(var,var_regrid)
> var_regrid at _FillValue = 1.e+20
> var_regrid at missing_value = 1.e+20
> var_regrid at _FillValue = var at _FillValue
>
> var_regrid!0 = "time"
> var_regrid!1 = "i"
> var_regrid!2 = "j"
>
> time = ispan(1,dSizes(3),1) ; CCSM4
> time!0 = "time"
> time at long_name = "time"
> time at units = "month"
> time&time = time
>
> var_regrid&time = time
> var_regrid&i = lat2d&i
> var_regrid&j = lat2d&j
>
> delete( var_regrid at lat1d )
> delete( var_regrid at lon1d )
> if ( isatt( var_regrid, "lat2d" ) ) then
> delete( var_regrid at lat2d )
> end if
> if ( isatt( var_regrid, "lon2d" ) ) then
> delete( var_regrid at lon2d )
> end if
>
> ;;----------------------------------------------------------------------
> ;; Write regridded data to file
> ;;----------------------------------------------------------------------
> str = str_split(srcGridFili, ".")
> filo = str(0) + ".rgrd.nc"
>
> if ( isfilepresent(srcGridDiri+"/"+filo) .eq. True ) then
> system( "rm " + filo )
> end if
>
> setfileoption("nc","Format","LargeFile")
> fo = addfile( srcGridDiri + "/" + filo,"c")
> fo->var = var_regrid
> fo->lat = lat2d
> fo->lon = lon2d
>
> ;; Clean up
> delete( var )
> delete( sfile )
> delete( Opt )
> delete( filo )
> delete( fo )
> delete( var_regrid )
>
> end do
>
> delete( dfile )
> delete( lat2d )
> delete( lon2d )
>
> end
>
>
> _______________________________________________
> 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/20171112/661cc5c3/attachment.html>
More information about the ncl-talk
mailing list