Changeset 175 for trunk/src/ws_correction_ncdf.pro
- Timestamp:
- 03/22/12 14:40:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ws_correction_ncdf.pro
r172 r175 1 1 ;+ 2 ;3 ; .. _ws_correction_ncdf.pro:4 2 ; 5 3 ; ====================== … … 7 5 ; ====================== 8 6 ; 7 ; .. function:: ws_correction_ncdf(yyyymmddb,yyyymmdde) 8 ; 9 ; DESCRIPTION 10 ; =========== 11 ; 9 12 ; Correction of ws on OAFLUX grid 10 13 ; 11 ; :file:`${PROJECT_OD}/erai_ws_ 19890101_20091231_oafluxgrid.nc`14 ; :file:`${PROJECT_OD}/erai_ws_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 12 15 ; containing 13 16 ; ++ … … 17 20 ; Corrected ws on OAFLUX grid 18 21 ; is written in 19 ; :file:`${PROJECT_OD}/TropFlux_ws_ 19890101_20091231.nc`22 ; :file:`${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc` 20 23 ; if this file not already exists. 21 24 ; 22 25 ; This output file 23 ; :file:`${PROJECT_OD}/TropFlux_ws_ 19890101_20091231.nc`26 ; :file:`${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc` 24 27 ; will be used by 25 ; : ref:`TropFlux_19890101_20091231.pro`.28 ; :func:`tropflux`. 26 29 ; 27 30 ; .. only:: man … … 35 38 ; digraph ws_correction_ncdf { 36 39 ; 37 ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_ws_ 19890101_20091231_oafluxgrid.nc"];38 ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_ 19890101_20091231.nc"];40 ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_ws_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; 41 ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc"]; 39 42 ; 40 43 ; ws_correction_ncdf [shape=box, … … 51 54 ; ======== 52 55 ; 56 ; :ref:`mooring_corrections` 57 ; 58 ; Used by :ref:`tropflux.sh` 59 ; 53 60 ; :ref:`project_profile.sh` 54 ;55 ; :ref:`mooring_corrections`56 61 ; 57 62 ; :func:`interp_erai_ws` … … 69 74 ; :: 70 75 ; 71 ; IDL> ws_correction_ncdf 76 ; IDL> yyyymmddb = 20000101L 77 ; IDL> yyyymmdde = 20001231L 78 ; IDL> result = ws_correction_ncdf(yyyymmddb, yyyymmdde) 79 ; IDL> print, result 72 80 ; 73 81 ; TODO … … 90 98 ; 91 99 ; $URL$ 100 ; 101 ; - fplod 20120322 102 ; 103 ; * taking project_overwite into account 104 ; * try to add compile_opt seems to be incompatible with ncdf_quickwrite 105 ; * pro -> function 106 ; * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters 107 ; * get rid of timegen 92 108 ; 93 109 ; - fplod 20110808T131954Z aedon.locean-ipsl.upmc.fr (Darwin) … … 110 126 ; 111 127 ;- 112 pro ws_correction_ncdf 113 ; 114 @cm_4cal 128 function ws_correction_ncdf $ 129 , yyyymmddb $ 130 , yyyymmdde 131 ; 132 ;++compile_opt idl2, strictarrsubs, logical_predicate 133 ; 115 134 @cm_4data 116 135 @cm_4mesh … … 118 137 @cm_project 119 138 ; 139 ; Return to caller if errors 140 ON_ERROR, 2 141 ; 142 result = -1 143 ; 144 usage = 'result = ws_correction_ncdf(yyyymmddb, yyyymmdde)' 145 nparam = N_PARAMS() 146 IF (nparam NE 2) THEN BEGIN 147 ras = report(['Incorrect number of arguments.' $ 148 + '!C' $ 149 + 'Usage : ' + usage]) 150 return, result 151 ENDIF 152 ; 153 @cm_4cal 120 154 ; test if ${PROJECT_OD} defined 121 155 CASE project_od_env OF … … 123 157 msg = 'eee : ${PROJECT_OD} is not defined' 124 158 ras = report(msg) 125 STOP159 return, result 126 160 END 127 161 ELSE: BEGIN … … 138 172 msg = 'eee : the directory' + iodirout + ' is not accessible.' 139 173 ras = report(msg) 140 STOP174 return, result 141 175 ENDIF 142 176 ; … … 145 179 msg = 'eee : the directory' + iodirout + ' was not found.' 146 180 ras = report(msg) 147 STOP 148 ENDIF 149 ; 150 da1=19880101 151 da2=20101231 181 return, result 182 ENDIF 152 183 ; 153 184 ; build data filename 154 filename='erai_ws_19890101_20091231_oafluxgrid.nc' 185 filename='erai_ws_' $ 186 + string(yyyymmddb,format='(i8.8)') $ 187 + '_' $ 188 + string(yyyymmdde,format='(i8.8)') $ 189 + '_oafluxgrid.nc' 155 190 ; 156 191 ; check if this file exists … … 161 196 msg = 'eee : the file ' + fullfilename + ' was not found.' 162 197 ras = report(msg) 163 STOP198 return, result 164 199 ENDIF 165 200 ; 166 201 ; build output filename 167 filename_out = 'TropFlux_ws_19890101_20091231.nc' 202 filename_out = 'TropFlux_ws_' $ 203 + string(yyyymmddb,format='(i8.8)') $ 204 + '_' $ 205 + string(yyyymmdde,format='(i8.8)') $ 206 + '.nc' 168 207 fullfilename_out = iodirout + filename_out 169 208 ; in order to avoid unexpected overwritten 170 IF ( FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN209 IF ((FILE_TEST(fullfilename_out) EQ 1) AND (project_overwrite EQ 0)) THEN BEGIN 171 210 msg = 'eee : the file ' + fullfilename_out + ' already exists.' 172 211 ras = report(msg) 173 STOP212 return, result 174 213 ENDIF 175 214 ; 176 215 initncdf, fullfilename 177 u=read_ncdf('u10',da1,da2,file=fullfilename,/nostr) 178 v=read_ncdf('v10',da1,da2,file=fullfilename,/nostr) 216 u=read_ncdf('u10',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) 217 timein=24.d*(time-julday(1,1,1957,0,0,0)) 218 jpt=n_elements(timein) 219 da=jul2date(time[0]) 220 cda0=string(da,format='(i8.8)') 221 da=jul2date(time[jpt-1]) 222 cda1=string(da,format='(i8.8)') 223 print, 'u10 in ws_correction_ncdf first date ', cda0 224 print, 'u10 in ws_correction_ncdf last date ' , cda1 225 ; 226 v=read_ncdf('v10',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) 227 timein=24.d*(time-julday(1,1,1957,0,0,0)) 228 jpt=n_elements(timein) 229 da=jul2date(time[0]) 230 cda0=string(da,format='(i8.8)') 231 da=jul2date(time[jpt-1]) 232 cda1=string(da,format='(i8.8)') 233 print, 'v10 in ws_correction_ncdf first date ', cda0 234 print, 'v10 in ws_correction_ncdf last date ' , cda1 235 ; 179 236 w=sqrt(u*u+v*v) 180 237 ; … … 189 246 ; 190 247 for jt=0,jpt-1 do begin 191 jtt=(time (jt)-julday(1,1,yea(jt))) < 364192 q=reform(w_mean (*,*))193 w_m (*,*,jt)=q248 jtt=(time[jt]-julday(1,1,yea[jt])) < 364 249 q=reform(w_mean[*,*]) 250 w_m[*,*,jt]=q 194 251 endfor 195 252 help, w_m … … 211 268 ; 212 269 ;writing field 213 lat=reform(gphit(0,0:jpj-1)) 214 lon=reform(glamt(0:jpi-1,0)) 215 time=timegen(7670, start=julday(1,1,1989,0), units='days') 216 jpt=n_elements(time) 217 ; 218 cda0=string(jul2date(time(0)),format='(i8.8)') 219 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 220 ; 221 time=time-julday(1,1,1950) 222 jpt=n_elements(time) 270 lat=reform(gphit[0,0:jpj-1]) 271 lon=reform(glamt[0:jpi-1,0]) 223 272 ; 224 273 ncfile='!' + fullfilename_out … … 229 278 w_attr={units:'m/s',missing_value:1.e20,long_name:'mean wind speed',short_name:'w',axis:'TYX'} 230 279 ; 231 ncfields = 'ws[longitude,latitude, time]=w_new:w_attr; ' $280 ncfields = 'ws[longitude,latitude,*time]=w_new:w_attr; ' $ 232 281 + 'longitude[]=lon:lon_attr; ' $ 233 282 + 'latitude[]=lat:lat_attr; ' $ 234 + 'time[ *time]=time:time_attr ' $283 + 'time[]=timein:time_attr ' $ 235 284 + ' @ globattr' 236 285 ; 237 286 @ncdf_quickwrite 238 287 ; 288 result = 0 289 return, result 290 ; 239 291 end
Note: See TracChangeset
for help on using the changeset viewer.