;+ ; ; ===================== ; tropflux_nrt_ncdf.pro ; ===================== ; ; .. function:: tropflux_nrt_ncdf(yyyymmddb, yyyymmdde) ; ; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc` ; containing ; ws corrected on OAFLUX grid ; has been produced by ; :func:`tropflux_swr_blnd`. ; ; :file:`${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc` ; containing ; lwr corrected on OAFLUX grid ; has been produced by ; :func:`lwr_correction_ncdf`. ; ; :file:`${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coare3.nc` ; containing ; ++ ; has been produced by ; :func:`tropflux`. ; ; ++ are written ; in :file:`${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}.nc` ; if this file not already exists. ; ; .. graphviz:: ; ; digraph tropflux_nrt_ncdf { ; ; file_swr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc"]; ; file_lwr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_{yyyymmdd}_{yyyymmdd}.nc"]; ; file_coare [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}_coarev3.nc"]; ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_{yyyymmdd}_{yyyymmdd}.nc"]; ; ; tropflux_nrt_ncdf [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/tropflux_nrt_ncdf.pro", ; label="${PROJECT}/src/tropflux_nrt_ncdf.pro" ]; ; ; {file_swr file_lwr file_coare} -> {tropflux_nrt_ncdf} -> {file_out} ; ; } ; ; SEE ALSO ; ======== ; ; Used by :ref:`tropflux.sh` ; ; :ref:`project_profile.sh` ; ; :func:`initncdf ` ; :func:`read_ncdf ` ; :func:`julday ` ; :func:`jul2date ` ; :func:`ncdf_quickwrite ` ; ; EXAMPLES ; ======== ; ; .. code-block:: idl ; ; yyyymmddb = 20000101L ; yyyymmdde = 20001231L ; result = tropflux_nrt_ncdf(yyyymmddb, yyyymmdde) ; print, result ; ; TODO ; ==== ; ; handle yyyymmdde > 20071231 see attributes also ; ; coding rules ; ; create 4 files instead of one now ; ; EVOLUTIONS ; ========== ; ; $Id: tropflux_nrt_ncdf.pro 88 2011-08-19 15:40:14Z pinsard $ ; ; $URL$ ; ; - fplod 20120326 ; ; * pro -> func ; * rename with lower case TropFlux_NRT_ncdf.pro become tropflux_nrt_ncdf.pro ; * taking project_overwrite into account ; * try to add compile_opt seems to be incompatible with ncdf_quickwrite ; * hard coded st and en replaced by yyyymmddb and yyyymmdde parameters ; * get rid of timegen ; ; - fplod 20110809T133815Z cratos (Linux) ; ; * remove v50 from pro name and in the graph ; * add coarev3 to the file coming from TropFlux_19890101_20091231.pro ; * use $PROJECT_OD ; ; - fplod 20101214T112526Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- function tropflux_nrt_ncdf $ , 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 SWR blnd data filename filename_swr_blnd="TropFlux_swr_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_BLND.nc" ; ; check if this file exists msg='iii : looking for ' + filename_swr_blnd ras = report(msg) fullfilename_swr_blnd = isafile(iodirout + filename_swr_blnd, NEW=0, /MUST_EXIST) IF fullfilename_swr_blnd[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_swr_blnd + ' was not found.' ras = report(msg) return, result ENDIF ; ; build LWR data filename filename_lwr="TropFlux_lwr_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc" ; ; check if this file exists msg='iii : looking for ' + filename_lwr ras = report(msg) fullfilename_lwr = isafile(iodirout + filename_lwr, NEW=0, /MUST_EXIST) IF fullfilename_lwr[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_lwr + ' was not found.' ras = report(msg) return, result ENDIF ; ; build COARE data filename filename_coare="TropFlux_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_coarev3.nc" ; ; check if this file exists msg='iii : looking for ' + filename_lwr ras = report(msg) fullfilename_coare = isafile(iodirout + filename_coare, NEW=0, /MUST_EXIST) IF fullfilename_coare[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_coare + ' was not found.' ras = report(msg) return, result ENDIF ; filename_out='TropFlux_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.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, fullfilename_swr_blnd ; swr=read_ncdf("swr", yyyymmddb - .5d, yyyymmdde, file=fullfilename_swr_blnd,/nostr) timein=24.d*(time-julday(1,1,1957,0,0,0)) jpt=n_elements(timein) da=jul2date(time[0]) cda0=string(da,format='(i8.8)') da=jul2date(time[jpt-1]) cda1=string(da,format='(i8.8)') print, 'swr in tropflux_nrt_ncdf first date ', cda0 print, 'swr in tropflux_nrt_ncdf last date ' , cda1 ; initncdf, fullfilename_lwr lwr=read_ncdf("lwr", yyyymmddb - .5d, yyyymmdde, file=fullfilename_lwr,/nostr) timein=24.d*(time-julday(1,1,1957,0,0,0)) jpt=n_elements(timein) da=jul2date(time[0]) cda0=string(da,format='(i8.8)') da=jul2date(time[jpt-1]) cda1=string(da,format='(i8.8)') print, 'lwr in tropflux_nrt_ncdf first date ', cda0 print, 'lwr in tropflux_nrt_ncdf last date ' , cda1 ; initncdf, fullfilename_coare lhf=read_ncdf("lhf", yyyymmddb - .5d, yyyymmdde, file=fullfilename_coare,/nostr) timein=24.d*(time-julday(1,1,1957,0,0,0)) jpt=n_elements(timein) da=jul2date(time[0]) cda0=string(da,format='(i8.8)') da=jul2date(time[jpt-1]) cda1=string(da,format='(i8.8)') print, 'lhf in tropflux_nrt_ncdf first date ', cda0 print, 'lhf in tropflux_nrt_ncdf last date ' , cda1 ; shf=read_ncdf("shf", yyyymmddb - .5d, yyyymmdde, file=fullfilename_coare,/nostr) timein=24.d*(time-julday(1,1,1957,0,0,0)) jpt=n_elements(timein) da=jul2date(time[0]) cda0=string(da,format='(i8.8)') da=jul2date(time[jpt-1]) cda1=string(da,format='(i8.8)') print, 'shf in tropflux_nrt_ncdf first date ', cda0 print, 'shf in tropflux_nrt_ncdf last date ' , cda1 ; help, swr, lwr, lhf, shf ; lat=reform(gphit[0,0:jpj-1]) lon=reform(glamt[0:jpi-1,0]) ; 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:'TropFlux - Air-Sea Fluxes for the Global Tropics', Resolution:'1 x 1 degree and daily', IDL_program_name:'TropFlux_ncdf.pro',Timerange:cda0+' - '+cda1, More_Info:'ISCCP based SWR until 2007 and OLR based SWR after that with a 90 day linear transition between the two'} sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'} lw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Longwave Radiation',short_name:'lwr',axis:'TYX'} sh_attr={units:'w/m^2',missing_value:1.e20,long_name:'Sensible Heat Flux',short_name:'shf',axis:'TYX'} lh_attr={units:'w/m^2',missing_value:1.e20,long_name:'Latent Heat Flux',short_name:'lhf',axis:'TYX'} ; ncfields = 'swr[longitude,latitude,*time]=swr:sw_attr; ' $ +'lwr[longitude,latitude,*time]=lwr:lw_attr; ' $ +'lhf[longitude,latitude,*time]=lhf:lh_attr; ' $ +'shf[longitude,latitude,*time]=shf:sh_attr; ' $ + 'longitude[]=lon:lon_attr; ' $ + 'latitude[]=lat:lat_attr; ' $ + 'time[]=timein:time_attr ' $ + ' @ globattr' ; @ncdf_quickwrite ; result = 0 return, result ; end