source: trunk/src/TropFlux_swr_DT_19890101_20071231.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: 5.8 KB
Line 
1;+
2;
3; .. _TropFlux_swr_DT_19890101_20071231.pro:
4;
5; =====================================
6; TropFlux_swr_DT_19890101_20071231.pro
7; =====================================
8;
9; DESCRIPTION
10; ===========
11;
12; Correction of swr delay time on OAFLUX grid
13;
14; :file:`${PROJECT_OD}/swr_oafluxgrid_1985_2007.nc`
15; have been produced ++by pk
16;
17; Corrected swr delay on OAFLUX grid
18; is written in
19; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc`
20; if this file not already exists.
21;
22; This file will be used by
23; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`.
24;
25;     .. graphviz::
26;
27;        digraph tropflux_swr_dt_19890101_20071231 {
28;
29;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/swr_oafluxgrid_1985_2007.nc"];
30;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"];
31;
32;           tropflux_swr_dt_19890101_20071231 [shape=box,
33;           fontname=Courier,
34;           color=blue,
35;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_DT_19890101_20071231.pro",
36;           label="${PROJECT}/src/TropFlux_swr_DT_19890101_20071231.pro"];
37;
38;           {file_in}-> {tropflux_swr_dt_19890101_20071231} -> {file_out}
39;
40;        }
41;
42; SEE ALSO
43; ========
44;
45; :ref:`project_profile.sh`
46;
47; :ref:`mooring_corrections`
48;
49; :ref:`data_in_swr`
50;
51; :func:`initncdf <saxo:initncdf>`
52; :func:`read_ncdf <saxo:read_ncdf>`
53; :func:`grossemoyenne <saxo:grossemoyenne>`
54; :func:`julday <saxo:julday>`
55; :func:`caldat <saxo:caldat>`
56; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
57;
58; EXAMPLES
59; ========
60;
61; ::
62;
63;  IDL> .compile TropFlux_swr_DT_19890101_20071231
64;  IDL> tropflux_swr_dt_19890101_20071231
65;
66; TODO
67; ====
68;
69; NaNf values in ouptut file while 1.e20 in input file !!
70;
71; coding rules
72;
73; why compile is needed ? uppercase in file name
74;
75; any way change the name to swr_dt_correction_ndcf.pro
76; to homogenize names of tools
77;
78; use the output of concat_swr.sh to be written.
79; now use swr_oafluxgrid_1985_2007.nc provided by pk 20110811
80;
81; KNOWN ISSUES
82; ============
83;
84; test of existence of fullfilename not very efficient because
85; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
86;
87; EVOLUTIONS
88; ==========
89;
90; $Id: TropFlux_swr_DT_19890101_20071231.pro 88 2011-08-19 15:40:14Z pinsard $
91;
92; $URL$
93;
94; - fplod 20110830T135743Z cratos (Linux)
95;
96;   * replace tt by time
97;
98; - fplod 20110812T073138Z aedon.locean-ipsl.upmc.fr (Darwin)
99;
100;   * usage of ${PROJECT_OD}
101;   * complete description
102;   * remove v50 in output filename
103;
104; - fplod 20101215T091726Z aedon.locean-ipsl.upmc.fr (Darwin)
105;
106;   * add graph in header
107;
108; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
109;
110;   * minimal header
111;
112; - pbk 2008
113;
114;   * creation
115;
116;-
117pro TropFlux_swr_DT_19890101_20071231
118;
119@cm_4cal
120@cm_4data
121@cm_4mesh
122@cm_4data
123@cm_project
124;
125; test if ${PROJECT_OD} defined
126CASE project_od_env OF
127  '' : BEGIN
128         msg = 'eee : ${PROJECT_OD} is not defined'
129         ras = report(msg)
130       STOP
131       END
132  ELSE: BEGIN
133          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
134          ras = report(msg)
135        END
136 ENDCASE
137;
138; check if output data will be possible
139iodirout = isadirectory(project_od_env)
140;
141; existence and protection for reading
142IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
143   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
144   ras = report(msg)
145   STOP
146ENDIF
147;
148; existence and protection for writing
149IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
150    msg = 'eee : the directory' + iodirout  + ' was not found.'
151    ras = report(msg)
152    STOP
153ENDIF
154;
155; build data filename
156filename='swr_oafluxgrid_1985_2007.nc'
157;
158; check if this file exists
159msg='iii : looking for ' + filename
160ras = report(msg)
161fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST)
162IF fullfilename[0] EQ '' THEN BEGIN
163   msg = 'eee : the file ' + fullfilename + ' was not found.'
164   ras = report(msg)
165   STOP
166ENDIF
167;
168; build output filename
169filename_out = 'TropFlux_swr_19890101_20071231_DT.nc'
170fullfilename_out = iodirout + filename_out
171; in order to avoid unexpected overwritten
172IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
173   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
174   ras = report(msg)
175   STOP
176ENDIF
177;
178initncdf, filename
179;
180sw=read_ncdf("swr", 19890101, 20071231, file=filename,/nostr)
181help, sw
182;
183sw_mean=grossemoyenne(sw, 't',/nan)
184help, sw_mean
185;
186jpt=n_elements(time)
187caldat, time,mon,day,yea
188sw_m=sw*0.
189sw_bias=sw*0.
190;
191for jt=0,jpt-1 do begin
192  jtt=(time(jt)-julday(1,1,yea(jt))) < 364
193  swr=reform(sw_mean(*,*))
194  sw_m(*,*,jt)=swr
195  sw_bias(*,*,jt)=(((swr-295.4)*18.36/(200.-295.4)) > 0.) < 18.37
196endfor
197;
198help, sw_m, sw_bias
199swa=sw-sw_m
200swa=swa/(0.901273)       ; variability correction (seasonal_cycle_swr_isccp.pro)
201;
202swr=sw_m+swa-sw_bias       ; new swr, corrected for bias and variability
203;
204; writing field
205cda0=string(jul2date(time(0)),format='(i8.8)')
206cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
207;
208lat=reform(gphit(0,0:jpj-1))
209lon=reform(glamt(0:jpi-1,0))
210time=time-julday(1,1,1950)
211jpt=n_elements(time)
212;
213ncfile='!' + fullfilename_out
214lon_attr={units:'degrees_east',long_name:'Longitude'}
215lat_attr={units:'degrees_north',long_name:'Latitude'}
216time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
217globattr={source:'Obtained from ISCCP.  Corrections has been done on mean bias and variability',timerange:cda0+' - '+cda1}
218sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'}
219;
220ncfields = 'swr[longitude,latitude,time]=swr:sw_attr; ' $
221                      + 'longitude[]=lon:lon_attr; ' $
222                      + 'latitude[]=lat:lat_attr; ' $
223                      + 'time[*time]=time:time_attr ' $
224                      + ' @ globattr'
225;
226@ncdf_quickwrite
227;
228end
Note: See TracBrowser for help on using the repository browser.