'CR5000 'Copyright (c) 2003 Campbell Scientific, Inc. All rights reserved. '1 January 03 'version 1.4 'e swiatek 'Revised on 4 November, 2003 'revision 1.0 'H. Kim ' 'Revised on 24 May, 2012 for urban flux 'revision 1.0 'zutao ouyang ' 'Revised on 31 May, 2012 for urban flux 'revision 2.0 'zutao ouyang 'Revised on 23 Sep again, 2012 for urban flux 'revision 2.0 'zutao ouyang 'This program measures the following sensors: '***************************************************************************************** 'CSAT3 three dimensional sonic anemometer 'LI-7500A open path infrared gas analyzer (co2 and h2o) ' CNR4 Net radiometer ' LI190SB-L Quantum sensor ' HMP45C-L Temp/RH sensors (three additional) ' TE525-L Tipping bucket rain gage ' 05103 mechanical aemometer ' Apogee Model SI-121 Infrared Radiometers 'Q7.1 net radiometer '***************************************************************************************** '***************************************************************************************** ' This CR5000 program measures turbulence sensors at 10 or 20 Hz. The time series can be 'saved to a PC Card. The CR5000 will also compute on-line turbulent fluxes from the 'measured data. The flux table saves all the cross products that are required to rotate 'the on-line fluxes into natural wind coordinates in post processing as described in: ' ' Kaimal, J. C. and Finnigan, J. J.: 1994, Atmospheric Boundary Layer Flows, Their ' Structure and Measurement, Oxford University Press, New York, 289 pages. ' ' Tanner, C. B. and Thurtell, G . W.: 1969, Anemoclinometer measurements of reynolds ' stress and heat transport in the atmospheric surface layer, Final Report, United ' States Army Electronics Command, Atmospheric Sciences Laboratory, Fort Huachuca, ' Arizona. 'The sign convention for the fluxes, except net radiation, is positive away from the 'surface and negative toward the surface. ' ' The CR5000 will introduce delays into the CSAT3 and CR5000 Panel Temperature 'data. These delays match the fixed 302.369 mSec delay that Campbell Scientific 'programs into the LI-7500 of the LI-7500 irga (see page 3-23 of the LI-7500 manual 'published by Li-Cor). The delays are a function of the Scan Interval and are computed 'automatically by the program. ' 'The site attendant must load in several constants and calibration values. Search 'for the text string "unique" to find the locations where unique constants and 'calibration values are entered. '***************************************************************************************** '*** Unit Definitions ******************************************************************** 'Units Units 'C Celsius 'degrees degrees (angle) 'g grams 'J Joules 'kg kilograms 'kPa kilopascals 'm meters 'mg milligrams 'mSeconds milliseconds 'mV millivolts 's seconds 'V volts 'W Watts '***************************************************************************************** '*** Operation *************************************************************************** ' ' Set the constant SCAN_INTERVAL to 100 mSec (10 Hz) or 50 mSec (20 Hz). The 'appropriate value of the constants CSAT_OPT, ANALOG_DELAY, and CSAT_DELAY will be 'computed by the CR5000. Connect all the sensors to the CR5000 as described in the 'Wiring section. ' 'Download the program to the CR5000. When servicing the station, set save_flx_flag_on 'low or set Custom Menu option "Save Fluxes?" to No, note that if save_flx_flag_on ("Save 'Fluxes?") is not set back to high (Yes), no flux data will be saved. '*** User Control in "Custom" Menu of Program Control Flags *** 'The Custom Menu allows the station operator to conveniently change the status of the 'Program Control Flags using the CR5000 keyboard display. 'Save Fluxes? Change to "Yes" (default) to start processing flux data. 'save_flx_flag_on Change to "No" when cleaning webs from CSAT3 or performing other ' site maintenance. This "bad" data will not be included in the on-line fluxes. ' 'Save Time Series? Change to "Yes" (default) to begin collecting time series on PC Card. 'save_ts_flag_on Change to "No" to stop collecting time series on the PC Card. '***************************************************************************************** '*** Wiring ****************************************************************************** '**********SDM INPUT CHANNEL**************CSAT and LI-7500A******************************* 'SDM-C1 CSAT3 SDM Data (green) ' LI-7500 SDM Data (blue) 'SDM-C2 CSAT3 SDM Clock (white) ' LI-7500 SDM Clock (white) 'SDM-C3 CSAT3 SDM Enable (brown) ' LI-7500 SDM Enable (brown) 'G CSAT3 SDM reference (black) ' CSAT3 SDM shield (clear) ' LI-7500 SDM reference (black) ' LI-7500 SDM shield (white) '**********SDM INPUT CHANNEL**************CSAT and LI-7500A******************************* '*********ANALOG INPUT CHANNEL**************CNR4 and LI190SB and Q7.1 and HMP45C*********** 'and 05103 wind and apogee IS-121********************************************************** '1H CNR4 Pyranometer Up Signal-short wave (red) '1L CNR4 Pyranometer Up Reference-short wave (blue) 'gnd Connect Jumper Wire to 1L ' '2H CNR4 Pyranometer Down Signal-short wave (white) '2L CNR4 Pyranometer Down Reference-short wave (black) 'gnd Connect Jumper Wire to 2L ' '3H CNR4 Pyrgeometer Up Signal-long wave (grey) '3L CNR4 Pyrgeometer Up Reference-long wave (yellow) 'gnd Connect Jumper Wire to 3L ' '4H CNR4 Pyrgeometer Signal-long wave (brown) '4L CNR4 Pyrgeometer Down Reference-long wave (green) 'gnd Connect Jumper Wire to 4L; CNR4 shield (clear) ' '5H '5L CNR4 thermistor signal (white) 'gnd CNR4 thermistor signal reference (black); CNR4 thermistor shield (clear) ' '6H '6L 'gnd ' '7H LI190SB Signal+ (red) '7L LI190SB Signal- (black) 'gnd LI190SB Shield (clear); connect jumper to 7L ' '8H Q7.1 signal (red) '8L Q7.1 signal reference (black) 'gnd Q7.1 shield (clear) ' '9H HMP45C #1 temperature signal (yellow) '9L HMP45C #1 signal reference (purple) 'gnd HMP45C #1shield (clear) ' '10H HMP45C #1relative humidity signal (blue) '10L short jumper wire to 9L 'gnd ' '11H (SE 21) 05103 wind dir. sig (green) '11L 'gnd 05103 wind dir. reflence (white) and 05305 shield wire (clear) ' '12H (SE 23) apogee IS-121 (green) '12L 'gnd apogee IS-121 (blue) ' '13H apogee IS-121 (red) '13L apogee IS-121 (black) 'gnd apogee IS-121 (clear) ' '14H '14L 'gnd ' '15H '15L 'gnd ' '16H '16L 'gnd ' '17H '17L 'gnd '18H '18L 'gnd ' '19H '19L 'gnd ' '20H '20L 'gnd '****************************************************************************************** '***********PULSE PORT***************TE525 rain gauge and 05103 wind*********************** 'P1 TE525 (black) 'G TE525 (white) ' TE525 (clear) 'P2 05103 wind speed sig (red) 'G 05103 wind speed sig (black) '***************************************************************************************** '***********CURRENT EXCITATION*********************CNR4(pt-100) and apogee IS-121********** ' and 05103 wind dir*********************************************************************** 'IX1 Pt-100 Current Excitation (red) 'gnd Pt-100 Current Excitation Ground (blue) 'voltage excitation 'VX1 apogee IS-121 (white) 'VX2 05103 wind dir voltage Excitation (blue) 'VX3 CNR4 thermistor voltage excitation 'G '****************************************************************************************** '*************CONTROL PORT***************************************************************** 'C1 'C2 'C3 'C4 'G ' '***************************************************************************************** '***************POWER OUT*************************HMP45C********************************** '5V HMP45C #1 power control (orange) '12V HMP45C #1 power (red) ' ' 'G HMP45C #1 power reference (black) ' ' 'SW12 ' ' ' 'G ' ' ' '****************************************************************************************** '*********POWER IN************************************************************************* '12V CR5000 (red) 'G CR5000 (black) '****************************************************************************************** '*******EXTERNAL POWER SUPPLY************************************************************** 'POS CSAT3 power (red) ' LI-7500 power (red with white) ' CR5000 (red) 'NEG CSAT3 power reference (black) ' CSAT3 power shield (clear) ' LI-7500 power reference (red with black) ' LI-7500 ground (green) ' CR5000 (black) '****************************************************************************************** '*** Constants *************************************************************************** Const ANGLE_FROM_NORTH = 210 'Unique value changed from 320 to 210. 'Compass azimuth of the -x axis. For the figure ' below, ANGLE_FROM_NORTH = 90. ' () -> Compass coordinate system ' {} -> Right handed coordinate system aligned to magnetic North ' ' ' (N) ' {-y} ' | ' | ' | ' | ' | ' | ' (W) {+x} --------[ ]----X---> {-x} (E) ' / | \ ' CSAT3 Block | CSAT3 Transducers ' | ' | ' v ' {+y} ' (S) ' 'The program computes the Compass wind direction, using the constant ANGLE_FROM_NORTH, 'and a CSAT3 wind direction. Good CSAT3 wind directions are between -90 to 0 and 0 to '90 degrees (-pi/2 to 0 and 0 to pi/2 radians), i.e. the wind is blowing into the CSAT3 'sensor head. 'Measurement Rate '10 Hz 20 Hz Const SCAN_INTERVAL = 100 '100 (mSec) 50 (mSec) 'Output period Const OUTPUT_INTERVAL = 30 'On-line flux data output interval in minutes. Const CSAT_OPT = INT (1/SCAN_INTERVAL*1000) '10 (Hz) 20 (Hz) Const ANALOG_DELAY = INT (300/SCAN_INTERVAL+1) '4 (3 scan delay) 7 (6 scan delay) Const CSAT_DELAY = INT (ANALOG_DELAY-2) '2 (1 scan delay) 5 (4 scan delay) Const Q7_1_POS_CAL = 9.47 'Unique positive multiplier for Q7.1. Const Q7_1_NEG_CAL = 11.76 'Unique negative multiplier for Q7.1. 'Unique CNR4 Sensitivity Const CNR4_pyrano_up = 13.80 Const CNR4_pyrano_dn = 10.43 Const CNR4_pyrgeo_up = 13.14 Const CNR4_pyrgeo_dn = 11.94 'CNR4 multipliers Const pyrano_up_mult = 1000/CNR4_pyrano_up Const pyrano_dn_mult = 1000/CNR4_pyrano_dn Const pyrgeo_up_mult= 1000/CNR4_pyrgeo_up Const pyrgeo_dn_mult = 1000/CNR4_pyrgeo_dn Const Excite_I=100 'Current Excitation at 100uA Const par_cal = 7.08 'Unique calibration value for LI190SB in uA/mmol/s/m^2 Const par_mult_flxdens = 1000/(par_cal*0.604) 'multiplier for Flux Density calculation Const par_mult_totflx = (1/(par_cal*0.604))*(SCAN_INTERVAL/1000) 'multiplier for Total Flux calculation Const CP = 1004.67 'Estimate of heat capacity of air [J/(kg K)]. Const LV = 2440 'Estimate of the latent heat of vaporization [J/g]. Const SDM_PER = 30 'Default SDM clock speed, 30 uSec bit period. Const RD = 0.28704 'Gas constant for dry air [J/(g K)]. Const RV = 0.0004615 'Gas constant for water vapor [J/(mg K)]. Const R = 8.3143e-3 'Universal gas constant [ (kP m^3) / (K mol) ]. Const A_0 = 6.107800 'Coefficients for the sixth order approximating Const A_1 = 4.436519e-1 ' saturation vapor pressure polynomial (Lowe, Const A_2 = 1.428946e-2 ' Paul R., 1976.: An approximating polynomial for Const A_3 = 2.650648e-4 ' computation of saturation vapor pressure, J. Appl. Const A_4 = 3.031240e-6 ' Meteor., 16, 100-103). Const A_5 = 2.034081e-8 Const A_6 = 6.136821e-11 'Declare constants for Apogee Model SI-121 Infrared Radiometers 'mC2 = polynomial coefficient (C2) used to calculate slope (m) 'mC1 = polynomial coefficient (C1) used to calculate slope (m) 'mC0 = polynomial coefficient (C0) used to calculate slope (m) 'bC2 = polynomial coefficient (C2) used to calculate intercept (b) 'bC1 = polynomial coefficient (C1) used to calculate intercept (b) 'bC0 = polynomial coefficient (C0) used to calculate intercept (b) 'Note that all calibration coefficients are sensor-specific Const mC2 = 49790 Const mC1 = 8144850 Const mC0 = 1313020000 Const bC2 = 34007 Const bC1 = -616580 Const bC0 = -2815290 Const YES = -1 'Yes is defined as True or -1. Const NO = 0 'No is defined as False or 0. '***************************************************************************************** '*** Variables *************************************************************************** 'CSAT3 variables with additional one or four scan delay, from the Data Table scan_1_4. Public wind(5) 'Wind, temperature, and diagnostic data from CSAT3. Alias wind(1) = Ux Alias wind(2) = Uy Alias wind(3) = Uz Alias wind(4) = Ts Alias wind(5) = diag_csat Units wind = m/s Units Ts = C Units diag_csat = unitless 'LI-7500 has a fixed delay of 302.369 mSec (three scans at 10 Hz or six scans at 20 Hz). Public irga(6) 'Co2, h2o, pressure, and diagnostic from the LI-7500. Alias irga(1) = co2 Alias irga(2) = h2o Alias irga(3) = press Alias irga(4) = diag_irga Alias irga(5) = co2_u_mol Alias irga(6) = h2o_m_mol Units co2 = mg/m^3 Units h2o = g/m^3 Units press = kPa Units diag_irga = unitless Units co2_u_mol = umol/mol Units h2o_m_mol = mmol/mol Public diag_bits(9) 'Warning flags. Alias diag_bits(1) = del_T_f 'Delta temperature warning flag. Alias diag_bits(2) = track_f 'Tracking (signal lock) warning flag. Alias diag_bits(3) = amp_h_f 'Amplitude high warning flag. Alias diag_bits(4) = amp_l_f 'Amplitude low warning flag. Alias diag_bits(5) = chopper_f 'Chopper warning flag. Alias diag_bits(6) = detector_f 'Detector warning flag. Alias diag_bits(7) = pll_f 'PLL warning flag. Alias diag_bits(8) = sync_f 'Synchronization warning flag. Alias diag_bits(9) = agc 'Automatic gain control. Units diag_bits = samples Units agc = unitless 'Analog variables with three or six scan delay. Public panel_temp 'CR5000 panel temperature. Units panel_temp = C 'No delay on meteorological sensors. Public rho_a 'Density of moist air. Public rho_d 'Density of dry air. Public hmp(3) 'HMP45C vapor density, temperature and relative humidity. Public e 'HMP45C vapor pressure. Public e_sat 'Saturation vapor pressure. Public batt_volt Alias hmp(1) = h2o_hmp Alias hmp(2) = t_hmp Alias hmp(3) = rh_hmp Units rho_a = kg/m^3 Units rho_d = kg/m^3 Units h2o_hmp = g/m^3 Units t_hmp = C Units rh_hmp = fraction Units e = kPa Units e_sat = kPa Units batt_volt = V 'No delay energy balance sensor. 'declare public variables Public Rn_Q7_1 Public Rn(9) Public Temp(2) 'Public solar_rad Public rain_fall Public par(3) 'public variables for apogee model SI-121 Infrared Radiometers 'SBTempC = sensor body temperature in degrees Celsius 'SBTempK = sensor body temperature in Kelvin 'TargmV = mV output of thermopile infrared detector (dependent on temperature difference between target and sensor 'body) 'm = slope of equation relating target and sensor body temperatures to mV output of thermopile 'b = intercept of the equation relating target and sensor body temperatures to mV output of thermopile 'TargTempK = target temperature in Kelvin 'TargTempC = target temperature in degrees Celsius Public SBTempC, SBTempK, TargmV, m, b, TargTempK, TargTempC Dim Rs Dim Vs_Vx Dim i Public hor_wind Alias Rn(1) = Rad_short_Up Alias Rn(2) = Rad_short_Dn Alias Rn(3) = Rad_long_Up Alias Rn(4) = Rad_long_Dn Alias Rn(5) = Rad_long_Up_TCor Alias Rn(6) = Rad_long_Dn_TCor Alias Rn(7) = Rn_short Alias Rn(8) = Rn_long Alias Rn(9) = Rn_total Alias Temp(1) = Temp_C Alias Temp(2) = Temp_K Alias par(1) = par_mV Alias par(2) = par_flxdens Alias par(3) = par_totflx '******Begining of 05103 variables********* Public hor_wnd_05103(2) Alias hor_wnd_05103(1)=hor_wnd_spd Alias hor_wnd_05103(2)=hor_wnd_dir '******End of 05103 variables********* '******Units defintion Units Rn_Q7_1 = W/m^2 Units Rn = W/m^2 Units Temp(1) = Temp_C Units Temp(2) = Temp_K Units rain_fall = mm Units par_mV = mV Units par_flxdens = umol/s/m^2 Units par_totflx = mmol/m^2 Units hor_wnd_05103(1) = m/s Units hor_wnd_05103(2) = degrees 'Flux variables. Dim Fc_wpl 'Co2 flux, with Webb et al. term. Dim LE_wpl 'Latent heat flux, with Webb et al. term. Dim Hs 'Sensible heat flux using sonic temperature. Dim tau 'Momentum flux. Dim u_star 'Friction velocity. Dim Fc_irga 'Co2 flux, raw. Dim LE_irga 'Latent heat flux, raw. Dim co2_wpl_LE 'Co2 flux, Webb et al. term do to latent heat flux. Dim co2_wpl_H 'Co2 flux, Webb et al. term do to sensible heat flux. Dim h2o_wpl_LE 'Latent heat flux, Webb et al. term do to latent heat flux. Dim h2o_wpl_H 'Latent heat flux, Webb et al. term do to sensible heat flux. Dim cov_out(51) 'Covariances of wind and scalars, wind vector, mean rho_a, rho_d, t_hmp, co2, h2o, and mean soil temperature. Units Fc_wpl = mg/(m^2 s) Units LE_wpl = W/m^2 Units Hs = W/m^2 Units tau = kg/(m s^2) Units u_star = m/s Units Fc_irga = mg/(m^2 s) Units LE_irga = W/m^2 Units co2_wpl_LE = mg/(m^2 s) Units co2_wpl_H = mg/(m^2 s) Units h2o_wpl_LE = W/m^2 Units h2o_wpl_H = W/m^2 'Aliases for covariances. Alias cov_out(1) = cov_Uz_Uz Alias cov_out(2) = cov_Uz_Ux Alias cov_out(3) = cov_Uz_Uy Alias cov_out(4) = cov_Uz_co2 Alias cov_out(5) = cov_Uz_h2o Alias cov_out(7) = cov_Uz_Ts Alias cov_out(9) = cov_Ux_Ux Alias cov_out(10) = cov_Ux_Uy Alias cov_out(11) = cov_Ux_co2 Alias cov_out(12) = cov_Ux_h2o Alias cov_out(14) = cov_Ux_Ts Alias cov_out(16) = cov_Uy_Uy Alias cov_out(17) = cov_Uy_co2 Alias cov_out(18) = cov_Uy_h2o Alias cov_out(20) = cov_Uy_Ts Alias cov_out(22) = cov_co2_co2 Alias cov_out(27) = cov_h2o_h2o Alias cov_out(34) = cov_Ts_Ts Units cov_Uz_Uz = (m/s)^2 Units cov_Uz_Ux = (m/s)^2 Units cov_Uz_Uy = (m/s)^2 Units cov_Uz_co2 = mg/(m^2 s) Units cov_Uz_h2o = g/(m^2 s) Units cov_Uz_Ts = m C/s Units cov_Ux_Ux = (m/s)^2 Units cov_Ux_Uy = (m/s)^2 Units cov_Ux_co2 = mg/(m^2 s) Units cov_Ux_h2o = g/(m^2 s) Units cov_Ux_Ts = m C/s Units cov_Uy_Uy = (m/s)^2 Units cov_Uy_co2 = mg/(m^2 s) Units cov_Uy_h2o = g/(m^2 s) Units cov_Uy_Ts = m C/s Units cov_co2_co2 = (mg/m^3)^2 Units cov_h2o_h2o = (g/m^3)^2 Units cov_Ts_Ts = C^2 'Wind directions and speed. Alias cov_out(39) = wnd_dir_compass Alias cov_out(41) = wnd_spd Alias cov_out(42) = rslt_wnd_spd Alias cov_out(43) = wnd_dir_csat3 Alias cov_out(44) = std_wnd_dir Alias cov_out(45) = rho_a_mean Alias cov_out(46) = rho_d_mean Alias cov_out(47) = t_hmp_mean Alias cov_out(48) = co2_mean Alias cov_out(49) = h2o_mean Units wnd_dir_compass = degrees Units wnd_spd = m/s Units rslt_wnd_spd = m/s Units wnd_dir_csat3 = degrees Units std_wnd_dir = degrees 'Diagnostic variables. Dim disable_flag_on(4) 'Intermediate processing disable. 'disable_flag_on(1) 'Set high when CSAT3 diagnostic warning flags are on or CSAT3 has no data. 'disable_flag_on(2) 'Set high when LI-7500 diagnostic warning flags are on or LI-7500 failed to send data. 'disable_flag_on(3) 'Set high when CSAT3 diagnostic warning flags are on. ' Used to filter the sum of CSAT3 diagnostic warning flags. 'disable_flag_on(4) 'Set high when LI-7500 diagnostic warning flags are on. ' Used to filter the sum of LI-500 diagnostic warning flags. Dim n 'Number of samples in the on-line covariances. Units n = samples 'Program Control flags. Public save_flx_flag_on Public save_ts_flag_on 'Measurement variables without delays. Dim wind_in(5) 'CSAT3 data, before adding delay. Dim panel_temp_in 'Panel temperature, before adding delay. 'Arrays to store delayed data. Dim analog_data(3) 'Three or six scan old data from the Data Table scan_3_6. Dim csat_data(5) 'One or four scan old data from the Data Table scan_1_4. 'Working variables. Dim cov_in(8) 'Array used in the covariance instruction. Dim co2_mm_m3 'Carbon dioxide concentration [mmol/m^3], used to compute umol/mol concentration. Dim h2o_mm_m3 'Water vapor concentration [mmol/m^3], used to compute vapor pressure and mmol/mol concentration. Dim t_hmp_K 'HMP45C temperature in Kelvin. Dim sigma_wpl 'Webb et al. sigma = density of water / density of dry air. Dim j 'Counter variable. Dim scan_count 'Counts the number scans that have been executed. Dim wind_east 'Uy wind in compass coordinate system. Dim wind_north 'Ux wind in compass coordinate system. Dim even_min_flag_on 'Used to synchronize the time series output to the even minute. '***************************************************************************************** '*** Final Output Data Tables ************************************************************ 'This table will hold fourteen days of flux data on the CPU or twenty-eight days on the 'PC Card of flux data. This data is output every OUTPUT_INTERVAL minutes. DataTable (flux,TRUE,2016) DataInterval (0,OUTPUT_INTERVAL,Min,10) CardOut (0,-1) Sample (1,Fc_wpl,IEEE4) Sample (1,LE_wpl, IEEE4) Sample (1,Hs,IEEE4) Sample (1,tau,IEEE4) Sample (1,u_star,IEEE4) Sample (5,cov_out(1),IEEE4) Sample (1,cov_out(7),IEEE4) Sample (4,cov_out(9),IEEE4) Sample (1,cov_out(14),IEEE4) Sample (3,cov_out(16),IEEE4) Sample (1,cov_out(20),IEEE4) Sample (1,cov_out(22),IEEE4) Sample (1,cov_out(27),IEEE4) Sample (1,cov_out(34),IEEE4) Average (3,Ux,IEEE4,(disable_flag_on(1) OR NOT (save_flx_flag_on)) Average (2,co2,IEEE4,(disable_flag_on(2) OR NOT (save_flx_flag_on)) Average (1,Ts,IEEE4,(disable_flag_on(1) OR NOT (save_flx_flag_on)) Average (1,rho_a,IEEE4,disable_flag_on(2) OR NOT (save_flx_flag_on)) Average (1,press,IEEE4,disable_flag_on(2) OR NOT (save_flx_flag_on)) Average (1,panel_temp,IEEE4,FALSE) Sample (1,wnd_dir_compass,IEEE4) Sample (1,wnd_dir_csat3,IEEE4) Sample (1,wnd_spd,IEEE4) Sample (1,rslt_wnd_spd,IEEE4) Average (1,batt_volt,IEEE4,FALSE) Sample (1,std_wnd_dir,IEEE4) Totalize (1,n,IEEE4,disable_flag_on(1) OR disable_flag_on(2) OR NOT (save_flx_flag_on)) Totalize (1,n,IEEE4,NOT (disable_flag_on(1) XOR disable_flag_on(3)) OR NOT (save_flx_flag_on) FieldNames ("csat_warnings") Totalize (1,n,IEEE4,NOT (disable_flag_on(2) XOR disable_flag_on(4)) OR NOT (save_flx_flag_on) FieldNames ("irga_warnings") Totalize (4,del_T_f,IEEE4,disable_flag_on(3) OR NOT (save_flx_flag_on)) Totalize (4,chopper_f,IEEE4,disable_flag_on(4) OR NOT (save_flx_flag_on)) Average (1,agc,IEEE4,disable_flag_on(2) OR NOT (save_flx_flag_on)) Sample (1,Fc_irga,IEEE4) Sample (1,LE_irga,IEEE4) Sample (1,co2_wpl_LE,IEEE4) Sample (1,co2_wpl_H,IEEE4) Sample (1,h2o_wpl_LE,IEEE4) Sample (1,h2o_wpl_H,IEEE4) Average (3,h2o_hmp,IEEE4,FALSE) ' modified to add output of rh Average (1,Rn_Q7_1,IEEE4,FALSE) Average (9,Rn,IEEE4,False) Average (1,Temp(2),IEEE4,False) ''==deleted== originally defined for LI200x Average (1,solar_rad,IEEE4,False) Totalize (1,rain_fall,FP2,False) '*********05103 output********** WindVector(1,hor_wnd_spd,hor_wnd_dir,IEEE4,TRUE,0,0,1) '*********apogee model SI-121 output******** Average (1,SBTempC,IEEE4,False) Average (1,TargTempC,IEEE4,False) '===(deleted)===Average (6,hmp(4),IEEE4,False) Totalize (1,par_totflx,IEEE4,False) Average (1,par_flxdens,IEEE4,False) EndTable 'Set save_ts_flag_on high or set "Save Time Series?" custom menu option to Yes 'to save time series data. DataTable (ts_data,even_min_flag_on,-1) DataInterval (0,SCAN_INTERVAL,mSec,100) CardOut (0,-1) Sample (3,Ux,IEEE4) Sample (2,co2,IEEE4) Sample (1,Ts,IEEE4) Sample (1,press,IEEE4) Sample (1,diag_csat,IEEE4) EndTable '*** Working Data Tables *** 'Delay the analog measurements by three or six scans. DataTable (scan_3_6,TRUE,ANALOG_DELAY) Sample (1,panel_temp_in,IEEE4) EndTable 'Delay the CSAT3 measurements by one or four scans. DataTable (scan_1_4,TRUE,CSAT_DELAY) Sample (5,wind_in(1),IEEE4) EndTable 'Compute the covariances of vertical wind, co2, h2o, and sonic temperature, as well as 'the other cross products, required to rotate the data into natural wind coordinates. 'This data is output every OUTPUT_INTERVAL minutes. DataTable (comp_cov,TRUE,1) DataInterval (0,OUTPUT_INTERVAL,min,1) Covariance (8,cov_in(1),IEEE4,(disable_flag_on(1) OR disable_flag_on(2) OR NOT (save_flx_flag_on)),36) WindVector (1,wind_east,wind_north,IEEE4,(disable_flag_on(1) OR NOT (save_flx_flag_on)),0,1,2) WindVector (1,Uy,Ux,IEEE4,(disable_flag_on(1) OR NOT (save_flx_flag_on)),0,1,2) Average (1,rho_a,IEEE4,disable_flag_on(2)) Average (1,rho_d,IEEE4,disable_flag_on(2)) Average (1,t_hmp,IEEE4,FALSE) Average (1,co2,IEEE4,disable_flag_on(2)) Average (1,h2o_hmp,IEEE4,FALSE) EndTable '*** Subroutines *** '*** Define Custom Menus *** DisplayMenu ("Program Control",TRUE) MenuItem ("Save Fluxes?",save_flx_flag_on) MenuPick (YES,NO) MenuItem ("Save Time Series?",save_ts_flag_on) MenuPick (YES,NO) EndMenu '*** Program *** BeginProg n = 1 'Save fluxes on compile. save_flx_flag_on = TRUE 'Save the time series on compile. save_ts_flag_on = TRUE 'Set all CSAT3 variables to NaN. Move (wind_in(1),5,NaN,1) 'Set all LI-7500 variables to NaN. Move (irga(1),4,NaN,1) 'Set the SDM clock speed. SDMSpeed (SDM_PER) Scan (SCAN_INTERVAL,mSec,10,0) 'CR5000 panel temperature. PanelTemp (panel_temp_in,250) 'Get CSAT3 wind and sonic temperature data. CSAT3 (wind_in(1),1,3,91,CSAT_OPT) 'Get LI-7500 data. CS7500 (irga(1),1,7,6) 'Save the molar density to compute molar concentration. co2_mm_m3 = co2 h2o_mm_m3 = h2o 'Convert LI-7500 data from molar density [mmol/m^3] to mass density. ' 44 [g/mol] - molecular weight of carbon dioxide ' 0.018 [g/mmol] - molecular weight of water vapor If ( NOT (co2 = -99999) ) Then ( co2 = co2*44 ) h2o = h2o*0.018 'Measure the HMP45AC temperature and fraction humidity. VoltDiff(t_hmp,1,mV1000,9,TRUE,200,250,0.1,0) VoltDiff(rh_hmp,1,mV1000,10,TRUE,200,250,0.1,0) 'Find the engineering units for the HMP45C temperature and humidity. t_hmp = t_hmp - 40 rh_hmp = rh_hmp*0.01 'Find the HMP45C vapor pressure, in kPa, using a sixth order polynomial (Lowe, 1976). e_sat = 0.1*(A_0+t_hmp*(A_1+t_hmp*(A_2+t_hmp*(A_3+t_hmp*(A_4+t_hmp*(A_5+t_hmp*A_6)))))) e = e_sat*rh_hmp 'Compute the HMP45C vapor density. h2o_hmp = e/((t_hmp+273.15)*RV) 'Compute dry and moist air density. rho_d = (press-e)/((t_hmp+273.15)*RD) rho_a = rho_d+(h2o_hmp/1000) 'Measure battery voltage. Battery (batt_volt) 'Measure the Q7.1 net radiometer. VoltDiff (Rn_Q7_1,1,mV200C,8,TRUE,200,250,1,0) 'Measure the CNR4 Net Radiometer 'Measure short wave up radiometer VoltDiff (Rn(1),1,mV50,1,True,200,250,pyrano_up_mult,0) 'Measure short wave dn radiometer VoltDiff (Rn(2),2,mV50,1,True,200,250,pyrano_dn_mult,0) 'Measure long wave up radiometer VoltDiff (Rn(3),3,mV50,1,True,200,250,pyrgeo_up_mult,0) 'Measure long wave dn radiometer VoltDiff (Rn(4),4,mV50,1,True,200,250,pyrgeo_dn_mult,0) 'change on 7/16 from Rn(3) to Rn(4), so all the date before this date was actually wrong for long wave 'Measure CNR4 thermistor BrHalf (Vs_Vx,1,mV5000,10,Vx3,1,2500,True,0,250,1.0,0) Rs = 1000*(Vs_Vx/(1-Vs_Vx)) Temp_C = 1/(1.0295*(10^(-3))+2.391*(10^(-4))*LN(Rs)+1.568*(10^(-7))*LN(Rs))-273.15 'Convert Temperature to Kelvin Temp_K = Temp_C+273.15 'Apply Temperature Corrections to CNR4 Long Wave Radiation Outputs Rn(5) = Rn(3)+5.67*10^(-8)*Temp_K^4 Rn(6) = Rn(4)+5.67*10^(-8)*Temp_K^4 'Caclulate Short Wave Net Radiation Rn_short = Rad_short_Up - Rad_short_Dn 'Calculate Long Wave Net Radiation Rn_long = Rad_long_Up - Rad_long_Dn 'Calculate Total Net Radiation Rn_total = Rn_short + Rn_long '****** end of the CNR1 measurement*********** 'Measure LI190SB Quantum sensor VoltDiff (par_mV,1,mV20,7,True,200,250,1,0) 'Calculate Flux Density & Total Flux par_flxdens = par_mV*par_mult_flxdens par_totflx = par_mV*par_mult_totflx 'Measure TE525 Tipping Bucket Rain gage and report the rain fall in mm PulseCount (rain_fall,1,1,2,0,0.254,0) 'Measure 05103 wind monitor BrHalf(hor_wnd_dir,1,Autorange,21,VX2,1,2500,TRUE,0,_60Hz,355,0) PulseCount(hor_wnd_spd,1,2,1,3000,0.0980,0) If hor_wnd_dir>=355 Then hor_wnd_dir=0 If hor_wnd_spd<0 Then hor_wnd_spd=0 'measure apogeen model SI-121 'measure sensor body temperature (green wire to SE23, white wire to EX1, blue wire to ground) BrHalf(SBTempC,1,Autorange,23,VX1,1,2500,TRUE,200,250,1.0,0) 'BrHalf measures the ratio of the measured voltage divided by the excitation voltage, use the following step to convert the measurement to real temperature 'first convert to resistance SBTempC=24900*(1/SBTempC-1) 'second the Steinhart and Hart equation is used to calcualte temperature from resistance SBTempC=1.129241*(10^(-3))+2.341077*(10^(-4))*LN(SBTempC)+8.775468*(10^(-8))*((LN(SBTempC))^3) SBTempC=1/SBTempC-273.15 'measure mV output of thermopile detector (red wire to 13H, black wire to 13L, clear wire to ground) VoltDiff (TargmV,1,Autorange,13,True,200,250,1.0,0) 'Calculation of m (slope) and b (intercept) coefficients for target temperature calculation m = mC2 * SBTempC^2 + mC1 * SBTempC + mC0 b = bC2 * SBTempC^2 + bC1 * SBTempC + bC0 'Calculation of target temperature SBTempK = SBTempC + 273.15 TargTempK = ((SBTempK^4) + m * TargmV + b)^0.25 TargTempC = TargTempK - 273.15 'Delay the analog measurements by three or six scans. CallTable scan_3_6 'Delay the CSAT3 measurements by one or four scans. CallTable scan_1_4 If ( scan_count >= ANALOG_DELAY ) Then 'Load in analog measurements that have been delayed by three or six scans. GetRecord (analog_data(1),scan_3_6,ANALOG_DELAY) panel_temp = analog_data(1) 'Load in CSAT3 measurements that have been delayed by one or four scans. GetRecord (Ux,scan_1_4,CSAT_DELAY) wind_east = -1*Uy wind_north = Ux 'Define 61502 in the diagnostic word as NaN. If ( diag_csat = NaN ) Then ( diag_csat = 61502 ) 'Break up the four CSAT3 warning flags into four separate bits. del_T_f = (diag_csat AND &h8000)/&h8000 track_f = (diag_csat AND &h4000)/&h4000 amp_h_f = (diag_csat AND &h2000)/&h2000 amp_l_f = (diag_csat AND &h1000)/&h1000 'Turn on the intermediate processing disable flag when any CSAT3 warning flag is high, including the 'special cases NaN (61502), a Lost Trigger (61440), No Data (61503), an SDM error (61441), or wrong CSAT3 'embedded code (61442). If ( diag_csat AND &hf000 ) Then disable_flag_on(1) = TRUE Else disable_flag_on(1) = FALSE EndIf 'Totalize the CSAT3 diagnostic warning flags only. Turn on the intermediate processing disable flag during 'the CSAT3 special cases NaN (61502), a Lost Trigger (61440), No Data (61503), an SDM error (61441), 'or wrong CSAT3 embedded code (61442). If ( (diag_csat AND &hf000) = &hf000 ) Then disable_flag_on(3) = TRUE Else disable_flag_on(3) = FALSE EndIf 'Save only the four most significant bits of the CSAT3 diagnostics, except for the special cases 'NaN (61502), a Lost Trigger (61440), No Data (61503), an SDM error (61441), or wrong CSAT3 'embedded code (61442). If ( diag_csat < &hf000 ) Then ( diag_csat = INT ((diag_csat AND &hf000)/&h1000) ) 'Swap the LI-7500 diagnostic bit state. diag_irga = diag_irga XOR &h00f0 'Turn on the intermediate processing disable flag when the LI-7500 has failed to send data to the 'CR5000 via SDM. If ( (co2 < -99990) OR (co2 = NaN) ) Then (diag_irga = &h00ff) 'Set all flags high and rail the AGC to 94. 'Compute the AGC. agc = INT ((diag_irga AND &h000f) * 6.25 + 0.5) 'Break up the four LI-7500 warning flags into four separate bits and swap bit state. chopper_f = (diag_irga AND &h0080)/&h0080 detector_f = (diag_irga AND &h0040)/&h0040 pll_f = (diag_irga AND &h0020)/&h0020 sync_f = (diag_irga AND &h0010)/&h0010 'Turn on the intermediate processing disable flag when any LI-7500 warning flag is high, including the 'special cases NaN or an SDM error. If ( diag_irga AND &h00f0 ) Then disable_flag_on(2) = TRUE Else disable_flag_on(2) = FALSE EndIf 'Totalize the LI-7500 diagnostic warning flags only. Turn on the intermediate processing disable flag during ' the LI-7500 special cases NaN (255) or SDM error (255). If ( (diag_irga AND &h00ff) = &h00ff ) Then disable_flag_on(4) = TRUE Else disable_flag_on(4) = FALSE EndIf 'Save only the four most significant bits of the LI-7500 diagnostic word. diag_irga = INT ((diag_irga AND &h00f0)/&h0010) 'Apply calibration and wind correction to net radiometer measurement. If ( NOT (disable_flag_on(1)) ) Then hor_wind = SQR (Ux*Ux+Uy*Uy) If (Rn_Q7_1 > 0) Then Rn_Q7_1 = Rn_Q7_1*Q7_1_POS_CAL*(1+(0.0132*hor_wind)/(0.066+(0.2*hor_wind))) Else Rn_Q7_1 = Rn_Q7_1*Q7_1_NEG_CAL*((0.00174*hor_wind)+0.99755) EndIf Else If (Rn_Q7_1 > 0) Then Rn_Q7_1 = Rn_Q7_1*Q7_1_POS_CAL*1.045 Else Rn_Q7_1 = Rn_Q7_1*Q7_1_NEG_CAL EndIf EndIf 'Compute the molar concentration of co2 and h2o. t_hmp_K = t_hmp+273.15 co2_u_mol = co2_mm_m3*R*t_hmp_K/press*1000 h2o_m_mol = h2o_mm_m3*R*t_hmp_K/press 'Write a file mark to the time series table every twenty-four hours with a five hour offset. 'The filemark is written only to the PC Card if time series data are being stored. If ( even_min_flag_on AND IfTime (300,1440,Min) ) Then ( FileMark (ts_data) ) 'Start saving the time series data on a even minute boundary. If ( save_ts_flag_on ) Then If ( IfTime (0,1,Min) ) Then ( even_min_flag_on = TRUE ) Else even_min_flag_on = FALSE EndIf CallTable ts_data 'Load cov_in() array for the covariance computation. cov_in(1) = Uz cov_in(2) = Ux cov_in(3) = Uy cov_in(4) = co2 cov_in(5) = h2o cov_in(7) = Ts CallTable comp_cov If ( comp_cov.Output(1,1) ) Then GetRecord (cov_out(1),comp_cov,1) 'The compass wind direction will be between 0 and 360 degrees. wnd_dir_compass = (wnd_dir_compass+ANGLE_FROM_NORTH) If ( wnd_dir_compass ) < 0 Then ( wnd_dir_compass = wnd_dir_compass+360 ) wnd_dir_compass = wnd_dir_compass MOD 360 'The CSAT3 wind direction will be between 0 to 180 degrees and 0 to -180 degrees. If ( wnd_dir_csat3 ) > 180 Then ( wnd_dir_csat3 = wnd_dir_csat3-360 ) 'Compute on-line fluxes. Fc_irga = cov_Uz_co2 LE_irga = LV*cov_Uz_h2o Hs = rho_a_mean*CP*cov_Uz_Ts tau = SQR ((cov_Uz_Ux*cov_Uz_Ux)+(cov_Uz_Uy*cov_Uz_Uy)) u_star = SQR (tau) tau = rho_a_mean*tau 'Convert dry air density to g/m^3. rho_d_mean = 1e3*rho_d_mean sigma_wpl = h2o_mean/rho_d_mean 'Webb et al. term for water vapor Eq. (25). h2o_wpl_LE = 1.61*sigma_wpl*LE_irga h2o_wpl_H = (1+(1.61*sigma_wpl))*h2o_mean/(t_hmp_mean+273.15)*LV*cov_Uz_Ts 'Webb et al. term for carbon dioxide Eq (24). co2_wpl_LE = 1.61*co2_mean/rho_d_mean*cov_Uz_h2o co2_wpl_H = (1+(1.61*sigma_wpl))*co2_mean/(t_hmp_mean+273.15)*cov_Uz_Ts LE_wpl = LE_irga+h2o_wpl_LE+h2o_wpl_H Fc_wpl = Fc_irga+co2_wpl_LE+co2_wpl_H EndIf CallTable flux Else scan_count = scan_count+1 EndIf NextScan EndProg