1 | ;+ |
---|
2 | ; |
---|
3 | ; ========================= |
---|
4 | ; cronin_gustiness_ncdf.pro |
---|
5 | ; ========================= |
---|
6 | ; |
---|
7 | ; .. function:: cronin_gustiness_ncdf(yyyymmddb,yyyymmdde) |
---|
8 | ; |
---|
9 | ; DESCRIPTION |
---|
10 | ; =========== |
---|
11 | ; |
---|
12 | ; Cronin gustiness correction on corrected sst on OAFLUX grid |
---|
13 | ; |
---|
14 | ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` have been produced by |
---|
15 | ; :func:`sst_correction_ncdf`. |
---|
16 | ; |
---|
17 | ; Cronin gustiness corrected ++ on corrected sst on OAFLUX grid |
---|
18 | ; is written in |
---|
19 | ; :file:`${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc` |
---|
20 | ; if this file not already exists. |
---|
21 | ; |
---|
22 | ; This file will be used by |
---|
23 | ; :func:`tropflux_swr_blnd` |
---|
24 | ; and |
---|
25 | ; :func:`tropflux`. |
---|
26 | ; |
---|
27 | ; .. graphviz:: |
---|
28 | ; |
---|
29 | ; digraph cronin_gustiness_ncdf { |
---|
30 | ; |
---|
31 | ; file_in [shape=ellipse, |
---|
32 | ; fontname=Courier, |
---|
33 | ; label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"]; |
---|
34 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc"]; |
---|
35 | ; |
---|
36 | ; cronin_gustiness_ncdf [shape=box, |
---|
37 | ; fontname=Courier, |
---|
38 | ; color=blue, |
---|
39 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/cronin_gustiness_ncdf.pro", |
---|
40 | ; label="${PROJECT}/src/cronin_gustiness_ncdf.pro"]; |
---|
41 | ; |
---|
42 | ; {file_in} -> {cronin_gustiness_ncdf} -> {file_out} |
---|
43 | ; } |
---|
44 | ; |
---|
45 | ; EXAMPLES |
---|
46 | ; ======== |
---|
47 | ; |
---|
48 | ; .. code-block:: idl |
---|
49 | ; |
---|
50 | ; yyyymmddb = 20000101L |
---|
51 | ; yyyymmdde = 20001231L |
---|
52 | ; result = cronin_gustiness_ncdf(yyyymmddb, yyyymmdde) |
---|
53 | ; print, result |
---|
54 | ; |
---|
55 | ; SEE ALSO |
---|
56 | ; ======== |
---|
57 | ; |
---|
58 | ; :ref:`project_profile.sh` |
---|
59 | ; |
---|
60 | ; :ref:`mooring_corrections` |
---|
61 | ; |
---|
62 | ; :func:`sst_correction_ncdf`. |
---|
63 | ; |
---|
64 | ; :func:`initncdf <saxo:initncdf>` |
---|
65 | ; :func:`julday <saxo:julday>` |
---|
66 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
67 | ; |
---|
68 | ; TODO |
---|
69 | ; ==== |
---|
70 | ; |
---|
71 | ; going on time parametrization |
---|
72 | ; |
---|
73 | ; coding rules |
---|
74 | ; |
---|
75 | ; why da1=19880101 and da2=20101231 ? should be 19890101 and 20091231 or better |
---|
76 | ; deduce from reading sst |
---|
77 | ; |
---|
78 | ; KNOWN ISSUES |
---|
79 | ; ============ |
---|
80 | ; |
---|
81 | ; test of existence of fullfilename_in not very efficient because |
---|
82 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
83 | ; |
---|
84 | ; EVOLUTIONS |
---|
85 | ; ========== |
---|
86 | ; |
---|
87 | ; $Id$ |
---|
88 | ; |
---|
89 | ; $URL$ |
---|
90 | ; |
---|
91 | ; - fplod 20120321 |
---|
92 | ; |
---|
93 | ; * pro -> func |
---|
94 | ; * taking project_overwrite into account |
---|
95 | ; |
---|
96 | ; - fplod 20110830T140029Z cratos (Linux) |
---|
97 | ; |
---|
98 | ; * replace tt by time |
---|
99 | ; |
---|
100 | ; - fplod 20110808T144208Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
101 | ; |
---|
102 | ; * usage of ${PROJECT_OD} |
---|
103 | ; * complete description |
---|
104 | ; * remove v50 in output filename |
---|
105 | ; * remove return statement |
---|
106 | ; |
---|
107 | ; - fplod 20101215T092619Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
108 | ; |
---|
109 | ; * add graph in header |
---|
110 | ; |
---|
111 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
112 | ; |
---|
113 | ; * minimal header |
---|
114 | ; |
---|
115 | ; - pbk 2008 |
---|
116 | ; |
---|
117 | ; * creation |
---|
118 | ; |
---|
119 | ;- |
---|
120 | function cronin_gustiness_ncdf $ |
---|
121 | , yyyymmddb $ |
---|
122 | , yyyymmdde |
---|
123 | ; |
---|
124 | ;++ compile_opt idl2, strictarrsubs, logical_predicate |
---|
125 | ; |
---|
126 | @cm_4cal |
---|
127 | @cm_4data |
---|
128 | @cm_4mesh |
---|
129 | @cm_4data |
---|
130 | @cm_project |
---|
131 | ; |
---|
132 | ; Return to caller if errors |
---|
133 | ON_ERROR, 2 |
---|
134 | ; |
---|
135 | result = -1 |
---|
136 | ; |
---|
137 | usage = 'result = tropflux_swr_nrt(yyyymmddb, yyyymmdde)' |
---|
138 | nparam = N_PARAMS() |
---|
139 | IF (nparam NE 2) THEN BEGIN |
---|
140 | ras = report(['Incorrect number of arguments.' $ |
---|
141 | + '!C' $ |
---|
142 | + 'Usage : ' + usage]) |
---|
143 | return, result |
---|
144 | ENDIF |
---|
145 | ; |
---|
146 | ; test if ${PROJECT_OD} defined |
---|
147 | CASE project_od_env OF |
---|
148 | '' : BEGIN |
---|
149 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
150 | ras = report(msg) |
---|
151 | return, result |
---|
152 | END |
---|
153 | ELSE : BEGIN |
---|
154 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
155 | ras = report(msg) |
---|
156 | END |
---|
157 | ENDCASE |
---|
158 | ; |
---|
159 | ; check if output data will be possible |
---|
160 | iodirout = isadirectory(project_od_env) |
---|
161 | ; |
---|
162 | ; existence and protection for reading |
---|
163 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
164 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
165 | ras = report(msg) |
---|
166 | return, result |
---|
167 | ENDIF |
---|
168 | ; |
---|
169 | ; existence and protection for writing |
---|
170 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
171 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
172 | ras = report(msg) |
---|
173 | return, result |
---|
174 | ENDIF |
---|
175 | ; |
---|
176 | da1=19880101 |
---|
177 | da2=20101231 |
---|
178 | ; |
---|
179 | ; build data filename |
---|
180 | filename='TropFlux_sst_19890101_20091231.nc' |
---|
181 | ; |
---|
182 | ; check if this file exists |
---|
183 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
184 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
185 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
186 | ras = report(msg) |
---|
187 | return, result |
---|
188 | ENDIF |
---|
189 | ; |
---|
190 | ; build output filename |
---|
191 | filename_out = 'TropFlux_gustiness' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' |
---|
192 | fullfilename_out = iodirout + filename_out |
---|
193 | ; in order to avoid unexpected overwritten |
---|
194 | IF ((FILE_TEST(fullfilename_out) EQ 1) AND (project_overwrite EQ 0)) THEN BEGIN |
---|
195 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
196 | ras = report(msg) |
---|
197 | return, result |
---|
198 | ENDIF |
---|
199 | ; |
---|
200 | initncdf, fullfilename |
---|
201 | sst=read_ncdf('sst',da1,da2,file=fullfilename,/nostr) |
---|
202 | sst=reform(sst-273.15) |
---|
203 | help, sst |
---|
204 | ; |
---|
205 | sst_clim=grossemoyenne(sst, 't',/nan) |
---|
206 | ;wg=0.175*sst_clim-3.17 ; line fit obtained from the scatter (Cronin gustiness Vs ERAI SST) |
---|
207 | ;help, wg |
---|
208 | ; |
---|
209 | jpt=n_elements(time) |
---|
210 | ; |
---|
211 | wg_tot=sst*0. |
---|
212 | for jt=0, jpt-1 do begin |
---|
213 | wg_tot(*,*,jt)=(((sst_clim(*,*)-23.7)*2.1/(29.8-23.7)) > 1.) <2.1 |
---|
214 | endfor |
---|
215 | help, wg_tot |
---|
216 | ; |
---|
217 | ; writing field |
---|
218 | time=timegen(7670, start=julday(1,1,1989,0), units='days') |
---|
219 | jpt=n_elements(time) |
---|
220 | ; |
---|
221 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
222 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
223 | time=time-julday(1,1,1950,00,00,00) |
---|
224 | xlon=reform(glamt(*,0) ) |
---|
225 | ylat=reform(gphit(0,*)) |
---|
226 | ; |
---|
227 | ncfile='!' + fullfilename_out |
---|
228 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
229 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
230 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
231 | gust_attr={units:'m/s',missing_value:valmask,long_name:'Climatological gustiness',short_name:'wg',axis:'TYX'} |
---|
232 | globattr={source:'Climatological wind gustiness obtained by fitting cronins gustiness values against sst ',timerange:cda0+' - '+cda1} |
---|
233 | ; |
---|
234 | ncfields = 'wg[longitude,latitude,time]=wg_tot:gust_attr; ' $ |
---|
235 | + 'longitude[]=xlon:lon_attr; ' $ |
---|
236 | + 'latitude[]=ylat:lat_attr; ' $ |
---|
237 | + 'time[*time]=time:time_attr ' $ |
---|
238 | + ' @ globattr' |
---|
239 | ; |
---|
240 | @ncdf_quickwrite |
---|
241 | ; |
---|
242 | result = 0 |
---|
243 | return, result |
---|
244 | ; |
---|
245 | end |
---|