source: trunk/src/TropFlux_swr_BLND_19890101_20091231.pro @ 85

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

restart consolidation of paper01 software

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