source: trunk/src/TropFlux_swr_NRT_19890101_20091231.pro @ 169

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

start to homogenize (to be cont.)

  • Property svn:keywords set to URL
File size: 7.1 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
27; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`.
28;
29;     .. graphviz::
30;
31;        digraph tropflux_swr_nrt_19890101_200912311 {
32;
33;           file_swr_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"];
34;           file_olr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc"];
35;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"];
36;
37;           tropflux_swr_nrt_19890101_200912311 [shape=box,
38;           fontname=Courier,
39;           color=blue,
40;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_NRT_19890101_200912311.pro",
41;           label="${PROJECT}/src/TropFlux_swr_NRT_19890101_200912311.pro"];
42;
43;           {file_swr_dt file_olr}-> {tropflux_swr_nrt_19890101_200912311} -> {file_out}
44;       }
45;
46; SEE ALSO
47; ========
48;
49; :ref:`project_profile.sh`
50;
51; :ref:`mooring_corrections`
52;
53; :ref:`data_in_swr`
54; :ref:`data_in_olr`
55;
56; :func:`initncdf <saxo:initncdf>`
57; :func:`read_ncdf <saxo:read_ncdf>`
58; :func:`julday <saxo:julday>`
59; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
60;
61; EXAMPLES
62; ========
63;
64; ::
65;
66;  IDL> .compile TropFlux_swr_NRT_19890101_20091231
67;  IDL> tropflux_swr_nrt_19890101_20091231
68;
69; TODO
70; ====
71;
72; remove NaNf values in ouptut file (may be not because of this module)
73;
74; why two sequence initcdf et read_ndcf on olr file ?
75;
76; coding rules
77;
78; why compile is needed ? uppercase in file name
79;
80; change the name to swr_nrt_correction_ncdf.pro
81; to homogenize names of tools
82;
83; KNOWN ISSUES
84; ============
85;
86; test of existence of fullfilename not very efficient because
87; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
88;
89; EVOLUTIONS
90; ==========
91;
92; $Id: TropFlux_swr_NRT_19890101_20091231.pro 88 2011-08-19 15:40:14Z pinsard $
93;
94; $URL$
95;
96; - fplod 20110830T135938Z cratos (Linux)
97;
98;   * replace tt by time
99;   * fill empty time_origin:wq
100;
101; - fplod 20110812T075406Z aedon.locean-ipsl.upmc.fr (Darwin)
102;
103;   * usage of ${PROJECT_OD}
104;   * complete description
105;   * remove v50 in filenames
106;
107; - fplod 20101215T092145Z aedon.locean-ipsl.upmc.fr (Darwin)
108;
109;   * add graph in header
110;
111; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
112;
113;   * minimal header
114;
115; - pbk 2008
116;
117;   * creation
118;
119;-
120pro TropFlux_swr_NRT_19890101_20091231
121;
122@cm_4cal
123@cm_4data
124@cm_4mesh
125@cm_4data
126@cm_project
127;
128; test if ${PROJECT_OD} defined
129CASE project_od_env OF
130  '' : BEGIN
131         msg = 'eee : ${PROJECT_OD} is not defined'
132         ras = report(msg)
133       STOP
134       END
135  ELSE: BEGIN
136          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
137          ras = report(msg)
138        END
139 ENDCASE
140; check if output data will be possible
141iodirout = isadirectory(project_od_env)
142;
143; existence and protection for reading
144IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
145   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
146   ras = report(msg)
147   STOP
148ENDIF
149;
150; existence and protection for writing
151IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
152    msg = 'eee : the directory' + iodirout  + ' was not found.'
153    ras = report(msg)
154    STOP
155ENDIF
156;
157; build swr dt data filename
158filename_swr_dt='TropFlux_swr_19890101_20071231_DT.nc'
159;
160; check if this file exists
161msg='iii : looking for ' + filename_swr_dt
162ras = report(msg)
163fullfilename_swr_dt = isafile(iodirout + filename_swr_dt, NEW=0, /MUST_EXIST)
164IF fullfilename_swr_dt[0] EQ '' THEN BEGIN
165   msg = 'eee : the file ' + fullfilename_swr_dt + ' was not found.'
166   ras = report(msg)
167   STOP
168ENDIF
169;
170; build olr data filename
171filename_olr='olr_oafluxgrid_30n30s_19890101_20091231.nc'
172;
173; check if this file exists
174msg='iii : looking for ' + filename_olr
175ras = report(msg)
176fullfilename_olr = isafile(iodirout + filename_olr, NEW=0, /MUST_EXIST)
177IF fullfilename_olr[0] EQ '' THEN BEGIN
178   msg = 'eee : the file ' + fullfilename_olr + ' was not found.'
179   ras = report(msg)
180   STOP
181ENDIF
182;
183; build output filename
184filename_out = 'TropFlux_swr_19890101_20091231_NRT.nc'
185fullfilename_out = iodirout + filename_out
186; in order to avoid unexpected overwritten
187IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
188   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
189   ras = report(msg)
190   STOP
191ENDIF
192;
193initncdf, fullfilename_swr_dt
194sw=read_ncdf("swr", 19890101, 20071231, file=fullfilename_swr_dt,/nostr)
195;
196swi=sw
197;
198initncdf, fullfilename_olr
199olr=read_ncdf('olr',19890100, 20071231, file=fullfilename_olr,/nost)
200;
201help, sw, olr
202;
203;creating climatology
204;
205ny=(2007-1989)+1
206nt=365*ny
207olri=total(reform(olr(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny
208swi=total(reform(swi(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny
209;
210help, olri, swi
211;
212; applying smoothing
213nsmooth=45
214;
215swi=[[[swi]],[[swi]],[[swi]]]
216olri=[[[olri]],[[olri]],[[olri]]]
217si=size(sw)
218n1=si(1)
219n2=si(2)
220;
221for j=0,n2-1 do begin
222  for i=0,n1-1 do begin
223    x=reform(swi(i,j,*))
224    y=reform(olri(i,j,*))
225    swi(i,j,*)=smooth(x,nsmooth)
226    olri(i,j,*)=smooth(y,nsmooth)
227  endfor
228endfor
229;
230swi=swi[*,*,365:365+364]
231olri=olri[*,*,365:365+364]
232help, swi
233;
234initncdf, fullfilename_olr
235olr=read_ncdf('olr', 19890100, 20091231, box=box, file=fullfilename_olr,/nostr)
236jpt=n_elements(time)
237caldat, time,mon,day,yea
238swm=olr*0.
239olrm=olr*0.
240for jt=0,jpt-1 do begin
241  jtt=(time(jt)-julday(1,1,yea(jt))) < 364
242  swm(*,*,jt)=swi(*,*,jtt)
243  olrm(*,*,jt)=olri(*,*,jtt)
244endfor
245;
246help, swm, olrm
247;
248olra=olr-olrm                       ; olr anomaly
249rec=swm+(olra/0.760364)             ; reconstructed sw
250;
251; writing field
252time=timegen(7670, start=julday(1,1,1989,0), units='days')
253cda0=string(jul2date(time(0)),format='(i8.8)')
254cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
255;
256lat=reform(gphit(0,0:jpj-1))
257lon=reform(glamt(0:jpi-1,0))
258time=time-julday(1,1,1950)
259jpt=n_elements(time)
260;
261ncfile='!' + fullfilename_out
262lon_attr={units:'degrees_east',long_name:'Longitude'}
263lat_attr={units:'degrees_north',long_name:'Latitude'}
264time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
265globattr={source:'Reconstructed from corrected OLR anomalies and TropFlux mean SWR climatology',timerange:cda0+' - '+cda1}
266sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'}
267;
268;
269ncfields = 'sw[longitude,latitude,time]=rec:sw_attr; ' $
270                      + 'longitude[]=lon:lon_attr; ' $
271                      + 'latitude[]=lat:lat_attr; ' $
272                      + 'time[*time]=time:time_attr ' $
273                      + ' @ globattr'
274;
275@ncdf_quickwrite
276;
277end
Note: See TracBrowser for help on using the repository browser.