Problems extracting run from dim_numrun using dim_sum

From: Cannavina, Dominique <d.cannavina11_at_nyahnyahspammersnyahnyah>
Date: Sat Sep 29 2012 - 11:55:02 MDT

Hi NCL Talk

I have extracted a daily minimum temperature (t2_mn) for consecutive years from a data set over a specified area (lat, lon).

dim_numrun_n was used to find the number of cold spells (i.e. number of consecutive cold spells of 1 day, 2 days....20 days etc

tcrit = 0 ; specify cut off temperature 'tcrit'

cold_mn = where(t2_mn.le.tcrit, 1, 0) ;create 0/1 array

cold_mn1 = dim_numrun_n(cold_mn, 1, 0) ; opt = 0 means total (time,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

Then dim_sum_n was used to extract the number of 1 day, 2 day spells at each lat,lon

This is the bit I am having problems with

I initially had the following line in the do loop below, but the subscripting is unbalanced so it rightly won't work

spell_tot_unique_mn(nr,:,:) = dim_sum_n(cold_mn1({spell(nr)},:,:),0)

.

.

.

So I removed the subscripting which gave me the following do loop, which although it didn't return any erro, when I went to plot the data, it returns the same set of values for each spell duration or 'nr'

; Set range for spell

n1 = 1

n2 = 100 ; ispan to specify all spells

spell = ispan(n1,n2,1) ; eg n1=1, n2=20

nspell = dimsizes(spell)

; Select out 'unique runs'

do nr=0,nspell-1

spell_tot_unique_mn(nr,:,:) = dim_sum_n(cold_mn1,0)

end do

spell_tot_unique_mn!0 = "spell"

spell_tot_unique_mn&spell = spell

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)

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=0 max=976

So I think although the dim_sum_n is summing run length from coldmn1, it is not differentiating between a 1 day run, 2 day run etc?

The full script and all the associated variables are attached in two file.

How can I get the dim_sum_n to sum the 'correct' spell lengths?

Any help much appreciated.

Kind regards

Dominique

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Sat Sep 29 11:55:18 2012

This archive was generated by hypermail 2.1.8 : Mon Oct 08 2012 - 15:54:16 MDT