;+ ; ; ===================== ; tropflux_swr_blnd.pro ; ===================== ; ; .. function:: tropflux_swr_blnd(yyyymmddb,yyyymmdde) ; ; DESCRIPTION ; =========== ; ; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc` ; containing ++ ; has been produced by ; :func:`tropflux_swr_dt`. ; ; :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_NRT.nc` ; containing ++ ; has been produced by ; :func:`tropflux_swr_nrt`. ; ; :file:`${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc` containing ++ ; has been produced by ; :func:`cronin_gustiness_ncdf`. ; ; ++ are written ; in :file:`${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_BLND.nc` ; if this file not already exists. ; ; This file will be used by ; :ref:`TropFlux_NRT_ncdf.pro`. ; ; .. graphviz:: ; ; digraph tropflux_swr_blnd { ; ; file_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_DT.nc"]; ; file_nrt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_NRT.nc"]; ; file_gustiness [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc"]; ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_{yyyymmdd}_{yyyymmdd}_blnd.nc"]; ; ; tropflux_swr_blnd [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/tropflux_swr_blnd.pro", ; label="${PROJECT}/src/tropflux_swr_blnd.pro"]; ; ; {file_dt file_nrt file_gustiness} -> {tropflux_swr_blnd} -> {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:`julday ` ; :func:`ncdf_quickwrite ` ; ; :ref:`Tropflux_NRT_ncdf.pro` ; ; EXAMPLES ; ======== ; ; :: ; ; IDL> yyyymmddb = 20000101L ; IDL> yyyymmdde = 20001231L ; IDL> result = tropflux_swr_blnd(yyyymmddb, yyyymmdde) ; IDL> print, result ; ; TODO ; ==== ; ; handling date > 20071231 ; ; read_ncdf usage of yyyymmddb yyyymmdde ; ; get rid of timegen ; ; submit read_ncdf with 19890101 pb to saxo-dev ; ; coding rules ; ; complete description ; ; why 20080100, 20100112 as date1 and date2 when readind nrt ; ; why two read_ncdf for nrt ; ; according to pk 20110811 we can include this process in ; tropflux_swr_nrt.pro ... later ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename_in not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; EVOLUTIONS ; ========== ; ; $Id: tropflux_swr_blnd.pro 88 2011-08-19 15:40:14Z pinsard $ ; ; $URL$ ; ; - fplod 20120321 ; ; * pro -> func ; * rename with lower case TropFlux_swr_BLND_19890101_20091231.pro become ; tropflux_swr_blnd.pro ; * taking project_overwite into account ; ; - fplod 20110819T120412Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * change 19890101 to 19890100 to read 6939 timesteps in DT file ; even if uggly and understanted SAXO strange behaviour ; ; this resolve crash on cratos idl7:: ; ; % Attempt to subscript SWR_DT with JT is out of range. ; ; line:: ; ; for jt=0,jpt-1 do swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt) ; ; problably because 6938+731=7669 and not 7670 when ; :samp:`dt=read_ncdf('swr', 19890101, 20071231, file=fullfilename_dt,/nostr)` ; was used :: ; ; DT FLOAT = Array[350, 60, 6938] ; NRT FLOAT = Array[350, 60, 731] ; SWR_DT FLOAT = Array[350, 60, 7669] ; SWR_NRT FLOAT = Array[350, 60, 7670] ; ; nb jours 19890101-20071231:: ; ; IDL> print, julday(12,31,2007) - julday(01, 01, 1989) +1 ; 6939 ; ; et ncdump -h $PROJECT_OD/TropFlux_swr_19890101_20071231_DT.nc time = UNLIMITED ; // (6939 currently) ; ; nb jours 19890101-20091231:: ; ; IDL> print, julday(12,31,2009) - julday(01, 01, 1989) +1 ; 7670 ; ; strange behaviour of read_ncdf ... see:: ; ; IDL> fullfilename_dt='TropFlux_swr_19890101_20071231_DT.nc' ; IDL> dt=read_ncdf('swr', 19890100, 20071231, file=fullfilename_dt,/nostr) ; IDL> print, 'first time step (should crash with invalid date)', jul2date(time[0]) ; first time step (should be 19890101) 19890101. ; IDL> dt=read_ncdf('swr', 19890101, 20071231, file=fullfilename_dt,/nostr) ; IDL> print, 'first time step (should be 19890101)', jul2date(time[0]) ; first time step (should be 19890101) 19890102. ; ; * correction for reading gustiness file ; ; - fplod 20110809T115747Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * usage of ${PROJECT_OD} ; * remove v* from filenames (in and out) ; * add test on IO files ; ; - fplod 20101215T085754Z 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_blnd $ , 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_blnd(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 dt data filename filename_dt='TropFlux_swr_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_DT.nc' ; ; check if this file exists msg='iii : looking for ' + filename_dt ras = report(msg) fullfilename_dt = isafile(iodirout + filename_dt, NEW=0, /MUST_EXIST) IF fullfilename_dt[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_dt + ' was not found.' ras = report(msg) return, result ENDIF ; ; build nrt data filename filename_nrt='TropFlux_swr_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '_NRT.nc' ; ; check if this file exists msg='iii : looking for ' + filename_nrt ras = report(msg) fullfilename_nrt = isafile(iodirout + filename_nrt, NEW=0, /MUST_EXIST) IF fullfilename_nrt[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_nrt + ' was not found.' ras = report(msg) return, result ENDIF ; ; build wg data filename filename_wg='TropFlux_gustiness_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' ; ; check if this file exists msg='iii : looking for ' + filename_wg ras = report(msg) fullfilename_wg = isafile(iodirout + filename_wg, NEW=0, /MUST_EXIST) IF fullfilename_wg[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_wg + ' 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)') + '_BLND.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_dt dt=read_ncdf('swr', 19890100, 20071231, file=fullfilename_dt,/nostr) print, 'www : should crash with invalide date 19890100' help, dt print, 'first time step (should be 19890101)', jul2date(time[0]) print, 'last time step (should be 20071231)', jul2date(time[jpt-1]) ; initncdf, fullfilename_nrt nrt=read_ncdf('sw', 20080100, 20100112, file=fullfilename_nrt,/nostr) help, nrt ; swr_nrt=read_ncdf('sw', 19880101, 20100112, file=fullfilename_nrt,/nostr) ; swr_dt=[[[dt]],[[nrt]]] help, nrt, swr_dt, swr_nrt ; swr_merged=swr_dt*0. ; time=timegen(7670, start=julday(1,1,1989,0), units='days') jpt=n_elements(time) ; a=interpol([1.,0.],[julday(10,01,2007),julday(12,31,2007)],time) a=((a > 0.) < 1.) for jt=0,jpt-1 do begin swr_merged[*,*,jt]=swr_dt[*,*,jt]*a[jt]+(1-a[jt])*swr_nrt[*,*,jt] endfor ; initncdf, fullfilename_wg time=timegen(7670, units='days', start=julday(1,1,1989,0)) jpt=n_elements(time) lat=reform(gphit[0,0:jpj-1]) lon=reform(glamt[0:jpi-1,0]) cda0=string(jul2date(time[0]),format='(i8.8)') cda1=string(jul2date(time[jpt-1]),format='(i8.8)') ; time=time-julday(1,1,1950,00,00) 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:'ISCCP based SWR until 2007, after 2007 timeseries is completed with OLR based SWR. A linear transition is applied from ISCCP based SWR to OLR based SWR'} 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_merged:sw_attr; ' $ + 'longitude[]=lon:lon_attr; ' $ + 'latitude[]=lat:lat_attr; ' $ + 'time[*time]=time:time_attr ' $ + ' @ globattr' ; @ncdf_quickwrite ; end