source: trunk/src/ws_correction_ncdf.pro @ 85

Last change on this file since 85 was 85, checked in by pinsard, 13 years ago

restart consolidation of paper01 software

File size: 5.4 KB
Line 
1;+
2;
3; .. _ws_correction_ncdf.pro:
4;
5; ======================
6; ws_correction_ncdf.pro
7; ======================
8;
9; Correction of ws on OAFLUX grid
10;
11; :file:`${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc` have been
12; produced by :ref:`interp_erai_ws_1989_2009.pro`.
13;
14; Corrected ws on OAFLUX grid is written in
15; :file:`${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc`
16; if this file not already exists.
17;
18; This file will be used by :ref:`TropFlux_19890101_20091231.pro`.
19;
20;     .. graphviz::
21;
22;        digraph ws_correction_ncdf {
23;           graph [
24;           rankdir="LR",
25;           ]
26;
27;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc"];
28;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc"];
29;
30;           ws_correction_ncdf [shape=box,
31;           fontname=Courier,
32;           color=blue,
33;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/ws_correction_ncdf.pro",
34;           label="${PROJECT}/src/ws_correction_ncdf.pro"];
35;
36;           {file_in} -> {ws_correction_ncdf} -> {file_out}
37;
38;          }
39;
40; SEE ALSO
41; ========
42;
43; :ref:`project_profile.sh`
44;
45; :ref:`mooring_corrections`
46;
47; :ref:`interp_erai_vs_1989_2009.pro`
48;
49; :func:`initncdf <saxo:initncdf>`
50; :func:`read_ncdf <saxo:read_ncdf>`
51; :func:`grossemoyenne <saxo:grossemoyenne>`
52; :func:`julday <saxo:julday>`
53; :func:`caldat <saxo:caldat>`
54; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
55;
56; EXAMPLES
57; ========
58;
59; ::
60;
61;  IDL> ws_correction_ncdf
62;
63; TODO
64; ====
65;
66; coding rules
67;
68; hard coded correction
69;
70; KNOWN ISSUES
71; ============
72;
73; test of existence of fullfilename_in not very efficient because
74; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
75;
76; EVOLUTIONS
77; ==========
78;
79; $Id$
80;
81; $URL$
82;
83; - fplod 20110808T131954Z aedon.locean-ipsl.upmc.fr (Darwin)
84;
85;   * usage of ${PROJECT_OD}
86;   * complete description
87;   * remove v20 in output filename
88
89; - fplod 20101215T115916Z aedon.locean-ipsl.upmc.fr (Darwin)
90;
91;   * add graph in header
92;
93; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
94;
95;   * minimal header
96;
97; - pbk 2008
98;
99;   * creation
100;
101;-
102pro ws_correction_ncdf
103;
104@cm_4cal
105@cm_4data
106@cm_4mesh
107@cm_4data
108@cm_project
109;
110; test if ${PROJECT_OD} defined
111CASE project_od_env OF
112  '' : BEGIN
113         msg = 'eee : ${PROJECT_OD} is not defined'
114         ras = report(msg)
115       STOP
116       END
117  ELSE: BEGIN
118          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
119          ras = report(msg)
120        END
121 ENDCASE
122;
123; check if output data will be possible
124iodirout = isadirectory(project_od_env)
125;
126; existence and protection for reading
127IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
128   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
129   ras = report(msg)
130   STOP
131ENDIF
132;
133; existence and protection for writing
134IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
135    msg = 'eee : the directory' + iodirout  + ' was not found.'
136    ras = report(msg)
137    STOP
138ENDIF
139;
140da1=19880101 & da2=20101231
141;
142; build data filename
143filename='erai_ws_19890101_20091231_oafluxgrid.nc'
144;
145; check if this file exists
146fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST)
147IF fullfilename[0] EQ '' THEN BEGIN
148   msg = 'eee : the file ' + fullfilename + ' was not found.'
149   ras = report(msg)
150   STOP
151ENDIF
152;
153; build output filename
154filename_out = 'TropFlux_ws_19890101_20091231.nc'
155fullfilename_out = iodirout + filename_out
156; in order to avoid unexpected overwritten
157IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
158   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
159   ras = report(msg)
160   STOP
161ENDIF
162;
163initncdf, fullfilename
164u=read_ncdf('u10',da1,da2,file=fullfilename,/nostr)
165v=read_ncdf('v10',da1,da2,file=fullfilename,/nostr)
166w=sqrt(u*u+v*v)
167
168help, w
169
170w_mean=grossemoyenne(w,'t',/nan)
171help, w_mean
172
173tt=time & jpt=n_elements(time)
174caldat, time,mon,day,yea
175w_m=w*0.
176
177for jt=0,jpt-1 do begin
178  jtt=(time(jt)-julday(1,1,yea(jt))) < 364
179  q=reform(w_mean(*,*))
180  w_m(*,*,jt)=q
181endfor
182help, w_m
183
184w_ano=w-w_m
185
186;; correction for mean based on scatter
187;w_m=w_m+0.282667    ;; (2000-2008)
188w_m=w_m+0.276739     ;; (2000-2009)
189
190help, w_ano
191
192;; applying the correction for varyability based on the scatter
193;w_ano=w_ano*(1/0.897667)   ;; (2000-2008)
194w_ano=w_ano*(1/0.903587)    ;; (2000-2009)
195
196w_new=w_m+w_ano
197help, w_new
198
199;writing field
200lat=reform(gphit(0,0:jpj-1))
201lon=reform(glamt(0:jpi-1,0))
202time=timegen(7670, units='days', start=julday(1,1,1989,0)) & jpt=n_elements(time)
203
204cda0=string(jul2date(time(0)),format='(i8.8)')
205cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
206
207time=time-julday(1,1,1950) & jpt=n_elements(time)
208
209ncfile='!' + fullfilename_out
210lon_attr={units:'degrees_east',long_name:'Longitude'}
211lat_attr={units:'degrees_north',long_name:'Latitude'}
212time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
213w_attr={units:'m/s',missing_value:1.e20,long_name:'mean wind speed',short_name:'w',axis:'TYX'}
214globattr={source:'Basic data obtained from ERAI. Bias and variability correction are applied',timerange:cda0+' - '+cda1}
215
216ncfields = 'ws[longitude,latitude,time]=w_new:w_attr; ' $
217                      + 'longitude[]=lon:lon_attr; ' $
218                      + 'latitude[]=lat:lat_attr; ' $
219                      + 'time[*time]=time:time_attr ' $
220                      + ' @ globattr'
221
222@ncdf_quickwrite
223
224end
Note: See TracBrowser for help on using the repository browser.