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