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