source: trunk/src/q2m_correction_ncdf.pro @ 79

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

complete documentation

File size: 5.2 KB
Line 
1;+
2;
3; .. _q2m_correction_ncdf.pro:
4;
5; =======================
6; q2m_correction_ncdf.pro
7; =======================
8;
9; Correction of q2m on OAFLUX grid
10;
11; :file:`${PROJECT_OD}/erai_q2m_19890101_20091231_oafluxgrid.nc` have been
12; produced by :ref:`d2m_to_q2m.pro`.
13;
14; Corrected q2m on OAFLUX grid is written in
15; :file:`${PROJECT_OD}/TropFlux_q2m_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 q2m_correction_ncdf {
23;           graph [
24;           rankdir="LR",
25;           ]
26;
27;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_q2m_19890101_20091231_oafluxgrid.nc"];
28;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc"];
29;
30;           q2m_correction_ncdf [shape=box,
31;           fontname=Courier,
32;           color=blue,
33;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/q2m_correction_ncdf.pro",
34;           label="${PROJECT}/src/q2m_correction_ncdf.pro"];
35;
36;           {file_in} -> {q2m_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:`d2m_to_q2m_erai.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:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
54;
55; EXAMPLES
56; ========
57;
58; ::
59;
60;  IDL> q2m_correction_ncdf
61;
62; TODO
63; ====
64;
65; can be tested because d2m_to_q2m.pro pb
66;
67; coding rules
68;
69; EVOLUTIONS
70; ==========
71;
72; - fplod 20110808T143129Z aedon.locean-ipsl.upmc.fr (Darwin)
73;
74;   * usage of ${PROJECT_OD}
75;   * remove v20 in output filename
76;
77; - fplod 20101215T113945Z aedon.locean-ipsl.upmc.fr (Darwin)
78;
79;   * add graph in header
80;
81; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
82;
83;   * minimal header
84;
85; - pbk 2008
86;
87;   * creation
88;
89;-
90pro q2m_correction_ncdf
91;
92@cm_4cal
93@cm_4data
94@cm_4mesh
95@cm_4data
96@cm_project
97;
98;
99; test if ${PROJECT_OD} defined
100CASE project_od_env OF
101  '' : BEGIN
102         msg = 'eee : ${PROJECT_OD} is not defined'
103         ras = report(msg)
104       STOP
105       END
106  ELSE: BEGIN
107          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
108          ras = report(msg)
109        END
110 ENDCASE
111;
112; check if output data will be possible
113iodirout = isadirectory(project_od_env)
114;
115; existence and protection for reading
116IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
117   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
118   ras = report(msg)
119   STOP
120ENDIF
121;
122; existence and protection for writing
123IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
124    msg = 'eee : the directory' + iodirout  + ' was not found.'
125    ras = report(msg)
126    STOP
127ENDIF
128;
129da1=19880101 & da2=20101231
130;
131; build data filename
132filename='erai_q2m_19890101_20091231_oafluxgrid.nc'
133;
134; check if this file exists
135fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST)
136IF fullfilename[0] EQ '' THEN BEGIN
137   msg = 'eee : the file ' + fullfilename + ' was not found.'
138   ras = report(msg)
139   STOP
140ENDIF
141;
142; build output filename
143filename_out = 'TropFlux_q2m_19890101_20091231.nc'
144fullfilename_out = iodirout + filename_out
145; in order to avoid unexpected overwritten
146IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
147   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
148   ras = report(msg)
149   STOP
150ENDIF
151;
152initncdf, fullfilename
153q2m=read_ncdf('q2m',da1,da2,file=fullfilename,/nostr)
154help, q2m
155
156q2m_mean=grossemoyenne(q2m,'t',/nan)
157help, q2m_mean
158
159tt=time & jpt=n_elements(time)
160caldat, time,mon,day,yea
161q2m_m=q2m*0.
162
163for jt=0,jpt-1 do begin
164  jtt=(time(jt)-julday(1,1,yea(jt))) < 364
165  q=reform(q2m_mean(*,*))
166  q2m_m(*,*,jt)=q
167endfor
168help, q2m_m
169
170q2m_ano=q2m-q2m_m
171
172;; correction for mean based on scatter
173;q2m_m=q2m_m+0.815445  ;;  (2000-2008)
174q2m_m=q2m_m+0.792717   ;;  (2000-2009)
175help, q2m_ano
176
177;; applying the correction for variability based on the scatter
178;q2m_ano=q2m_ano*(1/0.919333)  ;;  (2000-2008)
179q2m_ano=q2m_ano*(1/0.924674)   ;;  (2000-2009)
180
181q2m_new=q2m_m+q2m_ano
182help, q2m_new
183
184;writing field
185lat=reform(gphit(0,0:jpj-1))
186lon=reform(glamt(0:jpi-1,0))
187time=timegen(7670, units='days', start=julday(1,1,1989,0)) & jpt=n_elements(time)
188
189cda0=string(jul2date(time(0)),format='(i8.8)')
190cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
191
192time=time-julday(1,1,1950) & jpt=n_elements(time)
193
194ncfile='!' + fullfilename_out
195lon_attr={units:'degrees_east',long_name:'Longitude'}
196lat_attr={units:'degrees_north',long_name:'Latitude'}
197time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
198q2m_attr={units:'g/kg',missing_value:1.e20,long_name:'Specific humidity at 2m height',short_name:'q2m',axis:'TYX'}
199globattr={source:'Basic data obtained from ERAI.  Mean correction for bias and correction for variability are applied',timerange:cda0+' - '+cda1}
200
201ncfields = 'q2m[longitude,latitude,time]=q2m_new:q2m_attr; ' $
202                      + 'longitude[]=lon:lon_attr; ' $
203                      + 'latitude[]=lat:lat_attr; ' $
204                      + 'time[*time]=time:time_attr ' $
205                      + ' @ globattr'
206
207@ncdf_quickwrite
208
209end
Note: See TracBrowser for help on using the repository browser.