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