[ncl-talk] sub: EOF issue

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Fri Mar 19 12:11:42 MDT 2021


The message indicates that this is a data type change problem, not a
dimension problem.  There are some kinds of type changes that are not
allowed, because the receiving type does not hold exactly the same range of
numbers as the generated type.  This is to protect you from unexpected and
hidden changes in data values.  Please review the NCL chapter on coercion
of data types.

https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclDataTypes.shtml#Coercion

Whenever you get any kind of right side/left side mismatch, you should
always look at the right and left sides separately.  Right before line 81,
do this and compare the two results.  See if you can spot the problem:

    printVarSummary (right side)
    printVarSummary (left side)


On Fri, Mar 19, 2021 at 11:15 AM dale zuri via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Hi NCL user,
>
> I would appreciate any help to fix this issue. Although the data dimension
> looks okay, this error keeps coming.
>
> Thanks
> DZ
>
> fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be
> coerced to type of left hand side
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 81 in
> file eof-ensemble.ncl
>
> fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be
> coerced to type of left hand side
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 120 in
> file eof-ensemble.ncl
>
> Variable: xJA
> Type: float
> Total Size: 2246400 bytes
>             561600 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 26] x [lat | 75] x [lon | 288]
> Coordinates:
>             time: [  31..9156]
>             lat: [20.26178010471205..  90]
>             lon: [   0..358.75]
> Number Of Attributes: 1
>   NMO : 0
>
> *Code: *
> xJA = month_to_season (Avg, "DJF")
> printVarSummary(xJA)
>   ;nyrs   = dimsizes(var&time)
>   ;printVarSummary(var)
>
> ; =================================================================
> ; create weights:  sqrt(cos(lat))   [or sqrt(gw) ] for covariance
> ; =================================================================
>   rad    = 4.0*atan(1.0)/180.0
>   clat   = cos(rad*xJA&lat)
>   clat   = where(clat.lt.0, 0.0, clat)  ; avoid a potential numerical
> issue at pole
>   clat   = sqrt( clat )  ; avoid a potential numerical issue at pole
>
> ; =================================================================
> ; weight all observations
> ; =================================================================
>   wvar   = xJA                                  ; copy meta data
>   printVarSummary(wvar)
>   wvar   = xJA*conform(xJA, clat, 1) ; *line 81*
>  ; wvar at long_name = "Wgt: "+wvar at long_name
> ; =================================================================
> ; EOF
> ; Reorder (lat,lon,time) the *weighted* input data
> ; Access the area of interest via coordinate subscripting
> ; =================================================================
>   x      = wvar(lat|:,lon|:,time|:)
>
>   eof    = eofunc_Wrap(x, neof, optEOF)
>   eof_ts = eofunc_ts_Wrap (x, eof, optETS)
> printVarSummary( eof )
>   printVarSummary( eof_ts )
> return
> ; =================================================================
> ; Perform varimax rotation
> ; =================================================================
>
>   eof_rot = eofunc_varimax_Wrap( eof, 1 )
>   printVarSummary( eof_rot )
>   print("eof_rot: min="+min(eof_rot)+"   max="+max(eof_rot) )
>
> ; =================================================================
> ; put into descending order
> ; =================================================================
>
>   eofunc_varimax_reorder( eof_rot )
>   printVarSummary( eof_rot )
>
> ; =================================================================
> ; Normalize time series: Sum spatial weights over the area of used
> ; =================================================================
>
>   dimx   = dimsizes( x )
>   mln    = dimx(1)
>   sumWgt = mln*sum( clat )
>   printVarSummary( sumWgt )
> print(sumWgt)
>   eof_ts = eof_ts/sumWgt ; *line 120*
> return
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210319/b1caaa51/attachment.html>


More information about the ncl-talk mailing list