source: trunk/src/TropFlux_swr_NRT_19890101_20091231.pro @ 85

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

progress on swr and olr processing

File size: 6.9 KB
Line 
1;+
2;
3; .. _TropFlux_swr_NRT_19890101_20091231.pro:
4;
5; ======================================
6; TropFlux_swr_NRT_19890101_20091231.pro
7; ======================================
8;
9; DESCRITION
10; ==========
11;
12; Correction of swr near real time on OAFLUX grid
13;
14; Corrected swr delay on OAFLUX grid
15; has been produced by
16; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc`
17;
18; :file:`${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc`
19; have been produced ++by pk
20;
21; Corrected swr near real time on OAFLUX grid
22; ; is written in
23; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc`
24; if this file not already exists.
25;
26; This file will be used by :ref:`TropFlux_swr_BLND_19890101_20091231.pro`.
27;
28;     .. graphviz::
29;
30;        digraph tropflux_swr_nrt_19890101_200912311 {
31;
32;           file_swr_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"];
33;           file_olr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc"];
34;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"];
35;
36;           tropflux_swr_nrt_19890101_200912311 [shape=box,
37;           fontname=Courier,
38;           color=blue,
39;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_NRT_19890101_200912311.pro",
40;           label="${PROJECT}/src/TropFlux_swr_NRT_19890101_200912311.pro"];
41;
42;           {file_swr_dt file_olr}-> {tropflux_swr_nrt_19890101_200912311} -> {file_out}
43;       }
44;
45; SEE ALSO
46; ========
47;
48; :ref:`project_profile.sh`
49;
50; :ref:`mooring_corrections`
51;
52; :ref:`data_in_swr`
53; :ref:`data_in_olr`
54;
55; :func:`initncdf <saxo:initncdf>`
56; :func:`read_ncdf <saxo:read_ncdf>`
57; :func:`julday <saxo:julday>`
58; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
59;
60; EXAMPLES
61; ========
62;
63; ::
64;
65;  IDL> .compile TropFlux_swr_NRT_19890101_20091231
66;  IDL> tropflux_swr_nrt_19890101_20091231
67;
68; TODO
69; ====
70;
71; remove NaNf values in ouptut file (may be not because of this module)
72;
73; why two sequence initcdf et read_ndcf on olr file ?
74;
75; coding rules
76;
77; why compile is needed ? uppercase in file name
78;
79; change the name to swr_nrt_correction_ncdf.pro
80; to homogenize names of tools
81;
82; KNOWN ISSUES
83; ============
84;
85; test of existence of fullfilename not very efficient because
86; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
87;
88; EVOLUTIONS
89; ==========
90;
91; $Id$
92;
93; $URL$
94;
95; - fplod 20110812T075406Z aedon.locean-ipsl.upmc.fr (Darwin)
96;
97;   * usage of ${PROJECT_OD}
98;   * complete description
99;   * remove v50 in filenames
100;
101; - fplod 20101215T092145Z 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 TropFlux_swr_NRT_19890101_20091231
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; check if output data will be possible
135iodirout = isadirectory(project_od_env)
136;
137; existence and protection for reading
138IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
139   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
140   ras = report(msg)
141   STOP
142ENDIF
143;
144; existence and protection for writing
145IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
146    msg = 'eee : the directory' + iodirout  + ' was not found.'
147    ras = report(msg)
148    STOP
149ENDIF
150;
151; build swr dt data filename
152filename_swr_dt='TropFlux_swr_19890101_20071231_DT.nc'
153;
154; check if this file exists
155msg='iii : looking for ' + filename_swr_dt
156ras = report(msg)
157fullfilename_swr_dt = isafile(iodirout + filename_swr_dt, NEW=0, /MUST_EXIST)
158IF fullfilename_swr_dt[0] EQ '' THEN BEGIN
159   msg = 'eee : the file ' + fullfilename_swr_dt + ' was not found.'
160   ras = report(msg)
161   STOP
162ENDIF
163;
164; build olr data filename
165filename_olr='olr_oafluxgrid_30n30s_19890101_20091231.nc'
166;
167; check if this file exists
168msg='iii : looking for ' + filename_olr
169ras = report(msg)
170fullfilename_olr = isafile(iodirout + filename_olr, NEW=0, /MUST_EXIST)
171IF fullfilename_olr[0] EQ '' THEN BEGIN
172   msg = 'eee : the file ' + fullfilename_olr + ' was not found.'
173   ras = report(msg)
174   STOP
175ENDIF
176;
177; build output filename
178filename_out = 'TropFlux_swr_19890101_20091231_NRT.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_swr_dt
188sw=read_ncdf("swr", 19890101, 20071231, file=fullfilename_swr_dt,/nostr)
189
190swi=sw
191
192initncdf, fullfilename_olr
193olr=read_ncdf('olr',19890100, 20071231, file=fullfilename_olr,/nost)
194
195help, sw, olr
196
197;;creating climatology
198
199ny=(2007-1989)+1
200nt=365*ny
201olri=total(reform(olr(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny
202swi=total(reform(swi(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny
203
204help, olri, swi
205
206;; applying smoothing
207nsmooth=45
208
209swi=[[[swi]],[[swi]],[[swi]]] & olri=[[[olri]],[[olri]],[[olri]]]
210si=size(sw) & n1=si(1) & n2=si(2)
211
212for j=0,n2-1 do begin
213  for i=0,n1-1 do begin
214    x=reform(swi(i,j,*))
215    y=reform(olri(i,j,*))
216    swi(i,j,*)=smooth(x,nsmooth)
217    olri(i,j,*)=smooth(y,nsmooth)
218  endfor
219endfor
220
221swi=swi[*,*,365:365+364] & olri=olri[*,*,365:365+364]
222help, swi
223
224initncdf, fullfilename_olr
225olr=read_ncdf('olr', 19890100, 20091231, box=box, file=fullfilename_olr,/nostr)
226tt=time & jpt=n_elements(time)
227caldat, time,mon,day,yea
228swm=olr*0. & olrm=olr*0.
229for jt=0,jpt-1 do begin
230  jtt=(time(jt)-julday(1,1,yea(jt))) < 364
231  swm(*,*,jt)=swi(*,*,jtt)
232  olrm(*,*,jt)=olri(*,*,jtt)
233endfor
234
235help, swm, olrm
236
237olra=olr-olrm                       ; olr anomaly
238rec=swm+(olra/0.760364)             ; reconstructed sw
239;writing field
240time=julday(1,1,1989)+lindgen(7670)
241cda0=string(jul2date(tt(0)),format='(i8.8)')
242cda1=string(jul2date(tt(jpt-1)),format='(i8.8)')
243
244lat=reform(gphit(0,0:jpj-1))
245lon=reform(glamt(0:jpi-1,0))
246time=time-julday(1,1,1950) & jpt=n_elements(time)
247
248ncfile='!' + fullfilename_out
249lon_attr={units:'degrees_east',long_name:'Longitude'}
250lat_attr={units:'degrees_north',long_name:'Latitude'}
251time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:''}
252sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'}
253globattr={source:'Reconstructed from corrected OLR anomalies and TropFlux mean SWR climatology',timerange:cda0+' - '+cda1}
254
255
256ncfields = 'sw[longitude,latitude,time]=rec:sw_attr; ' $
257                      + 'longitude[]=lon:lon_attr; ' $
258                      + 'latitude[]=lat:lat_attr; ' $
259                      + 'time[*time]=time:time_attr ' $
260                      + ' @ globattr'
261
262@ncdf_quickwrite
263
264end
Note: See TracBrowser for help on using the repository browser.