source: trunk/src/TropFlux_swr_BLND_19890101_20091231.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: 9.1 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
31; :ref:`TropFlux_NRT_ncdf.pro`.
32;
33;     .. graphviz::
34;
35;        digraph tropflux_swr_blnd_19890101_20091231 {
36;
37;           file_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"];
38;           file_nrt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"];
39;           file_gustiness [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc"];
40;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_blnd.nc"];
41;
42;           tropflux_swr_blnd_19890101_20091231 [shape=box,
43;           fontname=Courier,
44;           color=blue,
45;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_BLND_19890101_20091231.pro",
46;           label="${PROJECT}/src/TropFlux_swr_BLND_19890101_20091231.pro"];
47;
48;           {file_dt file_nrt file_gustiness} -> {tropflux_swr_blnd_19890101_20091231} -> {file_out}
49;
50;       }
51;
52; SEE ALSO
53; ========
54;
55; :ref:`project_profile.sh`
56;
57; :ref:`mooring_corrections`
58;
59; :ref:`data_in_swr`
60;
61; :func:`initncdf <saxo:initncdf>`
62; :func:`read_ncdf <saxo:read_ncdf>`
63; :func:`julday <saxo:julday>`
64; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
65;
66; :ref:`Tropflux_NRT_ncdf.pro`
67;
68; EXAMPLES
69; ========
70;
71; ::
72;
73;  IDL> .compile TropFlux_swr_BLND_19890101_20091231
74;  IDL> tropflux_swr_blnd_19890101_20091231
75;
76; TODO
77; ====
78;
79; submit read_ncdf with 19890101 pb to saxo-dev
80;
81; avoid mix lower/uppercase in pro name to avoid compile
82;
83; coding rules
84;
85; complete description
86;
87; why 20080100, 20100112 as  date1 and date2 when readind nrt
88;
89; why two read_ncdf for nrt
90;
91; according to pk 20110811 we can include this process in
92; TropFlux_swr_NRT_19890101_20091231.pro ... later
93;
94; KNOWN ISSUES
95; ============
96;
97; test of existence of fullfilename_in not very efficient because
98; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
99;
100; EVOLUTIONS
101; ==========
102;
103; $Id: TropFlux_swr_BLND_19890101_20091231.pro 88 2011-08-19 15:40:14Z pinsard $
104;
105; $URL$
106;
107; - fplod 20110819T120412Z aedon.locean-ipsl.upmc.fr (Darwin)
108;
109;   * change 19890101 to 19890100 to read 6939 timesteps in DT file
110;     even if uggly and understanted SAXO strange behaviour
111;
112;     this resolve crash on cratos idl7::
113;
114;       % Attempt to subscript SWR_DT with JT is out of range.
115;
116;     line::
117;
118;        for jt=0,jpt-1 do swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt)
119;
120;     problably because  6938+731=7669 and not 7670 when
121;     :samp:`dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr)`
122;     was used ::
123;
124;        DT              FLOAT     = Array[350, 60, 6938]
125;        NRT             FLOAT     = Array[350, 60, 731]
126;        SWR_DT          FLOAT     = Array[350, 60, 7669]
127;        SWR_NRT         FLOAT     = Array[350, 60, 7670]
128;
129;     nb jours 19890101-20071231::
130;
131;        IDL>  print, julday(12,31,2007) - julday(01, 01, 1989) +1
132;        6939
133;
134;     et ncdump -h $PROJECT_OD/TropFlux_swr_19890101_20071231_DT.nc time = UNLIMITED ; // (6939 currently)
135;
136;     nb jours 19890101-20091231::
137;
138;        IDL>  print, julday(12,31,2009) - julday(01, 01, 1989) +1
139;        7670
140;
141;     strange behaviour of read_ncdf ... see::
142;
143;        IDL> fullfilename_dt='TropFlux_swr_19890101_20071231_DT.nc'
144;        IDL> dt=read_ncdf("swr", 19890100, 20071231, file=fullfilename_dt,/nostr)
145;        IDL> print, 'first time step (should crash with invalid date)', jul2date(time[0])
146;        first time step (should be 19890101)       19890101.
147;        IDL> dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr)
148;        IDL> print, 'first time step (should be 19890101)', jul2date(time[0])
149;        first time step (should be 19890101)       19890102.
150;
151;   * correction for reading gustiness file
152;
153; - fplod 20110809T115747Z aedon.locean-ipsl.upmc.fr (Darwin)
154;
155;   * usage of ${PROJECT_OD}
156;   * remove v* from filenames (in and out)
157;   * add test on IO files
158;
159; - fplod 20101215T085754Z aedon.locean-ipsl.upmc.fr (Darwin)
160;
161;   * add graph in header
162;
163; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
164;
165;   * minimal header
166;
167; - pbk 2008
168;
169;   * creation
170;
171;-
172pro TropFlux_swr_BLND_19890101_20091231
173;
174@cm_4cal
175@cm_4data
176@cm_4mesh
177@cm_4data
178@cm_project
179;
180; test if ${PROJECT_OD} defined
181CASE project_od_env OF
182  '' : BEGIN
183         msg = 'eee : ${PROJECT_OD} is not defined'
184         ras = report(msg)
185       STOP
186       END
187  ELSE: BEGIN
188          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
189          ras = report(msg)
190        END
191 ENDCASE
192;
193; check if output data will be possible
194iodirout = isadirectory(project_od_env)
195;
196; existence and protection for reading
197IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
198   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
199   ras = report(msg)
200   STOP
201ENDIF
202;
203; existence and protection for writing
204IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
205    msg = 'eee : the directory' + iodirout  + ' was not found.'
206    ras = report(msg)
207    STOP
208ENDIF
209;
210; build dt data filename
211filename_dt="TropFlux_swr_19890101_20071231_DT.nc"
212;
213; check if this file exists
214msg='iii : looking for ' + filename_dt
215ras = report(msg)
216fullfilename_dt = isafile(iodirout + filename_dt, NEW=0, /MUST_EXIST)
217IF fullfilename_dt[0] EQ '' THEN BEGIN
218   msg = 'eee : the file ' + fullfilename_dt + ' was not found.'
219   ras = report(msg)
220   STOP
221ENDIF
222;
223; build nrt data filename
224filename_nrt="TropFlux_swr_19890101_20091231_NRT.nc"
225;
226; check if this file exists
227msg='iii : looking for ' + filename_nrt
228ras = report(msg)
229fullfilename_nrt = isafile(iodirout + filename_nrt, NEW=0, /MUST_EXIST)
230IF fullfilename_nrt[0] EQ '' THEN BEGIN
231   msg = 'eee : the file ' + fullfilename_nrt + ' was not found.'
232   ras = report(msg)
233   STOP
234ENDIF
235;
236; build wg data filename
237filename_wg="TropFlux_gustiness_19890101_20091231.nc"
238;
239; check if this file exists
240msg='iii : looking for ' + filename_wg
241ras = report(msg)
242fullfilename_wg = isafile(iodirout + filename_wg, NEW=0, /MUST_EXIST)
243IF fullfilename_wg[0] EQ '' THEN BEGIN
244   msg = 'eee : the file ' + fullfilename_wg + ' was not found.'
245   ras = report(msg)
246   STOP
247ENDIF
248;
249; build output filename
250filename_out = 'TropFlux_swr_19890101_20091231_BLND.nc'
251fullfilename_out = iodirout + filename_out
252; in order to avoid unexpected overwritten
253IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
254   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
255   ras = report(msg)
256   STOP
257ENDIF
258;
259initncdf, fullfilename_dt
260dt=read_ncdf("swr", 19890100, 20071231, file=fullfilename_dt,/nostr)
261print, 'www : should crash with invalide date 19890100'
262help, dt
263print, 'first time step (should be 19890101)', jul2date(time[0])
264print, 'last time step (should be 20071231)', jul2date(time[jpt-1])
265;
266initncdf, fullfilename_nrt
267nrt=read_ncdf("sw", 20080100, 20100112, file=fullfilename_nrt,/nostr)
268help, nrt
269;
270swr_nrt=read_ncdf("sw", 19880101, 20100112, file=fullfilename_nrt,/nostr)
271;
272swr_dt=[[[dt]],[[nrt]]]
273help, nrt, swr_dt, swr_nrt
274;
275swr_merged=swr_dt*0.
276;
277time=timegen(7670, start=julday(1,1,1989,0), units='days')
278jpt=n_elements(time)
279;
280a=interpol([1.,0.],[julday(10,01,2007),julday(12,31,2007)],time)
281a=((a > 0.) < 1.)
282for jt=0,jpt-1 do begin
283    swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt)
284endfor
285;
286initncdf, fullfilename_wg
287time=timegen(7670, units='days', start=julday(1,1,1989,0))
288jpt=n_elements(time)
289lat=reform(gphit(0,0:jpj-1))
290lon=reform(glamt(0:jpi-1,0))
291cda0=string(jul2date(time(0)),format='(i8.8)')
292cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
293;
294time=time-julday(1,1,1950,00,00)
295ncfile='!' + fullfilename_out
296lon_attr={units:'degrees_east',long_name:'Longitude'}
297lat_attr={units:'degrees_north',long_name:'Latitude'}
298time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
299globattr={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'}
300sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'}
301;
302ncfields = 'swr[longitude,latitude,time]=swr_merged:sw_attr; ' $
303                      + 'longitude[]=lon:lon_attr; ' $
304                      + 'latitude[]=lat:lat_attr; ' $
305                      + 'time[*time]=time:time_attr ' $
306                      + ' @ globattr'
307;
308@ncdf_quickwrite
309;
310end
Note: See TracBrowser for help on using the repository browser.