source: trunk/src/ws_correction_ncdf.pro @ 152

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

start to homogenize (to be cont.)

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