;+ ; ; .. _sst_correction_ncdf.pro: ; ; ======================= ; sst_correction_ncdf.pro ; ======================= ; ; Correction of sst on OAFLUX grid ; ; :file:`${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc` have been ; produced by :ref:`interp_erai_sst_1989_2009.pro`. ; ; Corrected sst on OAFLUX grid is written in ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` ; if this file not already exists. ; ; This file will be used by :ref:`cronin_gustiness_ncdf.pro` and ; :ref:`TropFlux_19890101_20091231.pro`. ; ; .. graphviz:: ; ; digraph sst_correction_ncdf { ; graph [ ; rankdir="LR", ; ] ; ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc"]; ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"]; ; ; sst_correction_ncdf [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/sst_correction_ncdf.pro", ; label="${PROJECT}/src/sst_correction_ncdf.pro"]; ; ; {file_in} -> {sst_correction_ncdf} -> {file_out} ; ; } ; ; ; SEE ALSO ; ======== ; ; :ref:`project_profile.sh` ; ; :ref:`mooring_corrections` ; ; :ref:`interp_erai_sst_1989_2009.pro` ; ; :func:`initncdf ` ; :func:`read_ncdf ` ; :func:`grossemoyenne ` ; :func:`julday ` ; :func:`ncdf_quickwrite ` ; ; EXAMPLES ; ======== ; ; :: ; ; IDL> sst_correction_ncdf ; ; TODO ; ==== ; ; very strange value of time on lohlot1 idl6 but not always and not always at the same indices !!:: ; ; print, time[7080:7090] ; 2454607.5 2454608.5 2454609.5 9.9692100e+36 9.9692100e+36 ; 9.9692100e+36 9.9692100e+36 9.9692100e+36 9.9692100e+36 2454616.5 ; 2454617.5 ; ; while :: ; ; $ ncks -H -C -v time -d time,7080,7090 ${PROJECT_ID}/20c3m_erai_sstk_TROP_1989_2009.nc ; time[7080]=450432 ; time[7081]=450456 ; time[7082]=450480 ; time[7083]=450504 ; time[7084]=450528 ; time[7085]=450552 ; time[7086]=450576 ; time[7087]=450600 ; time[7088]=450624 ; time[7089]=450648 ; time[7090]=450672 ; ; and ; ncks -H -C -v time -d time,7080,7090 ${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc ; time[7080]=21325 ; time[7081]=21326 ; time[7082]=21327 ; time[7083]=9.96920996839e+36 ; time[7084]=9.96920996839e+36 ; time[7085]=9.96920996839e+36 ; time[7086]=9.96920996839e+36 ; time[7087]=9.96920996839e+36 ; time[7088]=9.96920996839e+36 ; time[7089]=21334 ; time[7090]=21335 ; ; and :: ; ; fplod@cratos$ ncks -H -C -v time -d time,7080,7090 ${PROJECT_OD}/erai_sst_19890101_20091231_oafluxgrid.nc ; time[7080]=21325 ; time[7081]=21326 ; time[7082]=21327 ; time[7083]=21328 ; time[7084]=21329 ; time[7085]=21330 ; time[7086]=21331 ; time[7087]=21332 ; time[7088]=21333 ; time[7089]=21334 ; time[7090]=21335 ; coding rules ; ; temperature SI units = K : why + and - 273... ; ; hard coded coefficient correction. ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename_in not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; EVOLUTIONS ; ========== ; ; - fplod 20110808T124236Z cratos (Linux) ; ; * usage of ${PROJECT_OD} ; * complete description ; * remove v20 in output filename ; ; - fplod 20101215T114224Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph in header ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- pro sst_correction_ncdf ; @cm_4cal @cm_4data @cm_4mesh @cm_4data @cm_project ; ; test if ${PROJECT_OD} defined CASE project_od_env OF '' : BEGIN msg = 'eee : ${PROJECT_OD} is not defined' ras = report(msg) STOP END ELSE: BEGIN msg = 'iii : ${PROJECT_OD} is ' + project_od_env ras = report(msg) END ENDCASE ; ; check if output data will be possible iodirout = isadirectory(project_od_env) ; ; existence and protection for reading IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirout + ' is not accessible.' ras = report(msg) STOP ENDIF ; ; existence and protection for writing IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirout + ' was not found.' ras = report(msg) STOP ENDIF ; da1=19880101 & da2=20091231 ; ; build data filename filename='erai_sst_19890101_20091231_oafluxgrid.nc' ; ; check if this file exists fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) IF fullfilename[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename + ' was not found.' ras = report(msg) STOP ENDIF ; ; build output filename filename_out = 'TropFlux_sst_19890101_20091231.nc' fullfilename_out = iodirout + filename_out ; in order to avoid unexpected overwritten IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN msg = 'eee : the file ' + fullfilename_out + ' already exists.' ras = report(msg) STOP ENDIF ; initncdf, fullfilename sst=read_ncdf('sst',da1,da2,file=fullfilename,/nostr) & sst=sst-273.15 help, sst sst_mean=grossemoyenne(sst,'t',/nan) help, sst_mean tt=time & jpt=n_elements(time) caldat, time,mon,day,yea ; ; debug to understand some time value 9.9692100e+36 on idl 6 lohloht1 print, time[7080:7090] ; sst_m=sst*0. for jt=0,jpt-1 do begin jtt=(time(jt)-julday(1,1,yea(jt))) < 364 t=reform(sst_mean(*,*)) sst_m(*,*,jt)=t endfor help, sst_m sst_ano=sst-sst_m ;; correction for mean based on scatter ;sst_m=sst_m+0.0521111 ;; (2000-2008) sst_m=sst_m+0.0533692 ;; (2000-2009) help, sst_ano ;; applying the correction for varyability based on the scatter ;sst_ano=sst_ano*(1/0.989889) ;; (2000-2008) sst_ano=sst_ano*(1/0.986196) ;; (2000-2009) sst_new=sst_m+sst_ano+273.15 help, sst_new ;writing field lat=reform(gphit(0,0:jpj-1)) lon=reform(glamt(0:jpi-1,0)) time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time) cda0=string(jul2date(time(0)),format='(i8.8)') cda1=string(jul2date(time(jpt-1)),format='(i8.8)') time=time-julday(1,1,1950) & jpt=n_elements(time) ncfile='!' + fullfilename_out lon_attr={units:'degrees_east',long_name:'Longitude'} lat_attr={units:'degrees_north',long_name:'Latitude'} time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} sst_attr={units:'degK',missing_value:1.e20,long_name:'Sea Surface Temperature',short_name:'sst',axis:'TYX'} globattr={source:'Basic data obtained from ERAI. Bias and variability correction are applied',timerange:cda0+' - '+cda1} ncfields = 'sst[longitude,latitude,time]=sst_new:sst_attr; ' $ + 'longitude[]=lon:lon_attr; ' $ + 'latitude[]=lat:lat_attr; ' $ + 'time[*time]=time:time_attr ' $ + ' @ globattr' @ncdf_quickwrite end