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