📄 3d_li_nohmp_v2_2.cr1
字号:
Dim rho_d_mean 'Density of dry air used in Webb et al. term [kg / m^3].
'Dim diag_csat_work As Long 'Working variable used to break out the CSAT3 diagnostic bits.
Dim diag_irga_work As Long 'Working variable used to break out the LI-7500 diagnostic bits.
'*** Final Output Data Tables ***
'Online flux data.
DataTable (flux,TRUE,FLUX_SIZE_CPU)
DataInterval (0,OUTPUT_INTERVAL,Min,10)
CardOut (0,-1)
' Sample (1,Hs,IEEE4)
' Sample (1,Fc_wpl,IEEE4)
' Sample (1,LE_wpl,IEEE4)
' Sample (1,Hc,IEEE4)
' Sample (1,tau,IEEE4)
' Sample (1,u_star,IEEE4)
'
' Sample (1,Ts_mean,IEEE4)
' Sample (4,stdev_Ts,IEEE4)
Sample (1,co2_mean,IEEE4)
'Sample (4,stdev_co2,IEEE4)
Average (1,h2o,IEEE4,disable_flag_on(2))
'Sample (4,stdev_h2o,IEEE4)
' Average (1,Ux,IEEE4,disable_flag_on(1))
' Sample (3,stdev_Ux,IEEE4)
' Average (1,Uy,IEEE4,disable_flag_on(1))
' Sample (2,stdev_Uy,IEEE4)
' Average (1,Uz,IEEE4,disable_flag_on(1))
' Sample (1,stdev_Uz,IEEE4)
Sample (1,press_mean,IEEE4)
Sample (1,rho_a_mean,IEEE4)
' Sample (1,wnd_dir_compass,IEEE4)
' Sample (1,wnd_dir_csat3,IEEE4)
' Sample (1,wnd_spd,IEEE4)
' Sample (1,rslt_wnd_spd,IEEE4)
' Sample (1,std_wnd_dir,IEEE4)
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)
' Totalize (1,n,IEEE4,cov_disable_flag)
' Totalize (1,n,IEEE4,NOT (disable_flag_on(1) OR disable_flag_on(3)))
' FieldNames ("csat_warnings")
Totalize (1,n,IEEE4,NOT (disable_flag_on(1) OR disable_flag_on(2)))
FieldNames ("irga_warnings")
' Totalize (1,n,IEEE4,NOT (del_T_f) OR NOT (disable_flag_on(3)))
' FieldNames ("del_T_f_Tot")
' Totalize (1,n,IEEE4,NOT (sig_lck_f) OR NOT (disable_flag_on(3)))
' FieldNames ("sig_lck_f_Tot")
' Totalize (1,n,IEEE4,NOT (amp_h_f) OR NOT (disable_flag_on(3)))
' FieldNames ("amp_h_f_Tot")
' Totalize (1,n,IEEE4,NOT (amp_l_f) OR NOT (disable_flag_on(3)))
' FieldNames ("amp_l_f_Tot")
Totalize (1,n,IEEE4,NOT (chopper_f) OR NOT (disable_flag_on(2)))
FieldNames ("chopper_f_Tot")
Totalize (1,n,IEEE4,NOT (detector_f) OR NOT (disable_flag_on(2)))
FieldNames ("detector_f_Tot")
Totalize (1,n,IEEE4,NOT (pll_f) OR NOT (disable_flag_on(2)))
FieldNames ("pll_f_Tot")
Totalize (1,n,IEEE4,NOT (sync_f) OR NOT (disable_flag_on(2)))
FieldNames ("sync_f_Tot")
Average (1,agc,IEEE4,disable_flag_on(2))
Average (1,panel_temp,IEEE4,FALSE)
Average (1,batt_volt,IEEE4,FALSE)
EndTable
'Time series data.
DataTable (ts_data,save_ts_flag_on,-1)
DataInterval (0,SCAN_INTERVAL,mSec,100)
CardOut (0,-1)
' Sample (1,Ux,IEEE4)
' Sample (1,Uy,IEEE4)
' Sample (1,Uz,IEEE4)
' Sample (1,Ts,IEEE4)
Sample (1,co2,IEEE4)
Sample (1,h2o,IEEE4)
Sample (1,press,IEEE4)
' Sample (1,diag_csat,IEEE4)
EndTable
'*** Working Data Tables ***
'Reorder the data and prepare to lag all the data.
DataTable (dly_data,TRUE,OFFSET)
Sample (1,panel_temp_raw,IEEE4)
' Sample (1,Ux_raw,IEEE4)
' Sample (1,Uy_raw,IEEE4)
' Sample (1,Uz_raw,IEEE4)
' Sample (1,Ts_raw,IEEE4)
' Sample (1,diag_csat_raw,IEEE4)
Sample (1,co2_raw,IEEE4)
Sample (1,h2o_raw,IEEE4)
Sample (1,press_raw,IEEE4)
Sample (1,diag_irga_raw,IEEE4)
EndTable
'Compute the flux covariances and 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)
' 'Compute covariances from CSAT3 data.
' Covariance (4,cov_array(1,1),IEEE4,disable_flag_on(1),10)
' 'Compute covariance of CO2 against CSAT3 wind data.
' Covariance (4,cov_array(2,1),IEEE4,cov_disable_flag,4)
' 'Compute covariance of H2O against CSAT3 wind data.
' Covariance (4,cov_array(3,1),IEEE4,cov_disable_flag,4)
' WindVector (1,wind_east,wind_north,IEEE4,disable_flag_on(1),0,1,2)
' WindVector (1,Uy,Ux,IEEE4,disable_flag_on(1),0,1,2)
' Average (1,Ts,IEEE4,disable_flag_on(1))
Average (1,h2o,IEEE4,disable_flag_on(2))
Average (1,co2,IEEE4,disable_flag_on(2))
Average (1,press,IEEE4,disable_flag_on(2))
EndTable
'*** Program ***
BeginProg
n = 1
' 'Set all CSAT3 variables to NaN.
' Move (Ux_raw,5,NaN,1)
'Set all LI-7500 variables to NaN.
Move (co2_raw,4,NaN,1)
'Set the SDM clock speed.
SDMSpeed (SDM_PER)
Scan (SCAN_INTERVAL,mSec,SCAN_BUFFER_SIZE,0)
'Datalogger panel temperature.
PanelTemp (panel_temp_raw,250)
' 'Get CSAT3 wind and sonic temperature data.
' CSAT3 (Ux_raw,1,3,91,CSAT_OPT)
'Get LI-7500 data.
CS7500 (co2_raw,1,7,6)
'Measure battery voltage.
Battery (batt_volt)
'Lag the CSAT3 and LI-7500 measurements.
CallTable dly_data
If ( scan_count >= OFFSET ) Then
' 'Load in the analog data that has been lagged by OFFSET scans.
' GetRecord (dly_data_out(1),dly_data,OFFSET)
' Move (panel_temp,1,dly_data_out(1),1) 'panel_temp
'
' 'Load in CSAT3 data that has been lagged by CSAT_REC_BCK scans.
' GetRecord (dly_data_out(1),dly_data,CSAT_REC_BCK)
' Move (Ux,5,dly_data_out(2),5) 'Ux, Uy, Uz, Ts, diag_csat
'Load in the LI-7500 data that has been lagged by IRGA_REC_BCK scans.
GetRecord (dly_data_out(1),dly_data,IRGA_REC_BCK)
Move (co2,4,dly_data_out(2),4) 'co2, h2o, press, diag_irga
' 'Copy and convert CSAT3 for compass wind vector computation.
' wind_east = -1*Uy
' wind_north = Ux
'Save the molar density to compute molar concentration.
co2_mm_m3 = co2
h2o_mm_m3 = h2o
' 'Compute the molar concentration of CO2 and H2O.
' co2_um_m = co2_mm_m3*R*(Ts+273.15)/press*1000
' h2o_mm_m = h2o_mm_m3*R*(Ts+273.15)/press
'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
' 'Define 61502 as NaN.
' If ( diag_csat = NaN ) Then ( diag_csat = 61502 )
' 'Break up the four CSAT3 warning flags into four separate bits.
' diag_csat_work = diag_csat
' del_T_f = diag_csat_work AND &h8000
' sig_lck_f = diag_csat_work AND &h4000
' amp_h_f = diag_csat_work AND &h2000
' amp_l_f = diag_csat_work AND &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).
' disable_flag_on(1) = diag_csat_work AND &hf000
' 'Turn on only when CSAT3 diagnostic warning flags are set.
' disable_flag_on(3) = ( disable_flag_on(1) AND NOT (Ts = NaN) )
'Save 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_work < &hf000 ) Then ( diag_csat = INT (diag_csat_work/&h1000) )
'Swap the LI-7500 diagnostic bit state.
diag_irga = diag_irga XOR &h00f0
diag_irga_work = diag_irga
'Turn on the intermediate processing disable flag when the LI-7500 has failed to
' send data to the datalogger via SDM. Set all flags high and rail the AGC to 94.
If ( (co2 < -99990) OR (co2 = NaN) ) Then (diag_irga_work = &h00ff)
'Compute the AGC.
agc = INT ((diag_irga_work AND &h000f)*6.25+0.5)
'Break up the four LI-7500 warning flags into four separate bits.
chopper_f = diag_irga_work AND &h0080
detector_f = diag_irga_work AND &h0040
pll_f = diag_irga_work AND &h0020
sync_f = diag_irga_work AND &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.
disable_flag_on(1) = diag_irga_work AND &h00f0
'Turn on only when LI-7500 diagnostic warning flags are set.
disable_flag_on(2) = ( disable_flag_on(2) AND NOT (diag_irga_work >= &h00ff) )
'Save only the four most significant bits of the LI-7500 diagnostic word.
diag_irga = INT (diag_irga_work/&h0010)
' 'Filter data in the covariance instruction if the CSAT3 or LI-7500 reports bad data.
' cov_disable_flag = disable_flag_on(1) OR disable_flag_on(2)
' 'Start saving the time series data on an even minute boundary.
' If ( (NOT (save_ts_flag_on)) AND (IfTime (0,1,Min)) ) Then ( save_ts_flag_on = TRUE )
'Save adjusted time series data.
CallTable ts_data
' 'Load the arrays that hold the input data for the covariance instructions.
' cov_array(1,1) = Ts
' Move (cov_array(1,2),3,Ux,3)
' cov_array(2,1) = co2
' Move (cov_array(2,2),3,Ux,3)
' cov_array(3,1) = h2o
' Move (cov_array(3,2),3,Ux,3)
'Compute the online covariances.
CallTable comp_cov
If ( comp_cov.Output(1,1) ) Then
GetRecord (cov_out(1),comp_cov,1)
' 'Compass wind direction will be between 0 and 360 degrees.
' wnd_dir_compass = (wnd_dir_compass+CSAT3_AZIMUTH) MOD 360
'
' '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 )
' rho_d_mean = (press_mean/((Ts_mean+273.15)*RD))-(h2o_mean*MU_WPL)
rho_a_mean = (rho_d_mean+h2o_mean)/1000
'Compute online fluxes.
' Fc_irga = cov_co2_Uz
' LE_irga = LV*cov_h2o_Uz
' Hs = rho_a_mean*CP*cov_Ts_Uz
'
' tau = SQR ((cov_Ux_Uz*cov_Ux_Uz)+(cov_Uy_Uz*cov_Uy_Uz))
' u_star = SQR (tau)
' tau = rho_a_mean*tau
'Compute the standard deviation from the variance.
' stdev_Ts = SQR (stdev_Ts)
' stdev_Ux = SQR (stdev_Ux)
' stdev_Uy = SQR (stdev_Uy)
' stdev_Uz = SQR (stdev_Uz)
stdev_co2 = SQR (stdev_co2)
stdev_h2o = SQR (stdev_h2o)
sigma_wpl = h2o_mean/rho_d_mean
' 'LI-7500 Webb et al. term for water vapor Eq. (25).
' h2o_wpl_LE = MU_WPL*sigma_wpl*LE_irga
' h2o_wpl_H = (1+(MU_WPL*sigma_wpl))*h2o_mean/(Ts_mean+273.15)*LV*cov_Ts_Uz
' LE_wpl = LE_irga+h2o_wpl_LE+h2o_wpl_H
'
' 'Compute a sensible heat flux from Hs and LE_wpl.
' Hc = (Hs-(rho_a_mean*CP*0.51*RD*(Ts_mean+273.15)*(Ts_mean+273.15)*LE_wpl)/(press_mean*LV))
'
' 'LI-7500 Webb et al. term for carbon dioxide Eq. (24).
' co2_wpl_LE = MU_WPL*co2_mean/rho_d_mean*cov_h2o_Uz
' co2_wpl_H = (1+(MU_WPL*sigma_wpl))*co2_mean/(Ts_mean+273.15)*Hc/(rho_a_mean*CP)
' Fc_wpl = Fc_irga+co2_wpl_LE+co2_wpl_H
EndIf
CallTable flux
Else
scan_count = scan_count+1
EndIf
NextScan
EndProg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -