[6] | 1 | ;+ |
---|
| 2 | ; |
---|
[31] | 3 | ; .. _sst_correction_ncdf.pro: |
---|
[6] | 4 | ; |
---|
| 5 | ; ======================= |
---|
| 6 | ; sst_correction_ncdf.pro |
---|
| 7 | ; ======================= |
---|
| 8 | ; |
---|
[72] | 9 | ; Correction of sst on OAFLUX grid |
---|
| 10 | ; |
---|
[92] | 11 | ; :file:`${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc` |
---|
| 12 | ; containing |
---|
| 13 | ; ++ |
---|
| 14 | ; has been produced by |
---|
| 15 | ; :ref:`interp_erai_sst_1989_2009.pro`. |
---|
[72] | 16 | ; |
---|
[92] | 17 | ; Corrected sst on OAFLUX grid |
---|
| 18 | ; is written in |
---|
[72] | 19 | ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` |
---|
| 20 | ; if this file not already exists. |
---|
| 21 | ; |
---|
[92] | 22 | ; This output file |
---|
| 23 | ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` |
---|
[100] | 24 | ; will be used by |
---|
| 25 | ; :ref:`cronin_gustiness_ncdf.pro` |
---|
[92] | 26 | ; and |
---|
[72] | 27 | ; :ref:`TropFlux_19890101_20091231.pro`. |
---|
| 28 | ; |
---|
[93] | 29 | ; ; This output file |
---|
| 30 | ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` |
---|
| 31 | ; is one of the deliverable of TropFlux. |
---|
| 32 | ; |
---|
[92] | 33 | ; .. only:: man |
---|
| 34 | ; |
---|
| 35 | ; Figure is visible on PDF and HTML documents only. |
---|
| 36 | ; |
---|
| 37 | ; .. only:: html or latex |
---|
| 38 | ; |
---|
[9] | 39 | ; .. graphviz:: |
---|
| 40 | ; |
---|
| 41 | ; digraph sst_correction_ncdf { |
---|
| 42 | ; |
---|
[72] | 43 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc"]; |
---|
| 44 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"]; |
---|
[9] | 45 | ; |
---|
| 46 | ; sst_correction_ncdf [shape=box, |
---|
| 47 | ; fontname=Courier, |
---|
| 48 | ; color=blue, |
---|
| 49 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/sst_correction_ncdf.pro", |
---|
[50] | 50 | ; label="${PROJECT}/src/sst_correction_ncdf.pro"]; |
---|
[9] | 51 | ; |
---|
[72] | 52 | ; {file_in} -> {sst_correction_ncdf} -> {file_out} |
---|
[9] | 53 | ; |
---|
| 54 | ; } |
---|
| 55 | ; |
---|
[6] | 56 | ; SEE ALSO |
---|
| 57 | ; ======== |
---|
| 58 | ; |
---|
[72] | 59 | ; :ref:`project_profile.sh` |
---|
| 60 | ; |
---|
| 61 | ; :ref:`mooring_corrections` |
---|
| 62 | ; |
---|
| 63 | ; :ref:`interp_erai_sst_1989_2009.pro` |
---|
| 64 | ; |
---|
[20] | 65 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 66 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 67 | ; :func:`grossemoyenne <saxo:grossemoyenne>` |
---|
| 68 | ; :func:`julday <saxo:julday>` |
---|
| 69 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 70 | ; |
---|
[6] | 71 | ; EXAMPLES |
---|
| 72 | ; ======== |
---|
| 73 | ; |
---|
| 74 | ; :: |
---|
| 75 | ; |
---|
| 76 | ; IDL> sst_correction_ncdf |
---|
| 77 | ; |
---|
| 78 | ; TODO |
---|
| 79 | ; ==== |
---|
| 80 | ; |
---|
[93] | 81 | ; make it work on loholt1 idl8: |
---|
| 82 | ; reach end whtiout error but with bad values (9.96921e+36 on time and sst, nb timestep 5716 |
---|
| 83 | ; |
---|
| 84 | ; see commands:: |
---|
| 85 | ; |
---|
| 86 | ; ncks -v sst -d time,0,1 -d latitude,0,1 -d longitude,0,1 /homedata/pinsard/tropflux_d/TropFlux_sst_19890101_20091231.nc |
---|
| 87 | ; |
---|
[73] | 88 | ; very strange value of time on lohlot1 idl6 but not always and not always at the same indices !!:: |
---|
| 89 | ; |
---|
| 90 | ; print, time[7080:7090] |
---|
| 91 | ; 2454607.5 2454608.5 2454609.5 9.9692100e+36 9.9692100e+36 |
---|
| 92 | ; 9.9692100e+36 9.9692100e+36 9.9692100e+36 9.9692100e+36 2454616.5 |
---|
| 93 | ; 2454617.5 |
---|
[92] | 94 | ; |
---|
[73] | 95 | ; while :: |
---|
| 96 | ; |
---|
| 97 | ; $ ncks -H -C -v time -d time,7080,7090 ${PROJECT_ID}/20c3m_erai_sstk_TROP_1989_2009.nc |
---|
[92] | 98 | ; time[7080]=450432 |
---|
| 99 | ; time[7081]=450456 |
---|
| 100 | ; time[7082]=450480 |
---|
| 101 | ; time[7083]=450504 |
---|
| 102 | ; time[7084]=450528 |
---|
| 103 | ; time[7085]=450552 |
---|
| 104 | ; time[7086]=450576 |
---|
| 105 | ; time[7087]=450600 |
---|
| 106 | ; time[7088]=450624 |
---|
| 107 | ; time[7089]=450648 |
---|
| 108 | ; time[7090]=450672 |
---|
[73] | 109 | ; |
---|
[92] | 110 | ; and |
---|
| 111 | ; ncks -H -C -v time -d time,7080,7090 ${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc |
---|
| 112 | ; time[7080]=21325 |
---|
| 113 | ; time[7081]=21326 |
---|
| 114 | ; time[7082]=21327 |
---|
| 115 | ; time[7083]=9.96920996839e+36 |
---|
| 116 | ; time[7084]=9.96920996839e+36 |
---|
| 117 | ; time[7085]=9.96920996839e+36 |
---|
| 118 | ; time[7086]=9.96920996839e+36 |
---|
| 119 | ; time[7087]=9.96920996839e+36 |
---|
| 120 | ; time[7088]=9.96920996839e+36 |
---|
| 121 | ; time[7089]=21334 |
---|
| 122 | ; time[7090]=21335 |
---|
| 123 | ; |
---|
[73] | 124 | ; and :: |
---|
| 125 | ; |
---|
| 126 | ; fplod@cratos$ ncks -H -C -v time -d time,7080,7090 ${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc |
---|
[92] | 127 | ; time[7080]=21325 |
---|
| 128 | ; time[7081]=21326 |
---|
| 129 | ; time[7082]=21327 |
---|
| 130 | ; time[7083]=21328 |
---|
| 131 | ; time[7084]=21329 |
---|
| 132 | ; time[7085]=21330 |
---|
| 133 | ; time[7086]=21331 |
---|
| 134 | ; time[7087]=21332 |
---|
| 135 | ; time[7088]=21333 |
---|
| 136 | ; time[7089]=21334 |
---|
| 137 | ; time[7090]=21335 |
---|
[97] | 138 | ; |
---|
[6] | 139 | ; coding rules |
---|
| 140 | ; |
---|
[72] | 141 | ; temperature SI units = K : why + and - 273... |
---|
| 142 | ; |
---|
| 143 | ; hard coded coefficient correction. |
---|
| 144 | ; |
---|
| 145 | ; KNOWN ISSUES |
---|
| 146 | ; ============ |
---|
| 147 | ; |
---|
| 148 | ; test of existence of fullfilename_in not very efficient because |
---|
| 149 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 150 | ; |
---|
[6] | 151 | ; EVOLUTIONS |
---|
| 152 | ; ========== |
---|
| 153 | ; |
---|
[90] | 154 | ; $Id: sst_correction_ncdf.pro 88 2011-08-19 15:40:14Z pinsard $ |
---|
[85] | 155 | ; |
---|
| 156 | ; $URL$ |
---|
| 157 | ; |
---|
[72] | 158 | ; - fplod 20110808T124236Z cratos (Linux) |
---|
| 159 | ; |
---|
| 160 | ; * usage of ${PROJECT_OD} |
---|
| 161 | ; * complete description |
---|
| 162 | ; * remove v20 in output filename |
---|
| 163 | ; |
---|
[9] | 164 | ; - fplod 20101215T114224Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 165 | ; |
---|
| 166 | ; * add graph in header |
---|
| 167 | ; |
---|
[6] | 168 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 169 | ; |
---|
| 170 | ; * minimal header |
---|
| 171 | ; |
---|
| 172 | ; - pbk 2008 |
---|
| 173 | ; |
---|
| 174 | ; * creation |
---|
| 175 | ; |
---|
| 176 | ;- |
---|
[5] | 177 | pro sst_correction_ncdf |
---|
[72] | 178 | ; |
---|
| 179 | @cm_4cal |
---|
| 180 | @cm_4data |
---|
| 181 | @cm_4mesh |
---|
| 182 | @cm_4data |
---|
| 183 | @cm_project |
---|
| 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 for reading |
---|
| 202 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 203 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
| 204 | ras = report(msg) |
---|
| 205 | STOP |
---|
| 206 | ENDIF |
---|
| 207 | ; |
---|
| 208 | ; existence and protection for writing |
---|
| 209 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 210 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 211 | ras = report(msg) |
---|
| 212 | STOP |
---|
| 213 | ENDIF |
---|
| 214 | ; |
---|
[97] | 215 | da1=19880101 |
---|
[94] | 216 | da2=20091231 |
---|
[72] | 217 | ; |
---|
| 218 | ; build data filename |
---|
| 219 | filename='erai_sst_19890101_20091231_oafluxgrid.nc' |
---|
| 220 | ; |
---|
| 221 | ; check if this file exists |
---|
[92] | 222 | msg='iii : looking for ' + filename |
---|
| 223 | ras = report(msg) |
---|
[72] | 224 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
| 225 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
| 226 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 227 | ras = report(msg) |
---|
| 228 | STOP |
---|
| 229 | ENDIF |
---|
| 230 | ; |
---|
| 231 | ; build output filename |
---|
| 232 | filename_out = 'TropFlux_sst_19890101_20091231.nc' |
---|
| 233 | fullfilename_out = iodirout + filename_out |
---|
| 234 | ; in order to avoid unexpected overwritten |
---|
| 235 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 236 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 237 | ras = report(msg) |
---|
| 238 | STOP |
---|
| 239 | ENDIF |
---|
| 240 | ; |
---|
| 241 | initncdf, fullfilename |
---|
[97] | 242 | sst=read_ncdf('sst',da1,da2,file=fullfilename,/nostr) |
---|
[94] | 243 | sst=sst-273.15 |
---|
[5] | 244 | help, sst |
---|
[97] | 245 | ; |
---|
[5] | 246 | sst_mean=grossemoyenne(sst,'t',/nan) |
---|
| 247 | help, sst_mean |
---|
[97] | 248 | ; |
---|
[94] | 249 | jpt=n_elements(time) |
---|
[5] | 250 | caldat, time,mon,day,yea |
---|
[92] | 251 | ; |
---|
[73] | 252 | ; debug to understand some time value 9.9692100e+36 on idl 6 lohloht1 |
---|
| 253 | print, time[7080:7090] |
---|
| 254 | ; |
---|
[5] | 255 | sst_m=sst*0. |
---|
[97] | 256 | ; |
---|
[5] | 257 | for jt=0,jpt-1 do begin |
---|
| 258 | jtt=(time(jt)-julday(1,1,yea(jt))) < 364 |
---|
| 259 | t=reform(sst_mean(*,*)) |
---|
| 260 | sst_m(*,*,jt)=t |
---|
| 261 | endfor |
---|
| 262 | help, sst_m |
---|
[97] | 263 | ; |
---|
[5] | 264 | sst_ano=sst-sst_m |
---|
[97] | 265 | ; |
---|
| 266 | ; correction for mean based on scatter |
---|
| 267 | ;sst_m=sst_m+0.0521111 ; (2000-2008) |
---|
| 268 | sst_m=sst_m+0.0533692 ; (2000-2009) |
---|
| 269 | ; |
---|
[5] | 270 | help, sst_ano |
---|
[97] | 271 | ; |
---|
| 272 | ; applying the correction for varyability based on the scatter |
---|
| 273 | ;sst_ano=sst_ano*(1/0.989889) ; (2000-2008) |
---|
| 274 | sst_ano=sst_ano*(1/0.986196) ; (2000-2009) |
---|
| 275 | ; |
---|
[5] | 276 | sst_new=sst_m+sst_ano+273.15 |
---|
| 277 | help, sst_new |
---|
[97] | 278 | ; |
---|
[5] | 279 | ;writing field |
---|
| 280 | lat=reform(gphit(0,0:jpj-1)) |
---|
| 281 | lon=reform(glamt(0:jpi-1,0)) |
---|
[100] | 282 | time=timegen(7670, start=julday(1,1,1989,0), units='days') |
---|
[94] | 283 | jpt=n_elements(time) |
---|
[97] | 284 | ; |
---|
[5] | 285 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 286 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
[97] | 287 | ; |
---|
| 288 | time=time-julday(1,1,1950) |
---|
[94] | 289 | jpt=n_elements(time) |
---|
[97] | 290 | ; |
---|
[72] | 291 | ncfile='!' + fullfilename_out |
---|
[5] | 292 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 293 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
| 294 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
[100] | 295 | globattr={source:'Basic data obtained from ERAI. Bias and variability correction are applied',timerange:cda0+' - '+cda1} |
---|
[5] | 296 | sst_attr={units:'degK',missing_value:1.e20,long_name:'Sea Surface Temperature',short_name:'sst',axis:'TYX'} |
---|
[97] | 297 | ; |
---|
[5] | 298 | ncfields = 'sst[longitude,latitude,time]=sst_new:sst_attr; ' $ |
---|
| 299 | + 'longitude[]=lon:lon_attr; ' $ |
---|
| 300 | + 'latitude[]=lat:lat_attr; ' $ |
---|
| 301 | + 'time[*time]=time:time_attr ' $ |
---|
| 302 | + ' @ globattr' |
---|
[97] | 303 | ; |
---|
[5] | 304 | @ncdf_quickwrite |
---|
[97] | 305 | ; |
---|
[5] | 306 | end |
---|