Re: FW: Dimension mismatch on latitude variable ERA data extraction

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 25 2012 - 14:07:44 MDT

As indicated by Adam, I do not think you need to
execute the dim_avg_n in the 'current' case.

The original 4D case

Variable: cold_cn1
Number of Dimensions: 4
Dimensions and sizes: [run_length | 720] x [number | 9] x [latitude |
18] x [longitude | 30]

The purpose of

   spell_tot_cn(nr,:,:) = dim_sum_n(cold_cn1({spell(nr)},:,:,:),0)

was to average over the 9 ensembles. Further, NCL sees

cold_cn1({spell(nr)},:,:,:) as a 3D array with 'number'
being all the ensemble members.

==
In your new case, there is no ensemble. Hence, why are
you using an averaging operator?

Just

   spell_tot_cn(nr,:,:) = cold_cn1({spell(nr)},:,:)

On 9/25/12 1:56 PM, Adam Phillips wrote:
> Hi Dominique,
> If I understand things correctly, you are saying this:
>
> do nr=0,nspell-1
> spell_tot_cn(nr,:,:) = dim_sum_n(cold_cn1({spell(nr)},:,:,:),0)
> end do
>
> worked. That makes sense. As Dennis stated before,
> cold_cn1({spell(nr)},:,:,:) will be seen internally by NCL as a 3D (NOT
> a 4D) array. You are dim_summing over the 0th dimension in a 3D array,
> resulting in a 2D array that you are able to put in
> spell_tot_cn(nr,:,:). Thus, for each run_length index, you are
> dim_summing over all ensemble members for each particular latitude and
> longitude.
>
> To see what I mean add this line in:
> printVarSummary(cold_cn1({spell(nr)},:,:,:)) within the do loop. Note
> that it will show up as a 3D array.
>
> You are also saying that this coding doesn't work and returns a
> dimension size mismatch:
>
> do nr=0,nspell-1
> spell_tot_unique_mn(nr,:,:) = dim_sum_n(cold_mn1({spell(nr)},:,:),0)
> end do
>
> That makes sense to me as well, as cold_mn1({spell(nr)},:,:) will be
> seen internally by NCL as a 2D array; you are dim_summing over the 0th
> dimension of a 2D array, and the resulting array will be 1D, which will
> not fit in spell_tot_unique_mn(nr,:,:). (Again, try putting this in the
> do loop: printVarSummary(cold_mn1({spell(nr)},:,:)) )
>
> I'm not sure what you're trying to accomplish with this last call, so
> I'm not sure what to suggest as a fix.
>
> Hopefully my explanation above makes sense.. If you still have
> questions, please let ncl-talk know.. Adam
>
>
>
>
> On 09/25/2012 12:41 PM, Cannavina, Dominique wrote:
>> Hi Dennis
>>
>> I think I confused matters in my last reply as I didn't include the information on the cold_cn1 variable.
>>
>> The first script which seemed to run okay had the variables cold_cn1 and spell_tot_cn
>>
>> cold_cn1 has 4 variables (rmax, ens, lat, lon) a summary of the variable is below
>>
>> Variable: cold_cn1
>> Type: integer
>> Total Size: 13996800 bytes
>> 3499200 values
>> Number of Dimensions: 4
>> Dimensions and sizes: [run_length | 720] x [number | 9] x [latitude | 18] x [longitude | 30]
>> Coordinates:
>> run_length: [1..720]
>> number: [0..8]
>> latitude: [75..32.5]
>> longitude: [-27.5..45]
>> Number Of Attributes: 2
>> cold_crit_values : 0
>> long_name : unique cold runs
>> (0) 100
>>
>> and the variable was set up in the script using the following;
>> dimcold = dimsizes(cold_cn1)
>> nrmax = dimcold(0) ; same as "run_length"
>> nens = dimcold(1)
>> nlat = dimcold(2)
>> mlon = dimcold(3)
>>
>> spell_tot_cn has 3 variables (spell, lat, lon)
>>
>> a summary of the variable is;
>> Variable: spell_tot_cn
>> Type: float
>> Total Size: 216000 bytes
>> 54000 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [spell | 100] x [latitude | 18] x [longitude | 30]
>> Coordinates:
>> spell: [1..100]
>> latitude: [75..32.5]
>> longitude: [-27.5..45]
>> Number Of Attributes: 2
>> spell : 1
>> _FillValue : 9.96921e+36
>> (0) 100
>> (0)
>> (0) min=0 max=105
>>
>> and the variable was set up in the script using the following;
>> spell_tot_cn = new( (/nspell,nlat,mlon/), "float") ; preallocate
>> dimspell = dimsizes(spell_tot_cn)
>> nspell = dimspell(0) ; same as "run_length"
>> nlat = dimspell(1)
>> mlon = dimspell(2)
>>
>> So when it ran through a similar do loop as the one which work in my last script, it was set up using;
>>
>> do nr=0,nspell-1
>> spell_tot_cn(nr,:,:) = dim_sum_n(cold_cn1({spell(nr)},:,:,:),0)
>> end do
>> spell_tot_cn!0 = "spell"
>> spell_tot_cn&spell = spell
>> copy_VarCoords(cold_cn1(0,0,:,:), spell_tot_cn(0,:,:)) ; trick for coords
>> printVarSummary(spell_tot_cn)
>> print(dimsizes(spell))
>> printMinMax(spell_tot_cn,True)
>>
>> which didn't give any errors for dimension mismatch in my new script
>>
>> cold_mn1 is now 3 dimensions (rmax, lat, lon)
>>
>> Variable: cold_mn1
>> Type: integer
>> Total Size: 67145680 bytes
>> 16786420 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [run_length | 12235] x [lat | 28] x [lon | 49]
>> Coordinates:
>> run_length: [1..12235]
>> lat: [73.5..33]
>> lon: [-27..45]
>> Number Of Attributes: 2
>> cold_crit_values : 0
>> long_name : unique cold runs
>>
>> and was set up using;
>> dimcold1 = dimsizes(cold_mn1)
>> nrmax = dimcold1(0) ; same as "run_length"
>> nlat = dimcold1(1)
>> mlon = dimcold1(2)
>>
>>
>> spell_tot_unique_mn is still 3 dimensions (spell, lat, lon)
>>
>> Variable: spell_tot_unique_mn
>> Type: float
>> Total Size: 548800 bytes
>> 137200 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [spell | 100] x [lat | 28] x [lon | 49]
>> Coordinates:
>> spell: [1..100]
>> lat: [73.5..33]
>> lon: [-27..45]
>> Number Of Attributes: 2
>> spell : 1
>> _FillValue : 9.96921e+36
>> (0) 100
>> (0)
>> (0) min=9.96921e+36 max=9.96921e+36
>>
>> and was set up using;
>> spell_tot_unique_mn = new( (/nspell,nlat,mlon/), "float") ; preallocate
>> dimspell = dimsizes(spell_tot_unique_mn)
>> nspell = dimspell(0) ; same as "run_length"
>> nlat = dimspell(1)
>> mlon = dimspell(2)
>>
>> so I modified the do loop to the following -removing an ':' after the {spell(nr)} and removed a '0' in the line with copy_VarCoords(cold_mn1(0............ to give
>>
>> do nr=0,nspell-1
>> spell_tot_unique_mn(nr,:,:) = dim_sum_n(cold_mn1({spell(nr)},:,:),0)
>> end do
>>
>> copy_VarCoords(cold_mn1(0,:,:), spell_tot_unique_mn(0,:,:)) ; trick for coords
>> printVarSummary(spell_tot_unique_mn)
>> print(dimsizes(spell))
>> printMinMax(spell_tot_unique_mn,True)
>>
>> which gave me a dimension mismatch?
>>
>> I have also attached the complete (faulty) script with the new variables and more detail on the other variables in the script.
>>
>>
>> Kind regards
>>
>> Dominique
>> ______________
>> __________________________
>> From: Dennis Shea [shea@ucar.edu]
>> Sent: 24 September 2012 00:56
>> To: Cannavina, Dominique
>> Cc:ncl-talk@ucar.edu
>> Subject: Re: [ncl-talk] Dimension mismatch on latitude variable ERA data extraction
>>
>> spell_tot_unique_mn(nr,:,:) = dim_sum_n(cold_mn1({spell(nr)},:,:),0)
>>
>> NCL temporarily 'sees'
>>
>> spell_tot_unique_mn(nr,:,:) as 2-dimensional
>> cold_mn1({spell(nr)},:,:) as 2-dimensional
>>
>> But after dim_sum_n operates on a 2D array, it will be one-dimensional.
>>
>> SO ...
>>
>> (:,:) = (:) results in exactly the error message
>>
>> > fatal:Dimension size mismatch on subscript #1, left-hand and right-hand
>> > side dimensions do not match
>>
>>
>>
>>
>>
>> On 9/23/12 9:39 AM, Cannavina, Dominique wrote:
>>> Hi NCL-Talk
>>>
>>> I am extracting data from an ERA data set and I get the following error
>>> messaage;
>>>
>>> fatal:Dimension size mismatch on subscript #1, left-hand and right-hand
>>> side dimensions do not match
>>>
>>> fatal:["Execute.c":7556]:Execute: Error occurred at or near line 185 in
>>> file /ECMWF_INTERIM/era_interim_spell_tot_0000hrs_run.ncl
>>>
>>> The line it is refering to is;
>>>
>>> spell_tot_unique_mn(nr,:,:) = dim_sum_n(cold_mn1({spell(nr)},:,:),0)
>>>
>>> which is part of a do loop-see below (full script is attached)
>>>
>>> do nr=0,nspell-1
>>>
>>> spell_tot_unique_mn(nr,:,:) = dim_sum_n(cold_mn1({spell(nr)},:,:),0)
>>>
>>> end do
>>>
>>> I attached units and names to each part of both of the variables and for
>>> the dimension#1 i.e. the latitude they appear to be the same, so I am
>>> not sure what I am doing wrong in the script. The two variables are
>>> listed below (a summary of all the variables is also attached)
>>>
>>> Any help on what I am doind wrong would be much appreciated.
>>>
>>> Variable: cold_mn1
>>>
>>> Type: integer
>>>
>>> Total Size: 67145680 bytes
>>>
>>> 16786420 values
>>>
>>> Number of Dimensions: 3
>>>
>>> Dimensions and sizes: [run_length | 12235] x [lat | 28] x [lon | 49]
>>>
>>> Coordinates:
>>>
>>> run_length: [1..12235]
>>>
>>> lat: [73.5..33]
>>>
>>> lon: [-27..45]
>>>
>>> Number Of Attributes: 2
>>>
>>> cold_crit_values : 0
>>>
>>> long_name : unique cold runs
>>>
>>>  
>>>
>>> Variable: spell_tot_unique_mn
>>>
>>> Type: float
>>>
>>> Total Size: 548800 bytes
>>>
>>> 137200 values
>>>
>>> Number of Dimensions: 3
>>>
>>> Dimensions and sizes: [spell | 100] x [lat | 28] x [lon | 49]
>>>
>>> Coordinates:
>>>
>>> spell: [1..100]
>>>
>>> lat: [73.5..33]
>>>
>>> lon: [-27..45]
>>>
>>> Number Of Attributes: 2
>>>
>>> spell : 1
>>>
>>> _FillValue : 9.96921e+36
>>>
>>> (0) 100
>>>
>>> (0)
>>>
>>> (0) min=9.96921e+36 max=9.96921e+36
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> =
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> ______________________________________________________________
> Adam Phillipsasphilli@ucar.edu
> NCAR/Climate and Global Dynamics Division (303) 497-1726
> P.O. Box 3000
> Boulder, CO 80307-3000http://www.cgd.ucar.edu/cas/asphilli
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 25 14:08:05 2012

This archive was generated by hypermail 2.1.8 : Wed Sep 26 2012 - 13:56:03 MDT