;The procedure getlongterm_theta_wc.pro finds the long term value of the ;vertical rotation theta given the wind direction phi for sonic anemometer ;data. It is used by getrotated_wc.pro which is in dayflux_wc.pro. ;The long term value of vertical rotation is based on a fit of hour-long ;averages of the wind direction (phi) and vertical rotation (theta). ;The fitted function has the form ; theta= amin*sin(phi-omega)+co(3)*phi^3+co(2)*phi^2+co(1)*phi+co(0) ;amin is the maginitude of sine function fitted to the data ;omega is the phase of the sine function ;co are coefficients of a polynomial fit to the residual (resid=data-sine fcn) ; ;Use of this procedure is as follows: ; getlongterm_theta_wc,year,jday,nphi,nnth ;Where ; | year = 4-digit integer year ; input | jday = julian day ; | nphi = half-hour-long average value of wind direction ; ; output | nnth = vertical rotation theta based on fitted curves ; | of half hour avg wind direction and vertical rotation ; ;Written by BWBerger 9/27/99 based heavily on getlongterm_theta.pro used for ;wlef. ; Modified by W wang for Lost Creek, Sep 20 2000 pro getlongterm_theta_lc,year,jday,nphi,nnth if nphi ne -999. then begin ; if (year eq 1999) and (jday ge ?) and (jday lt ?) then begin ; after getting the amin ,omega and...., need change them ; amin=0.066701286 ; omega=-2.5506242 ; co=[0.0090345802,0.0037363508,0.0065523144,-0.00054193522] ; amin=0.051741764 ; omega=3.1415928 ; co=[-0.00037361167,-0.0035706706,0.0025629113, 0.0399209632] ; Dec 18, 2000, for 257-289/2000 fit amin=0.017511213 omega=2.9670598 co=[0.0087165802,-0.0038714996,0.0010906214,0.00042049559] IF year EQ 2000 THEN BEGIN amin=0.021669309 omega=3.0836478 co=[0.0086829844,-0.0018659206,0.0026119162,0.00010596805] nnth=amin*sin(nphi-omega)+co(3)*nphi^3+co(2)*nphi^2+co(1)*nphi+co(0) ENDIF IF year EQ 2001 THEN BEGIN ; 2001 using higher-order fitting, becasue the shape of the theta-phi is a ; little bit strange amin=-0.018986855 omega=-0.17453294 co=[0.0065484938,-0.0047221532,-0.0012790248,0.0016544594,$ 0.0046622083,-0.00022475063,-0.00096655132,1.4160792e-05,5.3013155e-05] ;2002, Mar. 27, using all data of 2001 to do fitting amin=0.020322408 omega=2.6179939 co=[0.0083716696,-0.0047960443,-0.0022397452,0.0011075278,$ 0.0042626141,-7.9092888e-5,-0.00087304430,4.5311606e-05,4.7442026e-05] nnth=amin*sin(nphi-omega)+co(8)*nphi^8+co(7)*nphi^7+$ co(6)*nphi^6+co(5)*nphi^5+co(4)*nphi^4+$ co(3)*nphi^3+co(2)*nphi^2+co(1)*nphi+co(0) ENDIF IF year EQ 2002 THEN BEGIN ; Aug. 5th, 2002, run 1-211, 2002 amin=0.02474787 omega=2.7925269 co=[0.0021808224,0.00042482282,-0.00091026390,-0.00026438968,$ 0.0053640759,0.00021799720,-0.0011198411,-2.1259950e-05,6.0010783e-05] ;Jan 17, 2003, run all 2002 data amin=0.023466431 omega=2.4951228 co=[0.0056570107,-0.0037556831,-0.00057394931,0.00050055629,$ 0.0039005290,0.00014904975,-0.00085685088,-1.7902185e-05,4.6805068e-05] nnth=amin*sin(nphi-omega)+co(8)*nphi^8+co(7)*nphi^7+$ co(6)*nphi^6+co(5)*nphi^5+co(4)*nphi^4+$ co(3)*nphi^3+co(2)*nphi^2+co(1)*nphi+co(0) ENDIF IF year EQ 2003 THEN BEGIN ;11/3/2003, not a whole year data, using 'mean' option amin=0.024978855D omega=2.7925269D co=[-0.0120147600D,-0.0021925211,0.0072136577,0.0038824472 ,$ 0.0014632920,-0.00095999577,-0.00047889008,6.1371553e-05,2.5617064e-05] ;2/21/2004, whole 2003 data, use 'mean' option amin=0.022244441D omega=2.9670598D co=[-0.0163717760D,-0.0032206786,0.0088745290,0.0038688867 ,$ 0.0018265567,-0.00091921557,-0.00057803668,5.8782210e-05,3.1308394e-05] nnth=amin*sin(nphi-omega)+co(8)*nphi^8+co(7)*nphi^7+$ co(6)*nphi^6+co(5)*nphi^5+co(4)*nphi^4+$ co(3)*nphi^3+co(2)*nphi^2+co(1)*nphi+co(0) ENDIF IF year EQ 2004 THEN BEGIN ;9/4/2004, not a whole year data, using 'mean' option amin=0.025120732D omega=2.6179939D co=[-0.0025998531D,0.0032595536,0.0066730443,-0.0019350462,$ 5.2588224e-5,0.00031173895,-0.00023399741,-1.3584004e-5,1.4318307e-5] ;2/1/2005, whole year data, use 'mean' option amin=0.022851494d omega=2.6179939D co=[-0.0026632144D,0.0010066403,0.0081829007,-0.0010414222,$ -0.00073068963,0.00017441855,-0.00011092421,-7.1612000e-6,7.8054867e-6] nnth=amin*sin(nphi-omega)+co(8)*nphi^8+co(7)*nphi^7+$ co(6)*nphi^6+co(5)*nphi^5+co(4)*nphi^4+$ co(3)*nphi^3+co(2)*nphi^2+co(1)*nphi+co(0) ENDIF IF year EQ 2005 THEN BEGIN ;02/01/2006, using 8th-order-mean fit, whole year amin=-0.020066534 omega=-0.34906587 co=[-0.0024739337,0.0021365113,0.00042755346,-0.0013805386,$ 0.0037070591,0.00012974259,-0.00086268110,-1.0062387e-06,4.6713244e-05] nnth=amin*sin(nphi-omega)+co(8)*nphi^8+co(7)*nphi^7+$ co(6)*nphi^6+co(5)*nphi^5+co(4)*nphi^4+$ co(3)*nphi^3+co(2)*nphi^2+co(1)*nphi+co(0) ENDIF IF year EQ 2006 THEN BEGIN ;05/06/2007, using 8th-order-mean fit, whole year amin=-0.021632015D omega=-0.34906587D co=[-0.0053641589D,0.0027635196D,0.0046807328D,-0.0019208237D,$ 0.0016357183D,0.00034783700D,-0.00055356098D,-1.8362532D-05,3.2819394D-05] nnth=amin*sin(nphi-omega)+co(8)*nphi^8+co(7)*nphi^7+$ co(6)*nphi^6+co(5)*nphi^5+co(4)*nphi^4+$ co(3)*nphi^3+co(2)*nphi^2+co(1)*nphi+co(0) ENDIF ; nnth=-999. ;this line to be removed when a fit becomes available endif else begin nnth=-999. endelse return end