View source: R/smooth_tdl_data.R
smooth_tdl_data | R Documentation |
Tool for applying a smoothing function to the time series corresponding to measurements from a single valve in a tunable diode laser (TDL) data set.
smooth_tdl_data(
tdl_exdf,
column_to_be_smoothed,
valve_column_name,
valve_number,
smoothing_function
)
tdl_exdf |
An |
column_to_be_smoothed |
The name of the column in |
valve_column_name |
The name of the column in |
valve_number |
The value of the |
smoothing_function |
A function that accepts two vectors |
The output from a TDL is highly sensitive to electronic and atmospheric noise,
and it is often helpful to smooth the data from one or more valves before
attempting to apply calibration corrections or determine the content of an
unknown gas mixture. smooth_tdl_data
is a convenience function that
extracts a time series corresponding to data from one valve, applies a
smoothing operation, and replaces the original data in tdl_exdf
with
the smoothed version. The smoothing function is user-supplied to allow more
flexbility.
In addition to the column_to_be_smoothed
and valve_column_name
columns, the tdl_exdf
must also contain an 'elapsed_time'
column, which is typically created by a call to
identify_tdl_cycles
.
An exdf
object based on tdl_exdf
, where the time series of
column_to_be_smoothed
vs. 'elapsed_time'
has been replaced by a
smoothed version obtained by applying the smoothing_function
.
# Example: Smoothing the 12C signal from one TDL valve using a spline fit
tdl_file <- read_gasex_file(
PhotoGEA_example_file_path('tdl_sampling_1.dat'),
'TIMESTAMP'
)
tdl_file <- identify_tdl_cycles(
tdl_file,
valve_column_name = 'valve_number',
cycle_start_valve = 20,
expected_cycle_length_minutes = 2.7,
expected_cycle_num_valves = 9,
timestamp_colname = 'TIMESTAMP'
)
spline_smoothing_function <- function(Y, X) {
ss <- smooth.spline(X, Y)
return(ss$y)
}
spline_smoothed_tdl_file <- smooth_tdl_data(
tdl_file, 'Conc12C_Avg', 'valve_number', 20, spline_smoothing_function
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.