1 | ;+ |
---|
2 | ; |
---|
3 | ; .. _TropFlux_swr_NRT_19890101_20091231.pro: |
---|
4 | ; |
---|
5 | ; ====================================== |
---|
6 | ; TropFlux_swr_NRT_19890101_20091231.pro |
---|
7 | ; ====================================== |
---|
8 | ; |
---|
9 | ; DESCRITION |
---|
10 | ; ========== |
---|
11 | ; |
---|
12 | ; Correction of swr near real time on OAFLUX grid |
---|
13 | ; |
---|
14 | ; Corrected swr delay on OAFLUX grid |
---|
15 | ; has been produced by |
---|
16 | ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc` |
---|
17 | ; |
---|
18 | ; :file:`${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc` |
---|
19 | ; have been produced ++by pk |
---|
20 | ; |
---|
21 | ; Corrected swr near real time on OAFLUX grid |
---|
22 | ; ; is written in |
---|
23 | ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc` |
---|
24 | ; if this file not already exists. |
---|
25 | ; |
---|
26 | ; This file will be used by |
---|
27 | ; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`. |
---|
28 | ; |
---|
29 | ; .. graphviz:: |
---|
30 | ; |
---|
31 | ; digraph tropflux_swr_nrt_19890101_200912311 { |
---|
32 | ; |
---|
33 | ; file_swr_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"]; |
---|
34 | ; file_olr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc"]; |
---|
35 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"]; |
---|
36 | ; |
---|
37 | ; tropflux_swr_nrt_19890101_200912311 [shape=box, |
---|
38 | ; fontname=Courier, |
---|
39 | ; color=blue, |
---|
40 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_NRT_19890101_200912311.pro", |
---|
41 | ; label="${PROJECT}/src/TropFlux_swr_NRT_19890101_200912311.pro"]; |
---|
42 | ; |
---|
43 | ; {file_swr_dt file_olr}-> {tropflux_swr_nrt_19890101_200912311} -> {file_out} |
---|
44 | ; } |
---|
45 | ; |
---|
46 | ; SEE ALSO |
---|
47 | ; ======== |
---|
48 | ; |
---|
49 | ; :ref:`project_profile.sh` |
---|
50 | ; |
---|
51 | ; :ref:`mooring_corrections` |
---|
52 | ; |
---|
53 | ; :ref:`data_in_swr` |
---|
54 | ; :ref:`data_in_olr` |
---|
55 | ; |
---|
56 | ; :func:`initncdf <saxo:initncdf>` |
---|
57 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
58 | ; :func:`julday <saxo:julday>` |
---|
59 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
60 | ; |
---|
61 | ; EXAMPLES |
---|
62 | ; ======== |
---|
63 | ; |
---|
64 | ; :: |
---|
65 | ; |
---|
66 | ; IDL> .compile TropFlux_swr_NRT_19890101_20091231 |
---|
67 | ; IDL> tropflux_swr_nrt_19890101_20091231 |
---|
68 | ; |
---|
69 | ; TODO |
---|
70 | ; ==== |
---|
71 | ; |
---|
72 | ; remove NaNf values in ouptut file (may be not because of this module) |
---|
73 | ; |
---|
74 | ; why two sequence initcdf et read_ndcf on olr file ? |
---|
75 | ; |
---|
76 | ; coding rules |
---|
77 | ; |
---|
78 | ; why compile is needed ? uppercase in file name |
---|
79 | ; |
---|
80 | ; change the name to swr_nrt_correction_ncdf.pro |
---|
81 | ; to homogenize names of tools |
---|
82 | ; |
---|
83 | ; KNOWN ISSUES |
---|
84 | ; ============ |
---|
85 | ; |
---|
86 | ; test of existence of fullfilename not very efficient because |
---|
87 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
88 | ; |
---|
89 | ; EVOLUTIONS |
---|
90 | ; ========== |
---|
91 | ; |
---|
92 | ; $Id: TropFlux_swr_NRT_19890101_20091231.pro 88 2011-08-19 15:40:14Z pinsard $ |
---|
93 | ; |
---|
94 | ; $URL$ |
---|
95 | ; |
---|
96 | ; - fplod 20110830T135938Z cratos (Linux) |
---|
97 | ; |
---|
98 | ; * replace tt by time |
---|
99 | ; * fill empty time_origin:wq |
---|
100 | ; |
---|
101 | ; - fplod 20110812T075406Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
102 | ; |
---|
103 | ; * usage of ${PROJECT_OD} |
---|
104 | ; * complete description |
---|
105 | ; * remove v50 in filenames |
---|
106 | ; |
---|
107 | ; - fplod 20101215T092145Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
108 | ; |
---|
109 | ; * add graph in header |
---|
110 | ; |
---|
111 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
112 | ; |
---|
113 | ; * minimal header |
---|
114 | ; |
---|
115 | ; - pbk 2008 |
---|
116 | ; |
---|
117 | ; * creation |
---|
118 | ; |
---|
119 | ;- |
---|
120 | pro TropFlux_swr_NRT_19890101_20091231 |
---|
121 | ; |
---|
122 | @cm_4cal |
---|
123 | @cm_4data |
---|
124 | @cm_4mesh |
---|
125 | @cm_4data |
---|
126 | @cm_project |
---|
127 | ; |
---|
128 | ; test if ${PROJECT_OD} defined |
---|
129 | CASE project_od_env OF |
---|
130 | '' : BEGIN |
---|
131 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
132 | ras = report(msg) |
---|
133 | STOP |
---|
134 | END |
---|
135 | ELSE: BEGIN |
---|
136 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
137 | ras = report(msg) |
---|
138 | END |
---|
139 | ENDCASE |
---|
140 | ; check if output data will be possible |
---|
141 | iodirout = isadirectory(project_od_env) |
---|
142 | ; |
---|
143 | ; existence and protection for reading |
---|
144 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
145 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
146 | ras = report(msg) |
---|
147 | STOP |
---|
148 | ENDIF |
---|
149 | ; |
---|
150 | ; existence and protection for writing |
---|
151 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
152 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
153 | ras = report(msg) |
---|
154 | STOP |
---|
155 | ENDIF |
---|
156 | ; |
---|
157 | ; build swr dt data filename |
---|
158 | filename_swr_dt='TropFlux_swr_19890101_20071231_DT.nc' |
---|
159 | ; |
---|
160 | ; check if this file exists |
---|
161 | msg='iii : looking for ' + filename_swr_dt |
---|
162 | ras = report(msg) |
---|
163 | fullfilename_swr_dt = isafile(iodirout + filename_swr_dt, NEW=0, /MUST_EXIST) |
---|
164 | IF fullfilename_swr_dt[0] EQ '' THEN BEGIN |
---|
165 | msg = 'eee : the file ' + fullfilename_swr_dt + ' was not found.' |
---|
166 | ras = report(msg) |
---|
167 | STOP |
---|
168 | ENDIF |
---|
169 | ; |
---|
170 | ; build olr data filename |
---|
171 | filename_olr='olr_oafluxgrid_30n30s_19890101_20091231.nc' |
---|
172 | ; |
---|
173 | ; check if this file exists |
---|
174 | msg='iii : looking for ' + filename_olr |
---|
175 | ras = report(msg) |
---|
176 | fullfilename_olr = isafile(iodirout + filename_olr, NEW=0, /MUST_EXIST) |
---|
177 | IF fullfilename_olr[0] EQ '' THEN BEGIN |
---|
178 | msg = 'eee : the file ' + fullfilename_olr + ' was not found.' |
---|
179 | ras = report(msg) |
---|
180 | STOP |
---|
181 | ENDIF |
---|
182 | ; |
---|
183 | ; build output filename |
---|
184 | filename_out = 'TropFlux_swr_19890101_20091231_NRT.nc' |
---|
185 | fullfilename_out = iodirout + filename_out |
---|
186 | ; in order to avoid unexpected overwritten |
---|
187 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
188 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
189 | ras = report(msg) |
---|
190 | STOP |
---|
191 | ENDIF |
---|
192 | ; |
---|
193 | initncdf, fullfilename_swr_dt |
---|
194 | sw=read_ncdf("swr", 19890101, 20071231, file=fullfilename_swr_dt,/nostr) |
---|
195 | ; |
---|
196 | swi=sw |
---|
197 | ; |
---|
198 | initncdf, fullfilename_olr |
---|
199 | olr=read_ncdf('olr',19890100, 20071231, file=fullfilename_olr,/nost) |
---|
200 | ; |
---|
201 | help, sw, olr |
---|
202 | ; |
---|
203 | ;creating climatology |
---|
204 | ; |
---|
205 | ny=(2007-1989)+1 |
---|
206 | nt=365*ny |
---|
207 | olri=total(reform(olr(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny |
---|
208 | swi=total(reform(swi(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny |
---|
209 | ; |
---|
210 | help, olri, swi |
---|
211 | ; |
---|
212 | ; applying smoothing |
---|
213 | nsmooth=45 |
---|
214 | ; |
---|
215 | swi=[[[swi]],[[swi]],[[swi]]] |
---|
216 | olri=[[[olri]],[[olri]],[[olri]]] |
---|
217 | si=size(sw) |
---|
218 | n1=si(1) |
---|
219 | n2=si(2) |
---|
220 | ; |
---|
221 | for j=0,n2-1 do begin |
---|
222 | for i=0,n1-1 do begin |
---|
223 | x=reform(swi(i,j,*)) |
---|
224 | y=reform(olri(i,j,*)) |
---|
225 | swi(i,j,*)=smooth(x,nsmooth) |
---|
226 | olri(i,j,*)=smooth(y,nsmooth) |
---|
227 | endfor |
---|
228 | endfor |
---|
229 | ; |
---|
230 | swi=swi[*,*,365:365+364] |
---|
231 | olri=olri[*,*,365:365+364] |
---|
232 | help, swi |
---|
233 | ; |
---|
234 | initncdf, fullfilename_olr |
---|
235 | olr=read_ncdf('olr', 19890100, 20091231, box=box, file=fullfilename_olr,/nostr) |
---|
236 | jpt=n_elements(time) |
---|
237 | caldat, time,mon,day,yea |
---|
238 | swm=olr*0. |
---|
239 | olrm=olr*0. |
---|
240 | for jt=0,jpt-1 do begin |
---|
241 | jtt=(time(jt)-julday(1,1,yea(jt))) < 364 |
---|
242 | swm(*,*,jt)=swi(*,*,jtt) |
---|
243 | olrm(*,*,jt)=olri(*,*,jtt) |
---|
244 | endfor |
---|
245 | ; |
---|
246 | help, swm, olrm |
---|
247 | ; |
---|
248 | olra=olr-olrm ; olr anomaly |
---|
249 | rec=swm+(olra/0.760364) ; reconstructed sw |
---|
250 | ; |
---|
251 | ; writing field |
---|
252 | time=timegen(7670, start=julday(1,1,1989,0), units='days') |
---|
253 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
254 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
255 | ; |
---|
256 | lat=reform(gphit(0,0:jpj-1)) |
---|
257 | lon=reform(glamt(0:jpi-1,0)) |
---|
258 | time=time-julday(1,1,1950) |
---|
259 | jpt=n_elements(time) |
---|
260 | ; |
---|
261 | ncfile='!' + fullfilename_out |
---|
262 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
263 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
264 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
265 | globattr={source:'Reconstructed from corrected OLR anomalies and TropFlux mean SWR climatology',timerange:cda0+' - '+cda1} |
---|
266 | sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'} |
---|
267 | ; |
---|
268 | ; |
---|
269 | ncfields = 'sw[longitude,latitude,time]=rec:sw_attr; ' $ |
---|
270 | + 'longitude[]=lon:lon_attr; ' $ |
---|
271 | + 'latitude[]=lat:lat_attr; ' $ |
---|
272 | + 'time[*time]=time:time_attr ' $ |
---|
273 | + ' @ globattr' |
---|
274 | ; |
---|
275 | @ncdf_quickwrite |
---|
276 | ; |
---|
277 | end |
---|