source: trunk/src/d2m_to_q2m_erai.pro @ 79

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

complete documentation

File size: 6.6 KB
Line 
1;+
2;
3; .. _d2m_to_q2m_erai.pro:
4;
5; ===================
6; d2m_to_q2m_erai.pro
7; ===================
8;
9; Conversion of d2m to q2m on OAFLUX grid
10;
11; :file:`${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc` have been
12; produced by :ref:`interp_erai_dewt_1989_2009.pro`.
13;
14; :file:`${PROJECT_OD}/erai_t2m_19890101_20091231_oafluxgrid.nc` have been
15; produced by :ref:`interp_erai_t2m_1989_2009.pro`.
16;
17; :file:`${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc` have been
18; produced by :ref:`interp_erai_msl_1989_2009.pro`.
19;
20; q2m on OAFLUX grid is written in
21; :file:`${PROJECT_OD}/q2m_erai_19890101_20091231_oafluxgrid.nc`
22; if this file not already exists.
23;
24; This file will be used by :ref:`q2m_correction_ncdf.pro`.
25;
26;     .. graphviz::
27;
28;        digraph d2m_to_q2m_erai {
29;           graph [
30;           rankdir="LR",
31;           ]
32;
33;           file_d2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc"];
34;           file_t2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_t2m_19890101_20091231_oafluxgrid.nc"];
35;           file_msl [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc"];
36;           file_q2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/q2m_erai_19890101_20091231_oafluxgrid.nc"];
37;
38;           d2m_to_q2m_erai [shape=box,
39;           fontname=Courier,
40;           color=blue,
41;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/d2m_to_q2m_erai.pro",
42;           label="${PROJECT}/src/d2m_to_q2m_erai.pro"];
43;
44;           {file_d2m file_t2m file_msl} -> {d2m_to_q2m_erai} -> {file_q2m}
45;        }
46;
47; SEE ALSO
48; ========
49;
50; :ref:`project_profile.sh`
51;
52; :ref:`mooring_corrections`
53;
54; :ref:`interp_erai_dewt_1989_2009.pro`
55; :ref:`interp_erai_msl_1989_2009.pro`
56; :ref:`interp_erai_t2m_1989_2009.pro`
57;
58; :ref:`q2m_correction_ncdf.pro`
59;
60; :func:`rh_to_spechum`
61; :func:`initncdf <saxo:initncdf>`
62; :func:`read_ncdf <saxo:read_ncdf>`
63; :func:`julday <saxo:julday>`
64; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
65;
66; EXAMPLES
67; ========
68;
69; ::
70;
71;  IDL> d2m_to_q2m_erai
72;
73; TODO
74; ====
75;
76; es0 undefined
77;
78; coding rules
79;
80; EVOLUTIONS
81; ==========
82;
83; $Id$
84;
85; $URL$
86;
87; - fplod 20110809T154249Z aedon.locean-ipsl.upmc.fr (Darwin)
88;
89;   * typo
90;
91; - fplod 20110808T120234Z cratos (Linux)
92;
93;   * usage of ${PROJECT_OD}
94;   * complete description
95;   * remove return statement
96;
97; - fplod 20101215T162933Z aedon.locean-ipsl.upmc.fr (Darwin)
98;
99;   * graph correction
100;
101; - fplod 20101215T093141Z aedon.locean-ipsl.upmc.fr (Darwin)
102;
103;   * add graph in header
104;
105; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
106;
107;   * minimal header
108;
109; - pbk 2008
110;
111;   * creation
112;
113;-
114pro d2m_to_q2m_erai
115;
116@cm_4cal
117@cm_4data
118@cm_4mesh
119@cm_4data
120@cm_project
121;
122; test if ${PROJECT_OD} defined
123CASE project_od_env OF
124  '' : BEGIN
125         msg = 'eee : ${PROJECT_OD} is not defined'
126         ras = report(msg)
127       STOP
128       END
129  ELSE: BEGIN
130          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
131          ras = report(msg)
132        END
133 ENDCASE
134;
135; check if output data will be possible
136iodirout = isadirectory(project_od_env)
137;
138; existence and protection for reading
139IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
140   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
141   ras = report(msg)
142   STOP
143ENDIF
144;
145; existence and protection for writing
146IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
147    msg = 'eee : the directory' + iodirout  + ' was not found.'
148    ras = report(msg)
149    STOP
150ENDIF
151;
152d1=19881001 & d2=20101231
153;
154; build d2m filename
155filename_d2m='erai_d2m_19890101_20091231_oafluxgrid.nc'
156;
157; check if this file exists
158fullfilename_d2m = isafile(iodirout + filename_d2m, NEW=0, /MUST_EXIST)
159IF fullfilename_d2m[0] EQ '' THEN BEGIN
160   msg = 'eee : the file ' + fullfilename_d2m + ' was not found.'
161   ras = report(msg)
162   STOP
163ENDIF
164;
165; build t2m filename
166filename_t2m='erai_t2m_19890101_20091231_oafluxgrid.nc'
167;
168; check if this file exists
169fullfilename_t2m = isafile(iodirout + filename_t2m, NEW=0, /MUST_EXIST)
170IF fullfilename_t2m[0] EQ '' THEN BEGIN
171   msg = 'eee : the file ' + fullfilename_t2m + ' was not found.'
172   ras = report(msg)
173   STOP
174ENDIF
175;
176; build msl filename
177filename_msl='erai_msl_19890101_20091231_oafluxgrid.nc'
178;
179; check if this file exists
180fullfilename_msl = isafile(iodirout + filename_msl, NEW=0, /MUST_EXIST)
181IF fullfilename_msl[0] EQ '' THEN BEGIN
182   msg = 'eee : the file ' + fullfilename_msl + ' was not found.'
183   ras = report(msg)
184   STOP
185ENDIF
186;
187; build output filename
188filename_out = 'q2m_erai_19890101_20091231_oafluxgrid.nc'
189fullfilename_out = iodirout + filename_out
190; in order to avoid unexpected overwritten
191IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
192   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
193   ras = report(msg)
194   STOP
195ENDIF
196;
197; reading erai dew point temperature
198initncdf, fullfilename_d2m
199td=read_ncdf("d2m", d1,d2, file=fullfilename_d2m,/nostr)
200
201; reading erai air temperature
202initncdf, fullfilename_t2m
203t=read_ncdf("t2m", d1,d2, file=fullfilename_t2m,/nostr)
204tt=time &jpt=n_elements(time)
205help, t, td
206
207;;since the t2m and d2m are already in K, no need for conversion
208
209e=es0*exp((25.e5/461.5)*((1/273.15)-(1/td)))
210es=es0*exp((25.e5/461.5)*((1/273.15)-(1/t)))
211
212rh=(e/es)*100
213
214;; conversion of relative humidity to sp. humidity
215;; Ref.1 -  Gill, Appendix 4,
216;; Ref.2 - http://efdl.cims.nyu.edu/project_aomip/forcing_data/atmosphere/humidity.html
217
218t=t-273.15
219
220initncdf, fullfilename_msl
221P=read_ncdf("msl", d1, d2, file=fullfilename_msl,/nostr)
222help, P
223q2m=rh_to_spechum(rh,t,P)
224
225;writing field
226ncfile='!' + fullfilename_out
227time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
228cda0=string(jul2date(time(0)),format='(i8.8)')
229cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
230
231tt=time-julday(1,1,1950,00,00,00)
232xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*))
233valmask=1.e20
234
235lon_attr={units:'degrees_east',long_name:'Longitude'}
236lat_attr={units:'degrees_north',long_name:'Latitude'}
237q2m_attr={units:'kg/kg',missing_value:valmask,long_name:'Surface specific humidity at 2m ',short_name:'q2m',axis:'TYX'}
238time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
239globattr={source:'Surface specific humidity at 2m calculated from dew point temperature',timerange:cda0+' - '+cda1}
240
241ncfields = 'q2m[longitude,latitude,time]=q2m:q2m_attr; ' $
242                      + 'longitude[]=xlon:lon_attr; ' $
243                      + 'latitude[]=ylat:lat_attr; ' $
244                      + 'tt[*time]=tt:time_attr ' $
245                      + ' @ globattr'
246
247@ncdf_quickwrite
248end
Note: See TracBrowser for help on using the repository browser.