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