source: trunk/src/q2m_correction_ncdf.pro @ 81

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

progress on swr and olr processing

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