[ncl-talk] The rigmost dimension of x must be equal to the rightmost dimension of y

Adam Phillips asphilli at ucar.edu
Fri Sep 1 16:04:33 MDT 2017


Hi Melanie,
clmMonTLL and calcMonAnomTLL expect the input arrays to be 3-dimensional
and ordered time x latitude x longitude. Your x2 array is a 4-dimensional
array. Try doing this to eliminate the depth dimension:
 x2Clm   = clmMonTLL(x2(:,0,:,:))                             ;
(12,lat,lon;)
x2Anom  = calcMonAnomTLL(x2(:,0,:,:), xClm)                ; (time, lat,lon)

alternatively, you can use rmMonAnnCycTLL to do the same thing:
x2Anom = rmMonAnnCycTLL(x2(:,0,:,:))

https://www.ncl.ucar.edu/Document/Functions/Contributed/rmMonAnnCycTLL.shtml

Hope that helps!
Adam


On Fri, Sep 1, 2017 at 12:58 PM, Melanie O' hanoly <mel.hanoly at gmail.com>
wrote:

> Hi Adam..
>
> Thank you so much for help me..
> But  now have some problems in calculating anomalies
>
> Variable: x
> Type: double
> Total Size: 29760000 bytes
>             3720000 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 372] x [lat | 100] x [lon | 100]
> Coordinates:
>             time: [   0..16260480]
>             lat: [-89.09999999999999..89.10000000000002]
>             lon: [   0..356.4]
> Number Of Attributes: 2
>   _FillValue : -999000000
>   missing_value : -999000000
>
> Variable: x2
> Type: float
> Total Size: 14880000 bytes
>             3720000 values
> Number of Dimensions: 4
> Dimensions and sizes: [time | 372] x [depth | 1] x [latitude | 100] x
> [longitude | 100]
>
> fatal:Number of dimensions in parameter (0) of (clmMonTLL) is (4), (3)
> dimensions were expected
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 86 in
> file eof.ncl
>
> fatal:Number of dimensions in parameter (0) of (calcMonAnomTLL) is (4),
> (3) dimensions were expected
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 88 in
> file eof.ncl
>
> This is my script
>
> "; ==============================================================
> ; compute climatology and Anomalies                      2 file
> ; =============================================================
>  (86)  x2Clm   = clmMonTLL(x2)                             ; (12,lat,lon;)
>  (87)
>  (88)  x2Anom  = calcMonAnomTLL(x2, xClm)                ; (time, lat,lon)
>
>   printVarSummary(x2Anom)
>    printMinMax(x2Anom, True)
> ; ================================================================="
>
>
>
> On Tue, Aug 22, 2017 at 5:42 PM, Adam Phillips <asphilli at ucar.edu> wrote:
>
>> Hi Melanie,
>> regCoef operates on the rightmost dimensions of the two input arrays, and
>> expects those two rightmost dimensions to have the same size. See the
>> documentation here:
>> https://www.ncl.ucar.edu/Document/Functions/Built-in/regCoef-1.shtml
>> referring specifically to the Arguments - y section near the top.
>>
>> Thus, assuming your EOF/principal component timeseries was computed over
>> the TIME1 dimension, you should change this:
>> eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:),
>> x2(TIME1|:,DEPTH1_1|:,LAT|:,LON|:))/)
>> to this:
>> eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:),
>> x2(DEPTH1_1|0,LAT|:,LON|:,TIME1|:))/)
>> (Note that I also changed "DEPTH1_1|:" to "DEPTH1_1|0" so that the first
>> and only index is chosen, that way the array returned to the lefthand side
>> of the equal sign will be dimensioned lat (100) x lon (100).)
>>
>> If you were using regCoef_n, you could do this:
>> eof_regres(ne,:,:) = (/ regCoef_n(eof_ts(ne,:),
>> x2(TIME1|:,DEPTH1_1|0,LAT|:,LON|:),0,0) /)
>>
>> The last two arguments represent the dimension number to operate on for
>> the eof_ts and x2 arrays. In this specific case, you are index subscripting
>> eof_ts from a 2D array to a 1D array, and thus regCoef_n will only see a 1D
>> array and the 1st dimension should be operated on. Finally, you are
>> dimension reordering x2, and you don't really need to do this if you were
>> to use regCoef_n. You just need to indicate the correct dimension to
>> operate on with the last provided argument.
>>
>> Hope that all helps. If you have any further questions please respond to
>> the ncl-talk email list.
>> Adam
>>
>> On Tue, Aug 22, 2017 at 2:19 PM, Melanie O' hanoly <mel.hanoly at gmail.com>
>> wrote:
>>
>>> *Dear NCL users, I just have a little knowledge on NCL. So, could anyone help me?*
>>>
>>> *I have two data with 372 timestep, one has 3D and the other 4D, someone please help me with this error?*
>>>
>>> *"**fatal:regCoef: The rightmost dimension of x must be equal to the rightmost dimension of y"*
>>>
>>> *The summary is bellow*
>>>
>>>
>>> *This is the scrip line error "; Regress;
>>> =================================================================
>>> eof_regres = eof ; create an array w meta data do ne=0,neof-1
>>> eof_regres(ne,:,:) = (/ regCoef(eof_ts(ne,:),
>>> x2(TIME1|:,DEPTH1_1|:,LAT|:,LON|:))/) end do printVarSummary(eof_regres)
>>> printMinMax(eof_regres, True)*
>>> *"*
>>>
>>>
>>> *If i use regCoef_n, shows this error "fatal:syntax error: function
>>> regCoef_n expects 4 arguments, got 2"*
>>> Summary
>>> Copyright (C) 1995-2017 - All Rights Reserved
>>>  University Corporation for Atmospheric Research
>>>  NCAR Command Language Version 6.4.0
>>>  The use of this software is governed by a License Agreement.
>>>  See http://www.ncl.ucar.edu/ for more details.
>>>
>>> Variable: x
>>> Type: double
>>> Total Size: 29760000 bytes
>>>             3720000 values
>>> Number of Dimensions: 3
>>> Dimensions and sizes: [time | 372] x [lat | 100] x [lon | 100]
>>> Coordinates:
>>>             time: [   0..16260480]
>>>             lat: [-89.09999999999999..89.10000000000002]
>>>             lon: [   0..356.4]
>>> Number Of Attributes: 2
>>>   _FillValue : -999000000
>>>   missing_value : -999000000
>>>
>>> Variable: x2
>>> Type: double
>>> Total Size: 29760000 bytes
>>>             3720000 values
>>> Number of Dimensions: 4
>>> Dimensions and sizes: [TIME1 | 372] x [DEPTH1_1 | 1] x [LAT | 100] x
>>> [LON | 100]
>>> Coordinates:
>>>             TIME1: [1928.06849316134..1958.561643829649]
>>>             DEPTH1_1: [17.5..17.5]
>>>             LAT: [-89.1..89.1]
>>>             LON: [ 0..356.4]
>>> Number Of Attributes: 4
>>>   long_name : DIC[L=1:372]
>>>   _FillValue : -9.999999999999999e+33
>>>   missing_value : -9.999999999999999e+33
>>>   history : From dic_uvic
>>>
>>> Variable: eof_ts
>>> Type: double
>>> Total Size: 2976 bytes
>>>             372 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes: [evn | 1] x [time | 372]
>>> Coordinates:
>>>             evn: [1..1]
>>>             time: [   0..16260480]
>>> Number Of Attributes: 3
>>>   ts_mean : 1.196080271862835e-13
>>>   matrix : covariance
>>>   _FillValue : -999000000
>>>
>>> fatal:regCoef: The rightmost dimension of x must be equal to the
>>> rightmost dimension of y
>>> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 128 in
>>> file eof_cfsr.ncl
>>>
>>> Variable: eof_regres
>>> Type: double
>>> Total Size: 80000 bytes
>>>             10000 values
>>> Number of Dimensions: 3
>>> Dimensions and sizes: [evn | 1] x [lat | 100] x [lon | 100]
>>> Coordinates:
>>>             evn: [1..1]
>>>             lat: [-89.09999999999999..89.10000000000002]
>>>             lon: [   0..356.4]
>>> Number Of Attributes: 6
>>>   _FillValue : -999000000
>>>   method : transpose
>>>   matrix : covariance
>>>   pcvar : 13.29658
>>>   eval : 634047.31020702
>>>   eval_transpose : 24386.43500796231
>>> (0)
>>> (0) min=-0.04332826535433597   max=0.02833814180143831
>>>
>>>
>>> *Melanie O'Hanoly*
>>> *Oceangrapher*
>>> *PhD canditate at Alfred Wegener Institute Helmholtz Centre for Polar
>>> and Marine Research*
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>>
>> --
>> Adam Phillips
>> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
>> www.cgd.ucar.edu/staff/asphilli/   303-497-1726 <(303)%20497-1726>
>>
>> <http://www.cgd.ucar.edu/staff/asphilli>
>>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170901/918ae396/attachment.html>


More information about the ncl-talk mailing list