Changeset 175 for trunk/src/t2m_correction_ncdf.pro
- Timestamp:
- 03/22/12 14:40:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/t2m_correction_ncdf.pro
r155 r175 1 1 ;+ 2 ;3 ; .. _t2m_correction_ncdf.pro:4 2 ; 5 3 ; ======================= … … 7 5 ; ======================= 8 6 ; 7 ; .. function:: t2m_correction_ncdf(yyyymmddb,yyyymmdde) 8 ; 9 ; DESCRIPTION 10 ; =========== 11 ; 9 12 ; Mean correction for air temperature bias and correction for variability are 10 13 ; applied. 11 14 ; 12 ; :file:`${PROJECT_ID}/erai_t2m_ 19890101_20091231_oafluxgrid.nc`15 ; :file:`${PROJECT_ID}/erai_t2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 13 16 ; containing 14 17 ; air temperature at 2 m height from ERA-I interpolated on OAFLUX grid … … 18 21 ; Corrected air temperature at 2 m height 19 22 ; is written in 20 ; :file:`${PROJECT_OD}/TropFlux_t2m_ 19890101_20091231.nc`23 ; :file:`${PROJECT_OD}/TropFlux_t2m_{yyyymmdd}_{yyyymmdd}.nc` 21 24 ; if this file not already exists. 22 25 ; 23 26 ; This output file 24 ; :file:`${PROJECT_OD}/TropFlux_t2m_ 19890101_20091231.nc`27 ; :file:`${PROJECT_OD}/TropFlux_t2m_{yyyymmdd}_{yyyymmdd}.nc` 25 28 ; will be used by 26 ; : ref:`TropFlux_19890101_20091231.pro`.29 ; :func:`tropflux`. 27 30 ; 28 31 ; .. only:: man … … 36 39 ; digraph t2m_correction_ncdf { 37 40 ; 38 ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_t2m_ 19890101_20091231_oafluxgrid.nc"];39 ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_t2m_ 19890101_20091231.nc"];41 ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_t2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; 42 ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_t2m_{yyyymmdd}_{yyyymmdd}.nc"]; 40 43 ; 41 44 ; t2m_correction_ncdf [shape=box, … … 52 55 ; ======== 53 56 ; 57 ; :ref:`mooring_corrections` 58 ; 59 ; Used by :ref:`tropflux.sh` 60 ; 54 61 ; :ref:`project_profile.sh` 55 ;56 ; :ref:`mooring_corrections`57 62 ; 58 63 ; :func:`interp_erai_t2m` … … 72 77 ; :: 73 78 ; 74 ; IDL> t2m_correction_ncdf 79 ; IDL> yyyymmddb = 20000101L 80 ; IDL> yyyymmdde = 20001231L 81 ; IDL> result = t2m_correction_ncdf(yyyymmddb, yyyymmdde) 82 ; IDL> print, result 75 83 ; 76 84 ; TODO … … 97 105 ; check time values 98 106 ; 99 ; hard coded time in module name and in output filename100 ;101 107 ; hard coded correction values 102 108 ; … … 121 127 ; 122 128 ; $URL$ 129 ; 130 ; - fplod 20120322 131 ; 132 ; * taking project_overwite into account 133 ; * try to add compile_opt seems to be incompatible with ncdf_quickwrite 134 ; * pro -> function 135 ; * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters 136 ; * replace t2m=ncdf_lec(... by a t2m=read_ncdf( 123 137 ; 124 138 ; - fplod 20110822T112525Z aedon.locean-ipsl.upmc.fr (Darwin) … … 156 170 ; 157 171 ;- 158 pro t2m_correction_ncdf 172 function t2m_correction_ncdf $ 173 , yyyymmddb $ 174 , yyyymmdde 175 ; 176 ;++compile_opt idl2, strictarrsubs, logical_predicate 159 177 ; 160 178 @cm_4cal … … 164 182 @cm_project 165 183 ; 184 ; Return to caller if errors 185 ON_ERROR, 2 186 ; 187 result = -1 188 ; 189 usage = 'result = sst_correction_ncdf(yyyymmddb, yyyymmdde)' 190 nparam = N_PARAMS() 191 IF (nparam NE 2) THEN BEGIN 192 ras = report(['Incorrect number of arguments.' $ 193 + '!C' $ 194 + 'Usage : ' + usage]) 195 return, result 196 ENDIF 197 166 198 ; test if ${PROJECT_OD} defined 167 199 CASE project_id_env OF … … 169 201 msg = 'eee : ${PROJECT_OD} is not defined' 170 202 ras = report(msg) 171 STOP203 return, result 172 204 END 173 205 ELSE: BEGIN … … 184 216 msg = 'eee : the directory' + iodirout + ' is not accessible.' 185 217 ras = report(msg) 186 STOP218 return, result 187 219 ENDIF 188 220 ; … … 191 223 msg = 'eee : the directory' + iodirout + ' was not found.' 192 224 ras = report(msg) 193 STOP 194 ENDIF 195 ; 196 da1=19890101 197 da2=20091231 225 return, result 226 ENDIF 198 227 ; 199 228 ; build uncorrected t2 filename 200 229 filename_t2_uncor = 'erai_t2m_' $ 201 + string( da1,format='(i8.8)') $230 + string(yyyymmddb,format='(i8.8)') $ 202 231 + '_' $ 203 + string( da2,format='(i8.8)') $232 + string(yyyymmdde,format='(i8.8)') $ 204 233 + '_oafluxgrid.nc' 205 234 ; … … 211 240 msg = 'eee : the file ' + fullfilename_t2_uncor + ' was not found.' 212 241 ras = report(msg) 213 STOP242 return, result 214 243 ENDIF 215 244 ; 216 245 ; build output filename 217 246 filename_out = 'TropFlux_t2m_' $ 218 + string( da1,format='(i8.8)') $247 + string(yyyymmddb,format='(i8.8)') $ 219 248 + '_' $ 220 + string( da2,format='(i8.8)') $249 + string(yyyymmdde,format='(i8.8)') $ 221 250 + '.nc' 222 251 ; 223 252 fullfilename_out = iodirout + filename_out 224 253 ; in order to avoid unexpected overwritten 225 IF ( FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN254 IF ((FILE_TEST(fullfilename_out) EQ 1) AND (project_overwrite EQ 0)) THEN BEGIN 226 255 msg = 'eee : the file ' + fullfilename_out + ' already exists.' 227 256 ras = report(msg) 228 STOP257 return, result 229 258 ENDIF 230 259 ; … … 239 268 ; 240 269 ; find first and last dates yyyymmdd 241 ; they will be written in global attributes of output file242 270 da=jul2date(julday(01, 01, 1957,timein[0])) 243 271 cda0=string(da,format='(i8.8)') 244 272 da=jul2date(julday(01, 01, 1957,timein[jptin-1])) 245 273 cda1=string(da,format='(i8.8)') 246 print, 'f irst date ', cda0247 print, ' last date ' , cda1274 print, 'for time checking first date ', cda0 275 print, 'for time checking last date ' , cda1 248 276 ; 249 277 ; read t2 data 250 t2m=ncdf_lec(fullfilename_t2_uncor,var='t2m') 278 initncdf, fullfilename_t2_uncor 279 t2m=read_ncdf('t2m',yyyymmddb-.5d,yyyymmdde,file=fullfilename_t2_uncor,/nostr) 280 timein=24.d*(time-julday(1,1,1957,0,0,0)) 281 jpt=n_elements(timein) 282 da=jul2date(time[0]) 283 cda0=string(da,format='(i8.8)') 284 da=jul2date(time[jpt-1]) 285 cda1=string(da,format='(i8.8)') 286 print, 't2m in t2m_correction_ncdf first date ', cda0 287 print, 't2m in t2m_correction_ncdf last date ' , cda1 251 288 ; 252 289 t2m=t2m-273.15 … … 267 304 ;++print,day 268 305 jtt=(julday(01, 01, 1957,timein[jt])-julday(1,1,yea)) < 364 269 t=reform(t2m_mean (*,*))270 t2m_m (*,*,jt)=t271 bias_cor (*,*,jt)=(((t-22.6)*0.4004896/(28-22.6)) > 0.) <0.4 ; (2000-2009)306 t=reform(t2m_mean[*,*]) 307 t2m_m[*,*,jt]=t 308 bias_cor[*,*,jt]=(((t-22.6)*0.4004896/(28-22.6)) > 0.) <0.4 ; (2000-2009) 272 309 endfor 273 310 help, t2m_m,bias_cor … … 290 327 ; 291 328 ;writing field 292 lat=reform(gphit(0,0:jpj-1)) 293 lon=reform(glamt(0:jpi-1,0)) 294 cda0=string(da1) 295 cda1=string(da2) 296 ; 297 ; conversion for hours since 19570101 to days from 19500101 298 time=julday(01, 01, 1957,timein)-julday(1,1,1950) 299 jpt=n_elements(time) 329 lat=reform(gphit[0,0:jpj-1]) 330 lon=reform(glamt[0:jpi-1,0]) 300 331 ; 301 332 ncfile='!' + fullfilename_out … … 313 344 t2m_attr={units:units,missing_value:1.e20,long_name:long_name,short_name:'t2m',axis:'TYX'} 314 345 ; 315 ncfields = 't2m[longitude,latitude, time]=t2m_new:t2m_attr; ' $346 ncfields = 't2m[longitude,latitude,*time]=t2m_new:t2m_attr; ' $ 316 347 + 'longitude[]=lon:lon_attr; ' $ 317 348 + 'latitude[]=lat:lat_attr; ' $ 318 + 'time[ *time]=time:time_attr ' $349 + 'time[]=timein:time_attr ' $ 319 350 + ' @ globattr' 320 351 ; 321 352 @ncdf_quickwrite 322 353 ; 354 result = 0 355 return, result 356 ; 323 357 end
Note: See TracChangeset
for help on using the changeset viewer.