Re: Dimension mismatch on latitude variable ERA data extraction

From: Cannavina, Dominique <d.cannavina11_at_nyahnyahspammersnyahnyah>
Date: Mon Sep 24 2012 - 12:22:38 MDT

Hi Dennis

Thank you for explaining why cold_mn1({spell(nr)},:,:) reverts to being 1D, but I have to confess I am still unsure how to get both sides to balance in terms of dimensions.

So I tried changing it to
spell_tot_unique_mn(nr,:,:) = dim_sum_n(cold_mn1({spell(nr)},:,:,:),0) ; extra dimension after ({spell(nr)}

spell_tot_unique_mn(nr,:,:) = dim_sum_n(cold_mn1(:,{spell(nr)},:,:),0) ; extra dimension before({spell(nr)}

but it both give similiar error message saying only 3 dimensions expected and 4 given which makes sense as being wrong

so I went back to a previous script which seemed to run okay but there cold_cn1 had more dimensions (4 rather then the 3 it has in the new script)
and I can't see why that one 'balanced' both sides and this script doesn't balance?

So I am a bit stuck as to where to go next? I know I'm missing something but not sure which bit?

 dimcold = dimsizes(cold_cn1)
  nrmax = dimcold(0) ; same as "run_length"
  nens = dimcold(1)
  nlat = dimcold(2)
  mlon = dimcold(3)

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

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 Mon Sep 24 12:23:24 2012

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