/* determine critical u* */ /* 1. based on real data */ /* 2. based on binned data */ /* use same infile as that for AQRTa, AQRTaSWC model fitting */ /* CONCLUSION: tried raw Fc_leuning, raw NEE vs. u* by season, spring-fall (excluding winter) binned Fc_leuning, binned NEE vs. binned u* by season, by month, spring-fall post-dormancy had higher u*crit - 0.35 (30-35% eliminated) growing season and pre-dormancy had lower u*crit - 0.12 (20-35% eliminated) winter flux roughly flat, reasonable in March-April, October-November =========================================================================== Jan, Feb, Dec fluxes mostly negative, even at night, not reasonable =========================================================================== */ /* original: 08.11.2005 */ /* modified: 01.30.2007 */ /* Asko */ %let site=cc; %let year=2007; %let path=C:\DATA\&site.\; %let dsn=Flux_&site._&year._Master.txt; %let timestep=month; /*used for developing AQRT models, either monthly or weekly or seasonally*/ %let stability=020 and abs(Fcrfw)>abs(lagfc)) or (abs(jumpfc)>20 and abs(Fcrfw)>abs(leadFc)) then do; Fcrfw=.; Fcrfw_bad=1; gooddata=0; end; /* calc NEE here rather than in 1st step since Fc has been modified 'til now*/ /*if Gashound signal varies too much, then magnitude of co2_stor uncertain, --> don't use*/ if co2_stor ne . then do; NEE=Fcrfw+co2_stor; end; if co2_stor=. then do; NEE=Fcrfw; end; storrat=co2_stor/NEE; *if abs(storrat)>3 then storrat=.; /*This is remnant from prior version*/ *if season ne "4dor" then year=2004; run; /************************************************************************************/ /* Determine u*rit using binned u* data, since raw data shows no distinct threshold */ /* */ /************************************************************************************/ proc sort data=flux; by year ×tep.; run; proc univariate data=flux noprint; by year ×tep.; where PARa<4 and gooddata ne 0 and itc2_w<0.3 and r17<2 and r16>17000 and &stability. and v45<75; var ustarrfw; output out=ustar_p10 pctlpts= 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 pctlpre=p_; run; data flux_1; merge flux ustar_p10; by year ×tep.; if 0 ge ustarrfw and ustarrfw17000 and &stability. and v45<75 and (sastime>75600 or sastime<21600); var ustarrfw Fcrfw storrat; output out=meanustar mean=ustar Fc storrat stderr=e_ustar e_Fc e_storrat; run; proc sort data=meanustar; by year ×tep. ustarrfw; run; data err; set meanustar; Fc_minus=Fc_leun-e_Fc_leun; Fc_plus=Fc_leun+e_Fc_leun; NEE_minus=NEE-e_NEE; NEE_plus=NEE+e_NEE; run; goptions ftext=swiss htext=2; proc gplot data=err ; by year ×tep.; symbol1 value=dot interpol=join co=black ci=black; symbol2 value=point interpol=join co=blue ci=blue repeat=2; symbol4 value=dot interpol=join co=black ci=black; symbol5 value=point interpol=join co=blue ci=blue repeat=2; goptions interpol=join; symbol value=dot; plot (Fc_leun Fc_minus Fc_plus)*ustarrfw / overlay /*vaxis=-2 0 2 4 6*/ ; *plot (NEE NEE_minus NEE_plus)*ustarrfw / overlay grid vaxis=-2 0 2 ; run; /* check threshold for raw data using growing season data only (that was reasonable in binned analysis)*/ proc gplot data=flux_1; symbol value=plus i=none; where PARa<4 and gooddata ne 0 and itc2_w<0.3 and r17<2 and r16>17000 and &stability. and v45<75 and (sastime>75600 or sastime<21600); plot (Fcrfw )*ustarrfw / overlay /*vaxis=-4 -2 0 2 4 6 8*/; plot (storrat )*ustarrfw / overlay grid vaxis=-2 0 2 ; run; data ustarout; set meanustar; file "&path.ustarrfw_bin_&dsn.×tep..txt"; if _n_=1 then put 'year month ustarclass ustar Fc storrat err_ustar err_Fc err_storrat'; put year ×tep. ustarperc ustar Fc storrat e_ustar e_Fc e_storrat; run; /****************************************************************************************/ /* binned u* calculation over */ /****************************************************************************************/