FW: Dimension mismatch on latitude variable ERA data extraction

From: Cannavina, Dominique <d.cannavina11_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 25 2012 - 12:41:15 MDT

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: 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

Received on Tue Sep 25 12:41:34 2012

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