<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>As outlined by DaveA:</div><div>===================<br></div><div><br></div><div>If integer_val, float_val already exist:    <br></div><div><br></div><div>      integer_val =  float_val         ; illegal</div><div>      integer_val =  double_val     ; illegal</div><div>      float_val     = double_val      ; illegal</div><div><br></div><div>NCL requires user to explicitly perform a 'type reduction' when information may be lost</div><div><br></div><div><div>      integer_val =  toint(float_val)         ; legal</div><div>      integer_val =  toint(double_val)     ; legal</div><div>      float_val     = tofloat(double_val     ; legal</div><div><br></div><div>===</div><div>I speculate the 'xJA' is type float<br></div></div><div>  wvar   = xJA                                  ; copy meta data</div><div><br></div><div>Hence, 'wvar' is float</div><div>   printVarSummary(wvar)</div><div><br></div><div>I speculate 'lat'  [ xJA&lat] is type double<br></div><div><br></div><div><br></div><div>  wvar   = xJA*conform(xJA, clat, 1) ; <b>line 81</b></div><div><b><br></b></div><div><b>   </b>if you did a <br></div><div><br></div><div>  test_type = xJA*conform(xJA, clat, 1) <br></div><div>  print(typeof(test_type))                       <===== this would be double</div><div><br></div><div>Hence,</div><div> wvar   = xJA*conform(xJA, clat, 1) <br></div><div>is illegal because it is <br></div><div> type_float = type_double   <=== illegal<br></div><div><br></div><div>==================<br></div><div> wvar   = tofloat( xJA*conform(xJA, clat, 1) )</div><div><br></div><div>====================<br></div>=====================</div><div>I would probably do:</div><div><br></div><div>  rad    = 4.0*atan(1.0)/180.0</div><div>  lat     = tofloat(xJA&lat)<br></div><div>  clat   = cos(rad*lat)<br>  clat   = where(clat.lt.0, xJA@_FillValue, clat)  ; avoid a potential numerical issue at pole<br>  clat   = sqrt( clat )  ; avoid a potential numerical issue at pole</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 19, 2021 at 12:12 PM Dave Allured - NOAA Affiliate via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">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.</div><div dir="ltr"><br></div><div dir="ltr"><a href="https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclDataTypes.shtml#Coercion" target="_blank">https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclDataTypes.shtml#Coercion</a><br><div><br></div><div>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:</div><div><br></div>    printVarSummary (right side)<br>    printVarSummary (left side)<br></div><div dir="ltr"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 19, 2021 at 11:15 AM dale zuri via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi NCL user,</div><div><br></div><div>I would appreciate any help to fix this issue. Although the data dimension looks okay, this error keeps coming. <br></div><div><br></div><div>Thanks</div><div>DZ<br></div><div><br></div><div>fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be coerced to type of left hand side<br>fatal:["Execute.c":8637]:Execute: Error occurred at or near line 81 in file eof-ensemble.ncl</div><div><br></div><div>fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be coerced to type of left hand side<br>fatal:["Execute.c":8637]:Execute: Error occurred at or near line 120 in file eof-ensemble.ncl</div><div><br></div><div>Variable: xJA<br>Type: float<br>Total Size: 2246400 bytes<br>            561600 values<br>Number of Dimensions: 3<br>Dimensions and sizes:      [time | 26] x [lat | 75] x [lon | 288]<br>Coordinates: <br>            time: [  31..9156]<br>            lat: [20.26178010471205..  90]<br>            lon: [   0..358.75]<br>Number Of Attributes: 1<br>  NMO :      0<br><br></div><div><u>Code: </u><br></div><div>xJA = month_to_season (Avg, "DJF")<br>printVarSummary(xJA)<br>  ;nyrs   = dimsizes(var&time)<br>  ;printVarSummary(var)<br><br>; =================================================================<br>; create weights:  sqrt(cos(lat))   [or sqrt(gw) ] for covariance<br>; =================================================================<br>  rad    = 4.0*atan(1.0)/180.0<br>  clat   = cos(rad*xJA&lat)<br>  clat   = where(clat.lt.0, 0.0, clat)  ; avoid a potential numerical issue at pole<br>  clat   = sqrt( clat )  ; avoid a potential numerical issue at pole<br><br>; =================================================================<br>; weight all observations <br>; =================================================================<br>  wvar   = xJA                                  ; copy meta data<br>  printVarSummary(wvar)<br>  wvar   = xJA*conform(xJA, clat, 1) ; <b>line 81</b><br> ; wvar@long_name = "Wgt: "+wvar@long_name<br>; =================================================================<br>; EOF<br>; Reorder (lat,lon,time) the *weighted* input data<br>; Access the area of interest via coordinate subscripting<br>; =================================================================<br>  x      = wvar(lat|:,lon|:,time|:)<br><br>  eof    = eofunc_Wrap(x, neof, optEOF)<br>  eof_ts = eofunc_ts_Wrap (x, eof, optETS)</div><div>printVarSummary( eof )<br>  printVarSummary( eof_ts )<br>return<br>; =================================================================<br>; Perform varimax rotation<br>; =================================================================<br><br>  eof_rot = eofunc_varimax_Wrap( eof, 1 )<br>  printVarSummary( eof_rot )<br>  print("eof_rot: min="+min(eof_rot)+"   max="+max(eof_rot) )<br><br>; =================================================================<br>; put into descending order<br>; =================================================================<br><br>  eofunc_varimax_reorder( eof_rot )<br>  printVarSummary( eof_rot )<br><br>; =================================================================<br>; Normalize time series: Sum spatial weights over the area of used<br>; =================================================================<br><br>  dimx   = dimsizes( x )<br>  mln    = dimx(1)<br>  sumWgt = mln*sum( clat )<br>  printVarSummary( sumWgt )<br>print(sumWgt)<br>  eof_ts = eof_ts/sumWgt ; <b>line 120</b><br>return</div></div></blockquote></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>