[6] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; .. _interp_erai_dewt_1989_2009.pro: |
---|
| 4 | ; |
---|
[67] | 5 | ; ============================== |
---|
[70] | 6 | ; interp_erai_dewt_1989_2009.pro |
---|
[67] | 7 | ; ============================== |
---|
[6] | 8 | ; |
---|
[67] | 9 | ; DESCRIPTION |
---|
| 10 | ; =========== |
---|
| 11 | ; |
---|
[66] | 12 | ; Interpolation of d2 from ERA-I grid to OAFLUX grid |
---|
[6] | 13 | ; |
---|
[92] | 14 | ; :file:`${PROJECT_ID}/20c3m_erai_d2_TROP_1989_2009.nc` |
---|
| 15 | ; containing |
---|
| 16 | ; d2 from ERA-I |
---|
[93] | 17 | ; has been produced by |
---|
[92] | 18 | ; :ref:`compute_erai_daily_region_2d.sh`. |
---|
[66] | 19 | ; |
---|
[92] | 20 | ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` |
---|
| 21 | ; containing OAFLUX grid |
---|
[93] | 22 | ; has been produced by |
---|
[92] | 23 | ; :ref:`oaflux_mask_30N30S.pro`. |
---|
[66] | 24 | ; |
---|
[92] | 25 | ; Interpolated d2 |
---|
| 26 | ; is written in |
---|
| 27 | ; :file:`${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc` |
---|
| 28 | ; if this file not already exists. |
---|
[66] | 29 | ; |
---|
[92] | 30 | ; This output file |
---|
| 31 | ; :file:`${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc` |
---|
| 32 | ; must be processed after by |
---|
| 33 | ; :ref:`d2m_to_q2m_erai.pro`. |
---|
[66] | 34 | ; |
---|
[92] | 35 | ; .. only:: man |
---|
| 36 | ; |
---|
| 37 | ; Figure is visible on PDF and HTML documents only. |
---|
| 38 | ; |
---|
| 39 | ; .. only:: html or latex |
---|
| 40 | ; |
---|
[8] | 41 | ; .. graphviz:: |
---|
| 42 | ; |
---|
| 43 | ; digraph interp_erai_dewt_1989_2009 { |
---|
[71] | 44 | ; |
---|
[66] | 45 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_d2_TROP_1989_2009.nc"]; |
---|
[50] | 46 | ; mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; |
---|
[71] | 47 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc"]; |
---|
[8] | 48 | ; |
---|
| 49 | ; interp_erai_dewt_1989_2009 [shape=box, |
---|
| 50 | ; fontname=Courier, |
---|
| 51 | ; color=blue, |
---|
| 52 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_dewt_1989_2009.pro", |
---|
[50] | 53 | ; label="${PROJECT}/src/interp_erai_dewt_1989_2009.pro"]; |
---|
[8] | 54 | ; |
---|
| 55 | ; {file_in mask} -> {interp_erai_dewt_1989_2009} -> {file_out} |
---|
| 56 | ; |
---|
[71] | 57 | ; } |
---|
[8] | 58 | ; |
---|
[6] | 59 | ; SEE ALSO |
---|
| 60 | ; ======== |
---|
| 61 | ; |
---|
[92] | 62 | ; :ref:`interpolate_data` |
---|
| 63 | ; |
---|
[50] | 64 | ; :ref:`project_profile.sh` |
---|
[19] | 65 | ; |
---|
[20] | 66 | ; :func:`report <saxo:report>` |
---|
| 67 | ; :func:`isadirectory <saxo:isadirectory>` |
---|
| 68 | ; :func:`isafile <saxo:isafile>` |
---|
| 69 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 70 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 71 | ; :func:`domdef <saxo:domdef>` |
---|
| 72 | ; :func:`call_interp2d <saxo:call_interp2d>` |
---|
| 73 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 74 | ; |
---|
[67] | 75 | ; :ref:`d2m_to_q2m_erai.pro` |
---|
[66] | 76 | ; |
---|
[6] | 77 | ; EXAMPLES |
---|
| 78 | ; ======== |
---|
| 79 | ; |
---|
| 80 | ; :: |
---|
| 81 | ; |
---|
[66] | 82 | ; IDL> .compile file_interp |
---|
[6] | 83 | ; IDL> interp_erai_dewt_1989_2009 |
---|
| 84 | ; |
---|
[93] | 85 | ; TIPS |
---|
[6] | 86 | ; ==== |
---|
| 87 | ; |
---|
[93] | 88 | ; To see some values of variable :: |
---|
[6] | 89 | ; |
---|
[92] | 90 | ; $ ncks -v d2m -d time,0,1 -d latitude,0,1 -d longitude,0,1 \ |
---|
| 91 | ; $PROJECT_ID/erai_d2m_19890101_200 1231_oafluxgrid.nc |
---|
| 92 | ; |
---|
[93] | 93 | ; TODO |
---|
| 94 | ; ==== |
---|
[92] | 95 | ; |
---|
[70] | 96 | ; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call |
---|
| 97 | ; |
---|
| 98 | ; use real output of :ref:`compute_erai_daily_region_2d.sh`. |
---|
| 99 | ; |
---|
[6] | 100 | ; coding rules |
---|
| 101 | ; |
---|
[19] | 102 | ; KNOWN ISSUES |
---|
| 103 | ; ============ |
---|
| 104 | ; |
---|
| 105 | ; test of existence of fullfilename_msk not very efficient because |
---|
| 106 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 107 | ; |
---|
[6] | 108 | ; EVOLUTIONS |
---|
| 109 | ; ========== |
---|
| 110 | ; |
---|
[66] | 111 | ; $Id$ |
---|
| 112 | ; |
---|
[88] | 113 | ; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_dewt_1989_2009.pro $ |
---|
[66] | 114 | ; |
---|
[92] | 115 | ; - pinsard 2011-08-23T09:09:16Z loholt1.ipsl.polytechnique.fr (Linux) |
---|
| 116 | ; |
---|
| 117 | ; * retry on loholt1 with idl8 and idl6 |
---|
| 118 | ; |
---|
[70] | 119 | ; - fplod 20110808T094156Z cratos (Linux) |
---|
| 120 | ; |
---|
| 121 | ; * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call |
---|
| 122 | ; |
---|
[66] | 123 | ; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux) |
---|
| 124 | ; |
---|
| 125 | ; * usage of $PROJECT_ID and $PROJECT_OD |
---|
| 126 | ; |
---|
[19] | 127 | ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 128 | ; |
---|
| 129 | ; * remove hard coded directory for mask_oaflux_30N30S.nc |
---|
| 130 | ; |
---|
[8] | 131 | ; - fplod 20101215T093710Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 132 | ; |
---|
| 133 | ; * add graph in header |
---|
| 134 | ; |
---|
[6] | 135 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 136 | ; |
---|
| 137 | ; * minimal header |
---|
| 138 | ; |
---|
| 139 | ; - pbk 2008 |
---|
| 140 | ; |
---|
| 141 | ; * creation |
---|
| 142 | ; |
---|
| 143 | ;- |
---|
[5] | 144 | pro interp_erai_dewt_1989_2009 |
---|
[66] | 145 | ; |
---|
| 146 | @cm_4cal |
---|
| 147 | @cm_4data |
---|
| 148 | @cm_4mesh |
---|
| 149 | @cm_4data |
---|
[50] | 150 | @cm_project |
---|
[19] | 151 | ; |
---|
[66] | 152 | ; check for input directory |
---|
[19] | 153 | ; |
---|
[50] | 154 | ; test if ${PROJECT_ID} defined |
---|
| 155 | CASE project_id_env OF |
---|
[19] | 156 | '' : BEGIN |
---|
[50] | 157 | msg = 'eee : ${PROJECT_ID} is not defined' |
---|
[19] | 158 | ras = report(msg) |
---|
| 159 | STOP |
---|
| 160 | END |
---|
| 161 | ELSE: BEGIN |
---|
[50] | 162 | msg = 'iii : ${PROJECT_ID} is ' + project_id_env |
---|
[19] | 163 | ras = report(msg) |
---|
| 164 | END |
---|
| 165 | ENDCASE |
---|
| 166 | ; |
---|
[50] | 167 | iodirin = isadirectory(project_id_env) |
---|
[19] | 168 | ; |
---|
[50] | 169 | ; existence and protection of ${PROJECT_ID} |
---|
[19] | 170 | IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 171 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
| 172 | ras = report(msg) |
---|
| 173 | STOP |
---|
| 174 | ENDIF |
---|
| 175 | ; |
---|
| 176 | ; build mask filename |
---|
| 177 | filename_msk='mask_oaflux_30N30S.nc' |
---|
| 178 | ; |
---|
| 179 | ; check if this file exists |
---|
[92] | 180 | msg='iii : looking for ' + filename_msk |
---|
| 181 | ras = report(msg) |
---|
[19] | 182 | fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST) |
---|
| 183 | IF fullfilename_msk[0] EQ '' THEN BEGIN |
---|
| 184 | msg = 'eee : the file ' + fullfilename_msk + ' was not found.' |
---|
| 185 | ras = report(msg) |
---|
| 186 | STOP |
---|
| 187 | ENDIF |
---|
| 188 | ; |
---|
[66] | 189 | ; build data filename |
---|
| 190 | filename='20c3m_erai_d2_TROP_1989_2009.nc' |
---|
[71] | 191 | ; |
---|
| 192 | ; check if this file exists |
---|
[92] | 193 | msg='iii : looking for ' + filename |
---|
| 194 | ras = report(msg) |
---|
[66] | 195 | fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST) |
---|
| 196 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
| 197 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 198 | ras = report(msg) |
---|
| 199 | STOP |
---|
| 200 | ENDIF |
---|
| 201 | ; |
---|
| 202 | ; test if ${PROJECT_OD} defined |
---|
| 203 | CASE project_od_env OF |
---|
| 204 | '' : BEGIN |
---|
| 205 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 206 | ras = report(msg) |
---|
| 207 | STOP |
---|
| 208 | END |
---|
| 209 | ELSE: BEGIN |
---|
| 210 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 211 | ras = report(msg) |
---|
| 212 | END |
---|
| 213 | ENDCASE |
---|
| 214 | ; |
---|
| 215 | ; check if output data will be possible |
---|
| 216 | iodirout = isadirectory(project_od_env) |
---|
| 217 | ; |
---|
| 218 | ; existence and protection |
---|
| 219 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 220 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 221 | ras = report(msg) |
---|
| 222 | STOP |
---|
| 223 | ENDIF |
---|
| 224 | ; |
---|
| 225 | ; build output filename |
---|
| 226 | filename_out = 'erai_d2m_19890101_20091231_oafluxgrid.nc' |
---|
| 227 | fullfilename_out = iodirout + filename_out |
---|
| 228 | ; in order to avoid unexpected overwritten |
---|
| 229 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 230 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 231 | ras = report(msg) |
---|
| 232 | STOP |
---|
| 233 | ENDIF |
---|
| 234 | ; |
---|
| 235 | initncdf, fullfilename |
---|
[5] | 236 | domdef |
---|
[97] | 237 | latin=reform(gphit(0,*)) |
---|
[94] | 238 | lonin=reform(glamt(*,0)) |
---|
[5] | 239 | print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0) |
---|
| 240 | print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0) |
---|
[66] | 241 | d2min=read_ncdf("d2",19881201,20101231,file=fullfilename,/nostr) |
---|
[97] | 242 | ; |
---|
[94] | 243 | jptin=jpt |
---|
[5] | 244 | tab=d2min(*,*,0) |
---|
| 245 | mskin=glamt*0.+1. |
---|
[97] | 246 | ; |
---|
[19] | 247 | initncdf, fullfilename_msk |
---|
[5] | 248 | domdef |
---|
[94] | 249 | latout=reform(gphit(0,*)) |
---|
| 250 | lonout=reform(glamt(*,0)) |
---|
[5] | 251 | print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0) |
---|
| 252 | print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0) |
---|
[19] | 253 | mskout=read_ncdf("msk", file=fullfilename_msk,/nostr) |
---|
[97] | 254 | ; |
---|
[5] | 255 | help, d2min,lonin,latin,mskin,lonout,latout,mskout |
---|
[97] | 256 | ; |
---|
[5] | 257 | d2mout=fltarr(jpi,jpj,jptin) |
---|
| 258 | for jt=0,jptin-1 do begin |
---|
[92] | 259 | ; ++ print, 'Interpolation jt=',jt,' / ',jptin-1 |
---|
[5] | 260 | tab=reform(d2min(*,*,jt)) |
---|
[70] | 261 | d2mout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $ |
---|
| 262 | , lonout,latout,method='bilinear' $ |
---|
| 263 | , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) |
---|
[5] | 264 | d2mout(*,*,jt)=d2mout(*,*,jt)*mskout+(1.-mskout)*1.e20 |
---|
| 265 | endfor |
---|
[97] | 266 | ; |
---|
[19] | 267 | initncdf, fullfilename_msk |
---|
[97] | 268 | ; |
---|
[100] | 269 | time=timegen(7670, start=julday(1,1,1989,0), units='days') |
---|
[94] | 270 | jpt=n_elements(time) |
---|
[5] | 271 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 272 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
[100] | 273 | time=time-julday(1,1,1950,00,00) |
---|
[97] | 274 | ; |
---|
[5] | 275 | lat=latout |
---|
| 276 | lon=lonout |
---|
[66] | 277 | ncfile='!' + fullfilename_out |
---|
[5] | 278 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 279 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
[100] | 280 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
| 281 | globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1} |
---|
[5] | 282 | d2m_attr={units:'degK',missing_value:1e20,long_name:'Dew Point Temperature at 2m',short_name:'d2m',axis:'TYX'} |
---|
[97] | 283 | ; |
---|
[5] | 284 | ncfields = 'd2m[longitude,latitude,time]=d2mout:d2m_attr; ' $ |
---|
| 285 | + 'longitude[]=lon:lon_attr; ' $ |
---|
| 286 | + 'latitude[]=lat:lat_attr; ' $ |
---|
[100] | 287 | + 'time[*time]=time:time_attr ' $ |
---|
[5] | 288 | + ' @ globattr' |
---|
[97] | 289 | ; |
---|
[5] | 290 | @ncdf_quickwrite |
---|
[97] | 291 | ; |
---|
[5] | 292 | end |
---|