Hi NCL talk
I am trying to use dim_num_n to sum up the number of runs of data (in this case temp below tcrit =0degC) which have been produced from dim_numrun_n. My data extends over europe so I need to extract data at all grid points. The data files have 3 models, each model with 9 ensemble runs, and each ensemble run with 180 days of min temperature. I am just looking at 1 model at the moment.
I am trying to use the dim_num_n to count the number of each 'duration of run' which has been produced by dim_numrun_n
When I try and use a do loop and dim_num_n the function cuts off the lat and lon parts of the variable so I end up with [num file | ensemble | step ] which then causes me problems when I try and plot the data later on.
An exerpt of the main section is given below-but the full script and a sample of the variables is also attached.
Any advice would be much appreciated.
Kind regards
Dominique
; 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
; 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
;ukmo(ncl_join,step,number,latitude,longitude) => ukmo(0,1,2,3,4)
tStrt = 0
tLast = 179
tSkip = 1
; temporary variable
tc2 = tc2_uk(:,tStrt:tLast:tSkip,:,:,:) ; convenience/clarity
printVarSummary(tc2) ; does this look right?
;tc2 [ncl_join | 2] x [step | 180] x [number | 9] x [latitude | 18] x [longitude | 30]
;make sure dimensions of array fit with expected dimensions given above by specifying the following
dimt2 = dimsizes(tc2)
nfils = dimt2(0)
ntim = dimt2(1)
nens = dimt2(2)
nlat = dimt2(3)
mlon = dimt2(4)
tcrit = 0
uk_cold = where(tc2.le.tcrit, 1, 0) ; 0/1 array
printVarSummary(uk_cold)
uk_cold0 = dim_numrun_n(uk_cold, 0, 0) ; opt = 0 means total
uk_cold1 = dim_numrun_n(uk_cold, 1, 0) ; opt = 1 means unique
uk_cold0@long_name = "total cold runs"
uk_cold0@cold_crit_value = tcrit
copy_VarCoords(tc2, uk_cold0)
uk_cold1@long_name = "unique cold runs"
uk_cold1@cold_crit_value = tcrit
copy_VarCoords(tc2, uk_cold1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Second and third models to be added later
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;I now want to produce plots showning the average number of times in a given period there has been a 1 day duration cold event.... max day duration cold event
;so if the max duration of the cold event is 20 days, I will have 20 plots. I have 3 models each with 9 ensembles so for this period tally/(3*9)
; Not been able to produce this yet so try and get following two outputs
pltres = True
;pltres@PanelPlot = True
plots = new (60, graphic)
nuk_cold = dimsizes(uk_cold)
do n=0,nuk_cold(0)-1
tc2_tally0 = dim_num_n (uk_cold0, (/3,4/))
tc2_tally1 = dim_num_n (uk_cold1, (/3,4/))
-
-
-script defining boundaries lat/lon etc
-
-
plots(n) = gsn_csm_contour_map(wks,tc2_tally0(n,0,0,:,:),res0)
plots(n) = gsn_csm_contour_map(wks,tc2_tally1(n,0,0,:,:),res1)
end do
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2.1.8 : Tue Jul 03 2012 - 15:40:39 MDT