source: trunk/src/TropFlux_swr_DT_19890101_20071231.pro @ 85

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

progress on swr and olr processing

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