- Timestamp:
- 01/04/11 12:34:16 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/t2m_correction_ncdf.pro
r20 r28 6 6 ; t2m_correction_ncdf.pro 7 7 ; ======================= 8 ; 9 ; Mean correction for air temperature bias and correction for variability are 10 ; applied. 11 ; 12 ; :file:`${TROPFLUX_ID}/erai_t2m_19890101_20091231_oafluxgrid.nc` have been produced by :ref:`interp_erai_t2m_1989_2009.pro`. 13 ; It contains air temperature at 2 m height from ERA-I interpolated on OAFLUX grid. 14 ; 15 ; Corrected air temperature at 2 m height is written in 16 ; :file:`${TROPFLUX_OD}/TropFlux_t2m_19890101_20091231_v50.nc`. 8 17 ; 9 18 ; .. graphviz:: … … 14 23 ; ] 15 24 ; 16 ; file_t2m [shape=ellipse,fontname=Courier,label=" /Volumes/Iomega_HDD/TropFlux/input_uncor/erai_t2m_19890101_20091231_oafluxgrid.nc"];17 ; 18 ; ncfile [shape=ellipse,fontname=Courier,label=" /Volumes/Iomega_HDD/TropFlux/input_cor/full_cor/TropFlux_t2m_19890101_20091231_v20.nc"];25 ; file_t2m [shape=ellipse,fontname=Courier,label="${TROPFLUX_ID}/erai_t2m_19890101_20091231_oafluxgrid.nc"]; 26 ; 27 ; ncfile [shape=ellipse,fontname=Courier,label="${TROPFLUX_OD}/TropFlux_t2m_19890101_20091231_v50.nc"]; 19 28 ; 20 29 ; t2m_correction_ncdf [shape=box, … … 30 39 ; SEE ALSO 31 40 ; ======== 41 ; 42 ; :ref:`tropflux_profile.sh` 43 ; 44 ; :ref:`mooring_corrections` 45 ; 46 ; :ref:`interp_erai_t2m_1989_2009.pro` 32 47 ; 33 48 ; :func:`initncdf <saxo:initncdf>` … … 38 53 ; :func:`jul2date <saxo:jul2date>` 39 54 ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` 55 ; :func:`ncdf_getatt <saxo:ncdf_getatt>` 40 56 ; 41 57 ; EXAMPLES … … 49 65 ; ==== 50 66 ; 51 ; hard coded directory - usage of ${TROPFLUX_ID}67 ; make it work !! 52 68 ; 53 69 ; coding rules 70 ; 71 ; understand usage of jtt 72 ; 73 ; check time values 74 ; 75 ; hard coded time in module name and in output filename 76 ; 77 ; why v50 in filename output 78 ; 79 ; hard coded correction values 80 ; 81 ; check side effect of replacement of read_ncdf by ncdf_lec :: 82 ; 83 ; Probleme d'adequation entre les tailles du domaine nx*ny*jpt 350*60*1 et du tableau 350*60*7670 84 ; 85 ; 86 ; hard coded attributes 87 ; 88 ; CF conventions 89 ; 90 ; KNOWN ISSUES 91 ; ============ 92 ; 93 ; test of existence of fullfilename_msk not very efficient because 94 ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented 54 95 ; 55 96 ; EVOLUTIONS 56 97 ; ========== 57 98 ; 99 ; - fplod 20110104T093758Z aedon.locean-ipsl.upmc.fr (Darwin) 100 ; 101 ; * complete header 102 ; * replace /Volumes/Iomega_HDD/TropFlux/input_uncor/ by ${TROPFLUX_ID} 103 ; * replace /Volumes/Iomega_HDD/TropFlux/input_cor/full_cor/ by 104 ; ${TROPFLUX_OD} 105 ; * use :func:`ncdf_getatt <saxo:ncdf_getatt>` for attributes of lat and long 106 ; variables 107 ; * same problem of time axis and memory like in interp_erai_t2m_1989_2009 108 ; using read_ncdf. 109 ; replace read_ncdf by netcdf_lec 110 ; 58 111 ; - fplod 20101215T114503Z aedon.locean-ipsl.upmc.fr (Darwin) 59 112 ; … … 70 123 ;- 71 124 pro t2m_correction_ncdf 125 ; 72 126 @common 73 da1=19890101 & da2=20091231 74 75 file='/Volumes/Iomega_HDD/TropFlux/input_uncor/erai_t2m_19890101_20091231_oafluxgrid.nc' 76 initncdf, file 77 t2m=read_ncdf('t2m',da1,da2,file=file,/nostr) & t2m=t2m-273.15 127 ; check for input directory 128 ; 129 ; test if ${TROPFLUX_ID} defined 130 tropflux_id_env=GETENV('TROPFLUX_ID') 131 CASE tropflux_id_env OF 132 '' : BEGIN 133 msg = 'eee : ${TROPFLUX_ID} is not defined' 134 ras = report(msg) 135 STOP 136 END 137 ELSE: BEGIN 138 msg = 'iii : ${TROPFLUX_ID} is ' + tropflux_id_env 139 ras = report(msg) 140 END 141 ENDCASE 142 ; 143 iodirin = isadirectory(tropflux_id_env) 144 ; 145 ; existence and protection of ${TROPFLUX_ID} 146 IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN 147 msg = 'eee : the directory' + iodirin + ' is not accessible.' 148 ras = report(msg) 149 STOP 150 ENDIF 151 ; 152 ; build uncorrected t2 filename 153 da1=19890101 154 da2=20091231 155 filename_t2_uncor='erai_t2m_'+ string(da1,format='(i8.8)')+'_'+ string(da2,format='(i8.8)')+'_oafluxgrid.nc' 156 ; 157 ; check if this file exists 158 fullfilename_t2_uncor = isafile(iodirin + filename_t2_uncor, NEW=0, /MUST_EXIST) 159 IF fullfilename_t2_uncor[0] EQ '' THEN BEGIN 160 msg = 'eee : the file ' + fullfilename_t2_uncor + ' was not found.' 161 ras = report(msg) 162 STOP 163 ENDIF 164 ; test if ${TROPFLUX_OD} defined 165 tropflux_od_env=GETENV('TROPFLUX_OD') 166 CASE tropflux_od_env OF 167 '' : BEGIN 168 msg = 'eee : ${TROPFLUX_OD} is not defined' 169 ras = report(msg) 170 STOP 171 END 172 ELSE: BEGIN 173 msg = 'iii : ${TROPFLUX_OD} is ' + tropflux_od_env 174 ras = report(msg) 175 END 176 ENDCASE 177 ; 178 ; check if output data will be possible 179 iodirout = isadirectory(tropflux_od_env) 180 ; 181 ; existence and protection 182 IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN 183 msg = 'eee : the directory' + iodirout + ' was not found.' 184 ras = report(msg) 185 STOP 186 ENDIF 187 ; 188 ; build output filename 189 filename_out='TropFlux_t2m_'+ string(da1,format='(i8.8)')+'_'+ string(da2,format='(i8.8)')+'_v50.nc' 190 fullfilename_out = iodirout + filename_out 191 ; in order to avoid unexpected overwritten 192 IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 193 msg = 'eee : the file ' + fullfilename_out + ' already exists.' 194 ras = report(msg) 195 STOP 196 ENDIF 197 ; 198 ; define grid parameters with t2 file 199 initncdf, fullfilename_t2_uncor 200 ; 201 ; get time in t2 file 202 timein=ncdf_lec(fullfilename_t2_uncor,var='time') 203 jptin=n_elements(timein) 204 print, 'time steps from data ', jptin 205 print, 'The first 10 time values (variable timein) = ', timein[0:9] 206 ; 207 ; find first and last dates yyyymmdd 208 ; they will be written in global attributes of output file 209 da=jul2date(julday(01, 01, 1957,timein[0])) 210 cda0=string(da,format='(i8.8)') 211 da=jul2date(julday(01, 01, 1957,timein[jptin-1])) 212 cda1=string(da,format='(i8.8)') 213 print, 'first date ', cda0 214 print, 'last date ' , cda1 215 ; 216 ; read t2 data 217 t2m=ncdf_lec(fullfilename_t2_uncor,var='t2m') 218 ; 219 t2m=t2m-273.15 78 220 help, t2m 79 221 ; 222 jpt=jptin 80 223 t2m_mean=grossemoyenne(t2m,'t',/nan) 81 help, w_mean 82 83 tt=time & jpt=n_elements(time) 84 caldat, time,mon,day,yea 224 help, t2m_mean 225 85 226 t2m_m=t2m*0. 86 227 bias_cor=t2m*0. … … 89 230 ;; line fit -> -0.0741607x + 1.67601 ;; (2000-2009) 90 231 91 for jt=0,jpt-1 do begin 92 jtt=(time(jt)-julday(1,1,yea(jt))) < 364 232 for jt=0,jptin-1 do begin 233 caldat, julday(01, 01, 1957,timein[jt]),mon,day,yea 234 ;++print,day 235 jtt=(julday(01, 01, 1957,timein[jt])-julday(1,1,yea)) < 364 93 236 t=reform(t2m_mean(*,*)) 94 237 t2m_m(*,*,jt)=t … … 116 259 lat=reform(gphit(0,0:jpj-1)) 117 260 lon=reform(glamt(0:jpi-1,0)) 118 time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time) 119 120 cda0=string(jul2date(time(0)),format='(i8.8)') 121 cda1=string(jul2date(time(jpt-1)),format='(i8.8)') 122 123 time=time-julday(1,1,1950) & jpt=n_elements(time) 124 125 ;ncfile='!/Volumes/Iomega_HDD/TropFlux/input_cor/full_cor/TropFlux_t2m_19890101_20091231_v20.nc' 126 ncfile='!/Users/pkb/data/TropFlux/TropFlux_t2m_19890101_20091231_v50.nc' 127 lon_attr={units:'degrees_east',long_name:'Longitude'} 128 lat_attr={units:'degrees_north',long_name:'Latitude'} 261 cda0=string(da1) 262 cda1=string(da2) 263 264 time=time-julday(1,1,1950) 265 jpt=n_elements(time) 266 267 ncfile='!' + fullfilename_out 268 269 ncdf_getatt, fullfilename_t2_uncor, 'longitude', units=units 270 ncdf_getatt, fullfilename_t2_uncor, 'longitude', long_name=long_name 271 lon_attr={units:units, long_name:long_name} 272 ncdf_getatt, fullfilename_t2_uncor, 'latitude', units=units 273 ncdf_getatt, fullfilename_t2_uncor, 'latitude', long_name=long_name 274 lat_attr={units:units, long_name:long_name} 275 129 276 time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} 130 t2m_attr={units:'degK',missing_value:1.e20,long_name:'Air Temperature at 2m',short_name:'t2m',axis:'TYX'} 277 278 ncdf_getatt, fullfilename_t2_uncor, 't2m', units=units 279 ncdf_getatt, fullfilename_t2_uncor, 't2m', long_name=long_name 280 t2m_attr={units:units,missing_value:1.e20,long_name:long_name,short_name:'t2m',axis:'TYX'} 131 281 globattr={source:'Basic data obtained from ERAI. Mean correction for air temperautre bias and correction for variability are applied',timerange:cda0+' - '+cda1} 132 282
Note: See TracChangeset
for help on using the changeset viewer.