;+ ; ; =================== ; tropflux_swr_dt.pro ; =================== ; ; .. function:: tropflux_swr_dt(yyyymmddb,yyyymmdde) ; ; DESCRIPTION ; =========== ; ; Correction of swr delay time on OAFLUX grid ; ; :file:`${PROJECT_OD}/swr_oafluxgrid_1985_2007.nc` ; have been produced ++by pk ; ; Corrected swr delay on OAFLUX grid ; is written in ; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc` ; if this file not already exists. ; ; .. graphviz:: ; ; digraph tropflux_swr_dt { ; ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/swr_oafluxgrid_1985_2007.nc"]; ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc"]; ; ; tropflux_swr_dt [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/tropflux_swr_dt.pro", ; label="${PROJECT}/src/tropflux_swr_dt.pro"]; ; ; {file_in}-> {tropflux_swr_dt} -> {file_out} ; ; } ; ; SEE ALSO ; ======== ; ; :ref:`mooring_corrections` ; ; Used by :ref:`tropflux.sh` ; ; :ref:`project_profile.sh` ; ; :ref:`data_in_swr` ; ; :func:`initncdf ` ; :func:`read_ncdf ` ; :func:`grossemoyenne ` ; :func:`julday ` ; :func:`caldat ` ; :func:`ncdf_quickwrite ` ; ; EXAMPLES ; ======== ; ; .. code-block:: idl ; ; yyyymmddb = 20000101L ; yyyymmdde = 20001231L ; result = tropflux_swr_dt(yyyymmddb, yyyymmdde) ; print, result ; ; TODO ; ==== ; ; handle yyyymmdde > 20071231 ; ; first date 19991231 vs yyyymmddb = 20000101L ; ; NaNf values in output file while 1.e20 in input file !! ; ; coding rules ; ; use the output of concat_swr.sh to be written. ; now use swr_oafluxgrid_1985_2007.nc provided by pk 20110811 ; stored in :file:`cratos:/usr/lodyc/incas/fplod/tropflux_d/from_pk/stage_0/swr_oafluxgrid_1985_2007.nc` ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; EVOLUTIONS ; ========== ; ; $Id: tropflux_swr_dt.pro 88 2011-08-19 15:40:14Z pinsard $ ; ; $URL$ ; ; - fplod 20120321 ; ; * pro -> func ; * rename with lower case TropFlux_swr_DT_19890101_20071231.pro become ; tropflux_swr_dt.pro ; * taking project_overwrite into account ; * try to add compile_opt seems to be incompatible with ncdf_quickwrite ; * start to homogenize time handling and netcdf writing ; ; - fplod 20110830T135743Z cratos (Linux) ; ; * replace tt by time ; ; - fplod 20110812T073138Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * usage of ${PROJECT_OD} ; * complete description ; * remove v50 in output filename ; ; - fplod 20101215T091726Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph in header ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- function tropflux_swr_dt $ , yyyymmddb $ , yyyymmdde ; ;++compile_opt idl2, strictarrsubs, logical_predicate ; @cm_4cal @cm_4data @cm_4mesh @cm_4data @cm_project ; ; Return to caller if errors ON_ERROR, 2 ; result = -1 ; usage = 'result = tropflux_swr_dt(yyyymmddb, yyyymmdde)' nparam = N_PARAMS() IF (nparam NE 2) THEN BEGIN ras = report(['Incorrect number of arguments.' $ + '!C' $ + 'Usage : ' + usage]) return, result ENDIF ; test if ${PROJECT_OD} defined CASE project_od_env OF '' : BEGIN msg = 'eee : ${PROJECT_OD} is not defined' ras = report(msg) return, result 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) return, result 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) return, result ENDIF ; ; build data filename filename='swr_oafluxgrid_1985_2007.nc' ; ; check if this file exists msg='iii : looking for ' + filename ras = report(msg) 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) return, result ENDIF ; ; build output filename filename_out = 'TropFlux_swr_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_DT.nc' fullfilename_out = iodirout + filename_out ; in order to avoid unexpected overwritten IF ((FILE_TEST(fullfilename_out) EQ 1) AND (project_overwrite EQ 0)) THEN BEGIN msg = 'eee : the file ' + fullfilename_out + ' already exists.' ras = report(msg) return, result ENDIF ; initncdf, filename ; sw=read_ncdf("swr", yyyymmddb-.5d,yyyymmdde, file=filename,/nostr) timein=24.d*(time-julday(1,1,1957,0,0,0)) jptin=n_elements(timein) da=jul2date(time[0]) cda0=string(da,format='(i8.8)') da=jul2date(time[jptin-1]) cda1=string(da,format='(i8.8)') print, 'first date ', cda0 print, 'last date ' , cda1 help, sw ; sw_mean=grossemoyenne(sw, 't',/nan) help, sw_mean ; jpt=n_elements(time) caldat, time,mon,day,yea sw_m=sw*0. sw_bias=sw*0. ; for jt=0,jpt-1 do begin jtt=(time[jt]-julday(1,1,yea[jt])) < 364 swr=reform(sw_mean[*,*]) sw_m[*,*,jt]=swr sw_bias[*,*,jt]=(((swr-295.4)*18.36/(200.-295.4)) > 0.) < 18.37 endfor ; help, sw_m, sw_bias swa=sw-sw_m swa=swa/(0.901273) ; variability correction (seasonal_cycle_swr_isccp.pro) ; swr=sw_m+swa-sw_bias ; new swr, corrected for bias and variability ; ; writing field cda0=string(jul2date(time[0]),format='(i8.8)') cda1=string(jul2date(time[jpt-1]),format='(i8.8)') ; lat=reform(gphit[0,0:jpj-1]) lon=reform(glamt[0:jpi-1,0]) 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'} globattr={source:'Obtained from ISCCP. Corrections has been done on mean bias and variability',timerange:cda0+' - '+cda1} sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'} ; ncfields = 'swr[longitude,latitude,*time]=swr:sw_attr; ' $ + 'longitude[]=lon:lon_attr; ' $ + 'latitude[]=lat:lat_attr; ' $ + 'time[]=timein:time_attr ' $ + ' @ globattr' ; @ncdf_quickwrite ; result = 0 return, result ; end