source: trunk/src/q2m_correction_ncdf.pro @ 172

Last change on this file since 172 was 172, checked in by pinsard, 12 years ago

interp_erai_ws, d2m_to_q2m_erai and interp_olr_30n30s are now functions

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