;+ ; ; .. _read_sw.pro: ; ; =========== ; read_sw.pro ; =========== ; ; DESCRIPTION ; =========== ; ; .. graphviz:: ; ; digraph read_sw { ; ; swnet [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/swnet*_dy.cdf"]; ; sw [shape=tab,fontname=Courier,label="sw"] ; ; read_sw [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/paper01/fig2/read_sw.pro", ; label="${TROPFLUX}/src/paper01/fig2/read_sw.pro"]; ; ; {swnet} -> {read_sw} -> {sw} ; } ; ; SEE ALSO ; ======== ; ; :ref:`project_profile.sh` ; ; :func:`time_lec` ; ; :ref:`fig2_timeline_diagram.pro` ; ; EXAMPLES ; ======== ; ; :: ; ; IDL> csite='8s67e' ; IDL> date1=19890101L ; IDL> date2=20091231L ; IDL> box=++ ; IDL> read_sw, csite, date1, date2, box, sw ; ; TODO ; ==== ; ; make it work with a file : missing input file ; ; EVOLUTIONS ; ========== ; ; $Id$ ; ; $URL$ ; ; - pinsard 2011-04-20T15:15:12Z loholt1.ipsl.polytechnique.fr (Linux) ; ; * typo ; ; - fplod 20110412T093325Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * externalize function ; * remove hard coding path ; * add graphviz ; * remove smooth call (unreacheable statement after end !!) ; ; - fplod 20110411T142955Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ;- pro read_sw, csite, date1, date2, box, sw ; @cm_project ; ; DEFINE THE OUTPUT TIME AXIS ; jda1=date2jul(date1) jda2=date2jul(date2) jpt=(jda2-jda1+1l) time=jda1+dindgen(jpt) ; ; FIRST READ ALL DATA FROM SITE ; - if file exists, extract correct time axis ; - if not, fill variable with missing values ; ; SWR fi=project_id_env+'swnet'+csite+'_dy.cdf' f=file_test(fi) sw=fltarr(jpt)+!values.f_nan ; swr sw_q=fltarr(jpt)+!values.f_nan ; swr quality flag ; if (f) then begin tt0=time_lec(fi) sw0=ncdf_lec(fi,var='SWN_1495') sw_q0=ncdf_lec(fi,var='QSW_5495') tt0=tt0-time(0) ind=where((tt0 ge -1e-5) and (tt0 le jpt-1+1e-5)) if (ind(0) ne -1) then begin sw(tt0(ind))=sw0(ind) sw_q(tt0(ind))=sw_q0(ind) endif endif else begin print, fi, ' not found' endelse ; ind1=where((sw_q ne 1) and (sw_q ne 2)) sw(ind1)=!Values.f_nan ; ; Replace missing values by "NaN" ; ;tsvars=['at','bf','bp','dyn','emp','evap','heat','iso','sw','swnet','qlat','qsen','sw', $ ; 'swnet','rain','rf','rh','ssd','sss','sst','swnet','tx','ty','wu','wv','ws','lat','lon'] ;depvars=['u','v','d','t','s'] vars=['sw'] ; nn=n_elements(vars) for n=0,nn-1 do begin var=vars(n) com='ind=where('+var+' ge 1.e20) if (ind(0) ne -1) then '+var+'(ind)=!values.f_nan' r=execute(com) endfor ; end