Changeset 175 for trunk/src/q2m_correction_ncdf.pro
- Timestamp:
- 03/22/12 14:40:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/q2m_correction_ncdf.pro
r172 r175 1 1 ;+ 2 ;3 ; .. _q2m_correction_ncdf.pro:4 2 ; 5 3 ; ======================= … … 7 5 ; ======================= 8 6 ; 7 ; .. function:: q2m_correction_ncdf(yyyymmddb,yyyymmdde) 8 ; 9 9 ; DESCRIPTION 10 10 ; =========== … … 12 12 ; Correction of q2m on OAFLUX grid 13 13 ; 14 ; :file:`${PROJECT_OD}/erai_q2m_ 19890101_20091231_oafluxgrid.nc`14 ; :file:`${PROJECT_OD}/erai_q2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` 15 15 ; containing 16 16 ; ++ … … 20 20 ; Corrected q2m on OAFLUX grid 21 21 ; is written in 22 ; :file:`${PROJECT_OD}/TropFlux_q2m_ 19890101_20091231.nc`22 ; :file:`${PROJECT_OD}/TropFlux_q2m_{yyyymmdd}_{yyyymmdd}.nc` 23 23 ; if this file not already exists. 24 24 ; 25 25 ; This file will be used by 26 ; : ref:`TropFlux_19890101_20091231.pro`.26 ; :func:`tropflux`. 27 27 ; 28 28 ; .. only:: man … … 36 36 ; digraph q2m_correction_ncdf { 37 37 ; 38 ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_q2m_ 19890101_20091231_oafluxgrid.nc"];39 ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_ 19890101_20091231.nc"];38 ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_q2m_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; 39 ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_{yyyymmdd}_{yyyymmdd}.nc"]; 40 40 ; 41 41 ; q2m_correction_ncdf [shape=box, … … 52 52 ; ======== 53 53 ; 54 ; :ref:`mooring_corrections` 55 ; 56 ; Used by :ref:`tropflux.sh` 57 ; 54 58 ; :ref:`project_profile.sh` 55 ;56 ; :ref:`mooring_corrections`57 59 ; 58 60 ; :func:`d2m_to_q2m_erai` … … 69 71 ; :: 70 72 ; 71 ; IDL> q2m_correction_ncdf 73 ; IDL> yyyymmddb = 20000101L 74 ; IDL> yyyymmdde = 20001231L 75 ; IDL> result = q2m_correction_ncdf(yyyymmddb, yyyymmdde) 76 ; IDL> print, result 72 77 ; 73 78 ; TODO 74 79 ; ==== 75 80 ; 76 ; work on cratos idl7 even if NaNf values in erai_q2m_19890101_20091231_oafluxgrid.nc written by 77 ; d2m_to_q2m.pro. 81 ; make it work :: 82 ; 83 ; Writing fields: 84 ; q2m[longitude,latitude,time*]=q2m_new:q2m_attr; longitude[]=lon:lon_attr; latitude[]=lat:lat_attr; time[]=timein:time_attr @ globattr 85 ; % NCDF_DIMDEF: Unable to create dimension. (NC_ERROR=-59) 86 ; % NCDF_VARDEF: Unable to define variable, bad dimension id . 87 ; % NCDF_VARPUT: Variable Inquiry failed, -1 is not a valid variable id. 88 ; % Stop encountered: Q2M_CORRECTION_NCDF 1 89 ; /.autofs/lodyc/incas/fplod/tropflux/tropflux_ws/src/q2m_correction_ncdf.pro 78 90 ; 79 91 ; No way ... NaNf also in this output !! … … 88 100 ; $URL$ 89 101 ; 102 ; - fplod 20120322 103 ; 104 ; * taking project_overwite into account 105 ; * try to add compile_opt seems to be incompatible with ncdf_quickwrite 106 ; * pro -> function 107 ; * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters 108 ; * get rid of timegen 109 ; 90 110 ; - fplod 20110808T143129Z aedon.locean-ipsl.upmc.fr (Darwin) 91 111 ; … … 106 126 ; 107 127 ;- 108 pro q2m_correction_ncdf 128 function q2m_correction_ncdf $ 129 , yyyymmddb $ 130 , yyyymmdde 131 ; 132 ;++compile_opt idl2, strictarrsubs, logical_predicate 109 133 ; 110 134 @cm_4cal … … 114 138 @cm_project 115 139 ; 140 ; Return to caller if errors 141 ON_ERROR, 2 142 ; 143 result = -1 144 ; 145 usage = 'result = q2m_correction_ncdf(yyyymmddb, yyyymmdde)' 146 nparam = N_PARAMS() 147 IF (nparam NE 2) THEN BEGIN 148 ras = report(['Incorrect number of arguments.' $ 149 + '!C' $ 150 + 'Usage : ' + usage]) 151 return, result 152 ENDIF 153 116 154 ; test if ${PROJECT_OD} defined 117 155 CASE project_od_env OF … … 119 157 msg = 'eee : ${PROJECT_OD} is not defined' 120 158 ras = report(msg) 121 STOP159 return, result 122 160 END 123 161 ELSE: BEGIN … … 134 172 msg = 'eee : the directory' + iodirout + ' is not accessible.' 135 173 ras = report(msg) 136 STOP174 return, result 137 175 ENDIF 138 176 ; … … 141 179 msg = 'eee : the directory' + iodirout + ' was not found.' 142 180 ras = report(msg) 143 STOP 144 ENDIF 145 ; 146 da1=19880101 147 da2=20101231 181 return, result 182 ENDIF 148 183 ; 149 184 ; build data filename 150 filename='erai_q2m_ 19890101_20091231_oafluxgrid.nc'185 filename='erai_q2m_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_oafluxgrid.nc' 151 186 ; 152 187 ; check if this file exists … … 157 192 msg = 'eee : the file ' + fullfilename + ' was not found.' 158 193 ras = report(msg) 159 STOP194 return, result 160 195 ENDIF 161 196 ; 162 197 ; build output filename 163 filename_out = 'TropFlux_q2m_ 19890101_20091231.nc'198 filename_out = 'TropFlux_q2m_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' 164 199 fullfilename_out = iodirout + filename_out 165 200 ; in order to avoid unexpected overwritten 166 IF ( FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN201 IF ((FILE_TEST(fullfilename_out) EQ 1) AND (project_overwrite EQ 0)) THEN BEGIN 167 202 msg = 'eee : the file ' + fullfilename_out + ' already exists.' 168 203 ras = report(msg) 169 STOP204 return, result 170 205 ENDIF 171 206 ; 172 207 initncdf, fullfilename 173 q2m=read_ncdf('q2m',da1,da2,file=fullfilename,/nostr) 208 q2m=read_ncdf('q2m',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) 209 timein=24.d*(time-julday(1,1,1957,0,0,0)) 210 jpt=n_elements(timein) 211 da=jul2date(time[0]) 212 cda0=string(da,format='(i8.8)') 213 da=jul2date(time[jpt-1]) 214 cda1=string(da,format='(i8.8)') 215 print, 'q2m in q2m_correction_ncdf first date ', cda0 216 print, 'q2m in q2m_correction_ncdf last date ' , cda1 217 ; 174 218 help, q2m 175 219 ; … … 182 226 ; 183 227 for jt=0,jpt-1 do begin 184 jtt=(time (jt)-julday(1,1,yea(jt))) < 364185 q=reform(q2m_mean (*,*))186 q2m_m (*,*,jt)=q228 jtt=(time[jt]-julday(1,1,yea[jt])) < 364 229 q=reform(q2m_mean[*,*]) 230 q2m_m[*,*,jt]=q 187 231 endfor 188 232 help, q2m_m … … 203 247 ; 204 248 ;writing field 205 lat=reform(gphit(0,0:jpj-1)) 206 lon=reform(glamt(0:jpi-1,0)) 207 time=timegen(7670, start=julday(1,1,1989,0), units='days') 208 jpt=n_elements(time) 209 ; 210 cda0=string(jul2date(time(0)),format='(i8.8)') 211 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 212 ; 213 time=time-julday(1,1,1950) 214 jpt=n_elements(time) 249 lat=reform(gphit[0,0:jpj-1]) 250 lon=reform(glamt[0:jpi-1,0]) 215 251 ; 216 252 ncfile='!' + fullfilename_out … … 221 257 q2m_attr={units:'g/kg',missing_value:1.e20,long_name:'Specific humidity at 2m height',short_name:'q2m',axis:'TYX'} 222 258 ; 223 ncfields = 'q2m[longitude,latitude,time ]=q2m_new:q2m_attr; ' $259 ncfields = 'q2m[longitude,latitude,time*]=q2m_new:q2m_attr; ' $ 224 260 + 'longitude[]=lon:lon_attr; ' $ 225 261 + 'latitude[]=lat:lat_attr; ' $ 226 + 'time[ *time]=time:time_attr ' $262 + 'time[]=timein:time_attr ' $ 227 263 + ' @ globattr' 228 264 ; 229 265 @ncdf_quickwrite 230 266 ; 267 result = 0 268 return, result 269 ; 231 270 end
Note: See TracChangeset
for help on using the changeset viewer.