source: trunk/src/TropFlux_swr_BLND_19890101_20091231.pro @ 95

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

get rid of multistatement lines

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