[ncl-talk] sub: EOF issue
dale zuri
dalezuri at gmail.com
Fri Mar 19 16:50:33 MDT 2021
Great.
Thanks, Dennis & Dave.
On Fri, Mar 19, 2021 at 1:31 PM Dennis Shea <shea at ucar.edu> wrote:
> As outlined by DaveA:
> ===================
>
> If integer_val, float_val already exist:
>
> integer_val = float_val ; illegal
> integer_val = double_val ; illegal
> float_val = double_val ; illegal
>
> NCL requires user to explicitly perform a 'type reduction' when
> information may be lost
>
> integer_val = toint(float_val) ; legal
> integer_val = toint(double_val) ; legal
> float_val = tofloat(double_val ; legal
>
> ===
> I speculate the 'xJA' is type float
> wvar = xJA ; copy meta data
>
> Hence, 'wvar' is float
> printVarSummary(wvar)
>
> I speculate 'lat' [ xJA&lat] is type double
>
>
> wvar = xJA*conform(xJA, clat, 1) ; *line 81*
>
> if you did a
>
> test_type = xJA*conform(xJA, clat, 1)
> print(typeof(test_type)) <===== this would be
> double
>
> Hence,
> wvar = xJA*conform(xJA, clat, 1)
> is illegal because it is
> type_float = type_double <=== illegal
>
> ==================
> wvar = tofloat( xJA*conform(xJA, clat, 1) )
>
> ====================
> =====================
> I would probably do:
>
> rad = 4.0*atan(1.0)/180.0
> lat = tofloat(xJA&lat)
> clat = cos(rad*lat)
> clat = where(clat.lt.0, xJA at _FillValue, clat) ; avoid a potential
> numerical issue at pole
> clat = sqrt( clat ) ; avoid a potential numerical issue at pole
>
> On Fri, Mar 19, 2021 at 12:12 PM Dave Allured - NOAA Affiliate via
> ncl-talk <ncl-talk at mailman.ucar.edu> wrote:
>
>> 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
>>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at mailman.ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210319/5b98e37b/attachment.html>
More information about the ncl-talk
mailing list