1 | ;+ |
---|
2 | ; |
---|
3 | ; ============= |
---|
4 | ; dmean_mld.pro |
---|
5 | ; ============= |
---|
6 | ; |
---|
7 | ; .. function:: dmean_mld(data_prn) |
---|
8 | ; |
---|
9 | ; Compute daily mean and standart deviation of MLD from structure ++details |
---|
10 | ; |
---|
11 | ; :param data_prn: structure ++details |
---|
12 | ; :type data_prn: structure |
---|
13 | ; :raise data_prn: required |
---|
14 | ; |
---|
15 | ; :returns: data structure +todo+ details or -1 if error |
---|
16 | ; :rtype: structure +todo+ details |
---|
17 | ; |
---|
18 | ; :examples: |
---|
19 | ; |
---|
20 | ; Realistic example with POMME files:: |
---|
21 | ; |
---|
22 | ; IDL> data_prn=file_prn_to_mem() |
---|
23 | ; IDL> data_dmean=dmean_mld(data_prn) |
---|
24 | ; |
---|
25 | ; impression de controle :: |
---|
26 | ; |
---|
27 | ; IDL> help, data_dmean, /structure |
---|
28 | ; IDL> print, data_dmean[0] |
---|
29 | ; IDL> print, data_dmean.mean_zhom001 |
---|
30 | ; IDL> print, data_dmean.std_zhom001 |
---|
31 | ; |
---|
32 | ; :uses: |
---|
33 | ; |
---|
34 | ; :see also: |
---|
35 | ; |
---|
36 | ; :func:`file_prn_to_mem` |
---|
37 | ; :func:`join_mean_asc` |
---|
38 | ; |
---|
39 | ; :restrictions: |
---|
40 | ; |
---|
41 | ; :todo: |
---|
42 | ; |
---|
43 | ; test arguments |
---|
44 | ; |
---|
45 | ; missing values |
---|
46 | ; |
---|
47 | ; init returned structure to NaN vs 0L or 0.0 |
---|
48 | ; |
---|
49 | ; usage of report |
---|
50 | ; |
---|
51 | ; - fplod 20101129T092544Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
52 | ; |
---|
53 | ; * add 1st station in result structure |
---|
54 | ; |
---|
55 | ; - fplod 20101124T143429Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
56 | ; |
---|
57 | ; * creation |
---|
58 | ; |
---|
59 | ; :version: |
---|
60 | ; |
---|
61 | ; $Id$ |
---|
62 | ; |
---|
63 | ;- |
---|
64 | FUNCTION dmean_mld, data_prn |
---|
65 | ; |
---|
66 | compile_opt idl2, strictarrsubs |
---|
67 | ; |
---|
68 | ; Return to caller if errors |
---|
69 | ON_ERROR, 2 |
---|
70 | ; |
---|
71 | usage = 'result=dmean_mld(data_prn)' |
---|
72 | ; |
---|
73 | nparam = N_PARAMS() |
---|
74 | IF (nparam LT 1) THEN BEGIN |
---|
75 | ras = report(['Incorrect number of arguments.' $ |
---|
76 | + '!C' $ |
---|
77 | + 'Usage : ' + usage]) |
---|
78 | return, -1 |
---|
79 | ENDIF |
---|
80 | ; |
---|
81 | ; initialize returned structure |
---|
82 | resultstruct = { doy : 0L $ |
---|
83 | , first_station : 0L $ |
---|
84 | , mean_zhom001: 0.0 $ |
---|
85 | , mean_zhom002 : 0.0 $ |
---|
86 | , mean_zhom005 : 0.0 $ |
---|
87 | , mean_zhom010: 0.0 $ |
---|
88 | , mean_zhomelch : 0.0 $ |
---|
89 | , std_zhom001: 0.0 $ |
---|
90 | , std_zhom002 : 0.0 $ |
---|
91 | , std_zhom005 : 0.0 $ |
---|
92 | , std_zhom010: 0.0 $ |
---|
93 | , std_zhomelch : 0.0 $ |
---|
94 | } |
---|
95 | ; |
---|
96 | ; found days list |
---|
97 | multiple_days=ceil(data_prn.doy) |
---|
98 | days=multiple_days[UNIQ(multiple_days, SORT(multiple_days))] |
---|
99 | ndays=n_elements(days) |
---|
100 | ; |
---|
101 | ; initialize dimension of the returned structure |
---|
102 | result = replicate(resultstruct, ndays) |
---|
103 | result.doy=days |
---|
104 | ; |
---|
105 | ; loop on each day |
---|
106 | FOR iday=0L, ndays - 1 DO BEGIN |
---|
107 | ; find julian day in data_prn |
---|
108 | ;++print, result[iday].doy |
---|
109 | indice_prn = WHERE(ceil(data_prn.doy) EQ result[iday].doy,count) |
---|
110 | ;++print, count |
---|
111 | ;++print, 'indice du jour', result[iday].doy,' dans data_prn = ',indice_prn |
---|
112 | ; store the first (in numeric number - supposed to be chronological order) |
---|
113 | result[iday].first_station = data_prn[indice_prn[0]].station |
---|
114 | ; compute daily mean of MLDs |
---|
115 | result[iday].mean_zhom001 = total(data_prn[indice_prn].zhom001)/count |
---|
116 | result[iday].mean_zhom002 = total(data_prn[indice_prn].zhom002)/count |
---|
117 | result[iday].mean_zhom005 = total(data_prn[indice_prn].zhom005)/count |
---|
118 | result[iday].mean_zhom010 = total(data_prn[indice_prn].zhom010)/count |
---|
119 | result[iday].mean_zhomelch = total(data_prn[indice_prn].zhomelch)/count |
---|
120 | IF (count GT 1) THEN BEGIN |
---|
121 | ; compute standart deviation of MLDs |
---|
122 | result[iday].std_zhom001 = stddev(data_prn[indice_prn].zhom001) |
---|
123 | result[iday].std_zhom002 = stddev(data_prn[indice_prn].zhom002) |
---|
124 | result[iday].std_zhom005 = stddev(data_prn[indice_prn].zhom005) |
---|
125 | result[iday].std_zhom010 = stddev(data_prn[indice_prn].zhom010) |
---|
126 | result[iday].std_zhomelch = stddev(data_prn[indice_prn].zhomelch) |
---|
127 | ENDIF ELSE BEGIN |
---|
128 | result[iday].std_zhom001 = 0.0 |
---|
129 | result[iday].std_zhom002 = 0.0 |
---|
130 | result[iday].std_zhom005 = 0.0 |
---|
131 | result[iday].std_zhom010 = 0.0 |
---|
132 | result[iday].std_zhomelch = 0.0 |
---|
133 | ENDELSE |
---|
134 | ;++print, 'mean mld 1', result[iday].mean_zhom001 |
---|
135 | ENDFOR |
---|
136 | ; |
---|
137 | return, result |
---|
138 | ; |
---|
139 | END |
---|