source: trunk/src/lwr_correction_ncdf.pro @ 152

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

start to homogenize (to be cont.)

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