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