Do loops overwriting inner loops

From: Cannavina, Dominique <d.cannavina11_at_nyahnyahspammersnyahnyah>
Date: Sat Jun 30 2012 - 07:41:42 MDT

Hi NCL Talk

I am extracting data from ECMWF (DEMETER files) and using dim_numrun_n function to look at consecutive days below 0degC, but when I look at the output (see attached pdf file) the number look are lower then expected and also not the 'whole number figures' that should be produced as at this stage it should only be counting the number of occurance of 'a run of cold temperature'. Therefore I think my DO LOOPs are overwritting each other, the whole script is attached but an example of 'a main loop' is given below.

A quick overview of the data format is given below (and a file with the output of the PrintVarSummary from the script is attached)

I have used 'join' to attach files together

Each file has 3 models

Each model has 9 ensembles

each ensemble has an output for the minute daily temperature at 2 m for gridpoints covering a domain over europe

after I have downloaded and 'joined' files I then have 3 main loops (one for each model) and at the end of the main loop I have after I have used dim_numrun_n I used CopyVarCoords to retain the data which is then added together after the 3 main loops have run.

Each main loop runs through an ensemble and within the ensemble there is another innerloop for the time (each daily temperature).

I then use dim_numrun_n while still in the loop to count the total number of runs and unique runs and then CopyVarCoord as mentioned above.

So in summary;

1. how can I stop my loops overwritting each other?

2. am I using the dim_numrun_n correctly as it is giving me decimal output on my plot scale and I would of anticipated whole numbers.

3. is there any way of splitting the output of "unique runs" so I can get the total number of 1 day cold spells, 5 day cold spells, 20 days cold spells, again at each grid point?

Any advice is greatly appreciated.

Kind regards

Dominique.

One of main loops is given below;

; What times and how many time steps are in the data set?

ntimes = dimsizes(times) ; number of times in the file

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;First look at data from model ukmo

do iensemble = 0,8,1 ; ENSEMBLE LOOP MODELS 0,1...7,8

do itime = 24,4320,24 ; TIME LOOP DAYS 1,2....178,180 FOR EACH RUN THIS IS CHANGED TO UNITS IN FILE IE INTO HOURS 24,4320,24

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; First get the variables we will need

t2_uk = ukmo ; T2 in Kelvin

tc2_uk = t2_uk-273.16 ; T2 in C

;Counts the number of consecutive days that the temperature falls to or below the stipulated temperature.

; specify cut off temperature 'tcrit'

;I am trying to tally the number of cold spells per set of data (i.e. for each ensemble for each model for each year/start of ensemble run) but I need to be able to count how many 1,2,3....35 day duration events occur

tcrit = 0

;create 0/1 array

cold_uk = where(tc2_uk.le.tcrit, 1, 0) ;create 0/1 array

cold_uk0 = dim_numrun_n(cold_uk, 0, 0) ; opt = 0 means total

cold_uk1 = dim_numrun_n(cold_uk, 1, 0) ; opt = 1 means unique

;optional ... add meta data

cold_uk0@long_name ="total cold runs"

cold_uk0@cold_crit_value = tcrit

copy_VarCoords(tc2_uk, cold_uk0)

cold_uk1@long_name ="unique cold runs"

cold_uk1@cold_crit_values = tcrit

copy_VarCoords(tc2_uk, cold_uk1)

 

end do ;end of time loop

end do ;end of ensemble loop

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

Received on Sat Jun 30 07:44:07 2012

This archive was generated by hypermail 2.1.8 : Tue Jul 03 2012 - 15:40:40 MDT