Re: Problems combining dim_num_n and dim_numrun_n to number of runs of a given length

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 02 2012 - 16:08:52 MDT

Hi Dominique,
I think the issue has to do with how you are using dim_num_n, and that
may be related to the fact that I t hink example #4 on the dim_num_n has
an incorrect comment.

Example #4 should say this:

  N =*dim_num_n*(z,(/2,3/)) ; N(ntime,klev)

In other words, the dimensions that you specify in dim_num_n will be
eliminated from the returned array. I will get the website fixed..

You say this:
tc2_tally0 = dim_num_n (uk_cold0, (/3,4/))
That statement though will eliminate your latitude and longitude arrays.
I think you might want to say:
tc2_tally0 = dim_num_n (uk_cold0, (/0,1,2/))
Note though that the above statement will eliminate your first three
dimensions from uk_cold0, and I am not sure if you want to sum up across
all of the first 3 dimensions of uk_cold0 and uk_cold1.

I would advise that you check the output from dim_num_n to make sure it
is doing what you think it is doing.

If that answer does not help, please let ncl-talk know.. Adam

I

On 7/1/12 12:03 PM, Cannavina, Dominique wrote:
>
> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 2 16:08:49 2012

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