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