source: trunk/procs/macros/make_stddev.pro @ 86

Last change on this file since 86 was 86, checked in by kolasinski, 16 years ago

Merged procs-read branch changes r80:85 into teh trunk

File size: 2.5 KB
Line 
1;
2; make std dev from 2D macro_base_fld monthly time serie (defined in macro_read)
3;
4FUNCTION make_stddev, file_name, ncdf_db,  BOXZOOM = boxzoom, TIME_1 = time_1,  TIME_2 =  time_2, ALL_DATA = all_data, ZMTYP = zmtyp
5
6@common
7@com_eg
8;
9;
10; Read time serie
11;
12   IF debug_w THEN print, 'keyword_set(ALL_DATA) : ', keyword_set(ALL_DATA)
13
14   mfld = nc_read(file_name, macro_base_fld, ncdf_db, BOXZOOM = boxzoom, TIME_1 = time_1,  TIME_2 =  time_2, ALL_DATA = all_data)
15   mfld.data = trends(mfld.data, '412', 'xyt')
16
17   print, '    Warning: standard deviation assuming monthly time serie of base field ',macro_base_fld
18
19; Modif MK
20
21   IF stddev_mth NE '00' THEN BEGIN
22
23      mth = ['Jan',  'Feb',  'Mar',  'Apr',  'May',  'Jun',  'Jul',  'Aug', 'Sep',  'Oct', 'Nov',  'Dec']
24      CASE STRMID(stddev_mth, 0, 2) OF
25         '01': strd = 1
26         '02': strd = 2
27         '03': strd = 3
28         '04': strd = 4
29         '05': strd = 5
30         '06': strd = 6
31         '07': strd = 7
32         '08': strd = 8
33         '09': strd = 9
34         '10': strd = 10
35         '11': strd = 11
36         '12': strd = 12
37         ENDCASE
38
39     print,  '    Warning: standard deviation computed for ', mth[strd-1]
40
41; Sampling of data and computation of new numbers of values
42      data =  (mfld.data)[*, *, strd-1:*:12]       
43      nval =  (size(data))[3]
44   ENDIF ELSE BEGIN
45      data =  mfld.data
46      nval =  jpt
47   ENDELSE
48
49   std = a_timecorrelate(data, 0,/covariance)
50   std = sqrt( nval/(nval-1)*std )
51   idx =  WHERE (std GT 1.0e+10)
52
53   IF idx(0) NE -1 THEN std(idx) = valmask
54
55   IF stddev_mth NE '00' AND stddev_diff EQ 1 THEN BEGIN
56      print,  ' Warning: standard deviation diff between ', mth[strd-1],  ' and the whole serie'
57      std_tot = a_timecorrelate(mfld.data, 0,/covariance)
58      std_tot = sqrt( jpt/(jpt-1)*std_tot )
59      IF idx(0) NE -1 THEN std_tot(idx) = valmask
60      idx_diff =  WHERE (std NE valmask)
61      std(idx_diff) =  std(idx_diff) - std_tot(idx_diff)
62   ENDIF
63
64   field = {name: '', data: std, legend: '', units: '', origin: '', dim: 0, direc:''}
65   
66   field.origin = mfld.origin
67   
68   field.dim = 2
69   
70   IF stddev_mth NE '00' THEN BEGIN
71      field.legend = ' for '+mth[strd-1]+' in ['+cmdm.date1+'-'+cmdm.spec+'] -'
72      IF stddev_diff EQ 1 THEN BEGIN
73         field.legend = ' diff between '+mth[strd-1]+' and total TS ['+cmdm.date1+' - '+cmdm.spec+'] -'       
74      ENDIF
75   ENDIF ELSE BEGIN
76      field.legend = ' ['+cmdm.date1+'-'+cmdm.spec+']'
77   ENDELSE
78
79; Fin Modif MK
80
81;  data and plot are 2D
82
83   field.direc = 'xy'
84
85   return, field
86END
Note: See TracBrowser for help on using the repository browser.