source: trunk/src/d2m_to_q2m_erai.pro @ 152

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

start to homogenize (to be cont.)

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