source: trunk/src/TropFlux_swr_BLND_19890101_20091231.pro @ 81

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

progress on swr and olr processing

File size: 7.2 KB
Line 
1;+
2;
3; .. _TropFlux_swr_BLND_19890101_20091231.pro:
4;
5; =======================================
6; TropFlux_swr_BLND_19890101_20091231.pro
7; =======================================
8;
9; DESCRIPTION
10; ===========
11;
12; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc`
13; containing ++
14; have been produced by :ref:`TropFlux_swr_DT_19890101_20071231.pro`.
15;
16; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc`
17; containing ++
18; have been produced by :ref:`TropFlux_swr_NRT_19890101_20091231.pro`.
19;
20; :file:`${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc` containing ++
21; have been produced by :ref:` cronin_gustiness_ncdf.pro`.
22;
23; ++ are written
24; in :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc`
25; if this file not already exists.
26;
27; This file will be used by :ref:`TropFlux_NRT_cfd.pro`.
28;
29;     .. graphviz::
30;
31;        digraph tropflux_swr_blnd_19890101_20091231 {
32;
33;           file_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"];
34;           file_nrt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"];
35;           file_gustiness [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc"];
36;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_blnd.nc"];
37;
38;           tropflux_swr_blnd_19890101_20091231 [shape=box,
39;           fontname=Courier,
40;           color=blue,
41;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_BLND_19890101_20091231.pro",
42;           label="${PROJECT}/src/TropFlux_swr_BLND_19890101_20091231.pro"];
43;
44;           {file_dt file_nrt file_gustiness} -> {tropflux_swr_blnd_19890101_20091231} -> {file_out}
45;
46;       }
47;
48; SEE ALSO
49; ========
50;
51; :ref:`project_profile.sh`
52;
53; :ref:`mooring_corrections`
54;
55; :ref:`data_in_swr`
56;
57; :func:`initncdf <saxo:initncdf>`
58; :func:`read_ncdf <saxo:read_ncdf>`
59; :func:`julday <saxo:julday>`
60; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
61;
62; :ref:`Tropflux_NRT_cdf.pro`
63;
64; EXAMPLES
65; ========
66;
67; ::
68;
69;  IDL> .compile TropFlux_swr_BLND_19890101_20091231
70;  IDL> tropflux_swr_blnd_19890101_20091231
71;
72; TODO
73; ====
74;
75; resolve crash on cratos idl7::
76;
77;   % Attempt to subscript SWR_DT with JT is out of range.
78;
79; line::
80;
81;    for jt=0,jpt-1 do swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt)
82;
83; avoid mix lower/uppercase in pro name to avoid compile
84;
85; coding rules
86;
87; complete description
88;
89; why different date1 and date2 when readind dt and nrt
90;
91; why two read_ncdf for nrt
92;
93; according to pk 20110811 we can include this process in TropFlux_swr_NRT_19890101_20091231.pro
94;
95; KNOWN ISSUES
96; ============
97;
98; test of existence of fullfilename_in not very efficient because
99; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
100;
101; EVOLUTIONS
102; ==========
103;
104; $Id$
105;
106; $URL$
107;
108; - fplod 20110809T115747Z aedon.locean-ipsl.upmc.fr (Darwin)
109;
110;   * usage of ${PROJECT_OD}
111;   * remove v* from filenames (in and out)
112;   * add test on IO files
113;
114; - fplod 20101215T085754Z aedon.locean-ipsl.upmc.fr (Darwin)
115;
116;   * add graph in header
117;
118; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
119;
120;   * minimal header
121;
122; - pbk 2008
123;
124;   * creation
125;
126;-
127pro TropFlux_swr_BLND_19890101_20091231
128;
129@cm_4cal
130@cm_4data
131@cm_4mesh
132@cm_4data
133@cm_project
134;
135;
136; test if ${PROJECT_OD} defined
137CASE project_od_env OF
138  '' : BEGIN
139         msg = 'eee : ${PROJECT_OD} is not defined'
140         ras = report(msg)
141       STOP
142       END
143  ELSE: BEGIN
144          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
145          ras = report(msg)
146        END
147 ENDCASE
148;
149; check if output data will be possible
150iodirout = isadirectory(project_od_env)
151;
152; existence and protection for reading
153IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
154   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
155   ras = report(msg)
156   STOP
157ENDIF
158;
159; existence and protection for writing
160IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
161    msg = 'eee : the directory' + iodirout  + ' was not found.'
162    ras = report(msg)
163    STOP
164ENDIF
165;
166; build dt data filename
167filename_dt="TropFlux_swr_19890101_20071231_DT.nc"
168;
169; check if this file exists
170msg='iii : looking for ' + filename_dt
171ras = report(msg)
172fullfilename_dt = isafile(iodirout + filename_dt, NEW=0, /MUST_EXIST)
173IF fullfilename_dt[0] EQ '' THEN BEGIN
174   msg = 'eee : the file ' + fullfilename_dt + ' was not found.'
175   ras = report(msg)
176   STOP
177ENDIF
178
179; build nrt data filename
180filename_nrt="TropFlux_swr_19890101_20091231_NRT.nc"
181;
182; check if this file exists
183msg='iii : looking for ' + filename_nrt
184ras = report(msg)
185fullfilename_nrt = isafile(iodirout + filename_nrt, NEW=0, /MUST_EXIST)
186IF fullfilename_nrt[0] EQ '' THEN BEGIN
187   msg = 'eee : the file ' + fullfilename_nrt + ' was not found.'
188   ras = report(msg)
189   STOP
190ENDIF
191;
192; build wg data filename
193filename_wg="TropFlux_gustiness_19890101_20091231.nc"
194;
195; check if this file exists
196msg='iii : looking for ' + filename_wg
197ras = report(msg)
198fullfilename_wg = isafile(iodirout + filename_wg, NEW=0, /MUST_EXIST)
199IF fullfilename_wg[0] EQ '' THEN BEGIN
200   msg = 'eee : the file ' + fullfilename_wg + ' was not found.'
201   ras = report(msg)
202   STOP
203ENDIF
204;
205; build output filename
206filename_out = 'TropFlux_swr_19890101_20091231_BLND.nc'
207fullfilename_out = iodirout + filename_out
208; in order to avoid unexpected overwritten
209IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
210   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
211   ras = report(msg)
212   STOP
213ENDIF
214;
215initncdf, fullfilename_dt
216dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr)
217help, dt
218
219initncdf, fullfilename_nrt
220nrt=read_ncdf("sw", 20080100, 20100112, file=fullfilename_nrt,/nostr)
221help, nrt
222
223swr_nrt=read_ncdf("sw", 19880101, 20100112, file=fullfilename_nrt,/nostr)
224
225swr_dt=[[[dt]],[[nrt]]]
226help, swr_dt, swr_nrt
227
228swr_merged=swr_dt*0.
229
230time=timegen(7670, units='days', start=julday(1,1,1989,0)) & jpt=n_elements(time)
231
232a=interpol([1.,0.],[julday(10,01,2007),julday(12,31,2007)],time)
233a=((a > 0.) < 1.)
234for jt=0,jpt-1 do swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt)
235
236initncdf, file_wg
237time=timegen(7670, units='days', start=julday(1,1,1989,0)) & jpt=n_elements(time)
238lat=reform(gphit(0,0:jpj-1))
239lon=reform(glamt(0:jpi-1,0))
240cda0=string(jul2date(time(0)),format='(i8.8)')
241cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
242
243time=time-julday(1,1,1950,00,00)
244ncfile='!' + fullfilename_out
245lon_attr={units:'degrees_east',long_name:'Longitude'}
246lat_attr={units:'degrees_north',long_name:'Latitude'}
247time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
248sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'}
249globattr={source:'ISCCP based SWR until 2007, after 2007 timeseries is completed with OLR based SWR.  A linear transition is applied from ISCCP based SWR to OLR based SWR'}
250
251ncfields = 'swr[longitude,latitude,time]=swr_merged:sw_attr; ' $
252                      + 'longitude[]=lon:lon_attr; ' $
253                      + 'latitude[]=lat:lat_attr; ' $
254                      + 'time[*time]=time:time_attr ' $
255                      + ' @ globattr'
256
257@ncdf_quickwrite
258
259end
Note: See TracBrowser for help on using the repository browser.