1+ # '@title cleans sensor data with user-specified routines
2+ # '@description
3+ # 'cleans sensor data according to details within the user-specified config (*yml) file \cr
4+ # '
5+ # '@param deploy a string for the *.yml file name
6+ # '@param folder a string which specifies the folder of the *.yml file
7+ # '@param plot.diagnostic a boolean for creating a diagnostic plot
8+ # '@param write.file a boolean for creating a timeseries file output
9+ # '@return An optional plot and optional file output handle
10+ # '@keywords methods
11+ # '@author
12+ # 'Jordan S. Read
13+ # '@examples
14+ # '\dontrun{
15+ # 'clean.data(deploy='pellerin',folder='/[User]/Desktop/Science Projects/sensorQC/',plot.diagnostic=FALSE)
16+ # 'clean.data(deploy='pellerin',folder='/[User]/Desktop/Science Projects/sensorQC/',plot.diagnostic=TRUE,write.file=TRUE)
17+ # '}
118# '@export
2- clean.data <- function (deploy = ' pellerin' ,folder = ' ../examples/' ){
19+ clean.data <- function (deploy = ' pellerin' ,folder = ' ../examples/' , plot.diagnostic = TRUE , write.file = FALSE ){
320 # is an example wrapper for sensorQC calls
421
522 #
@@ -23,8 +40,19 @@ clean.data <- function(deploy='pellerin',folder='../examples/'){
2340 old.inst.flags <- build_flags(data.in = windowed.data ,sqc = simple.sqc $ outlier_removal ,verbose = F )
2441 old.sensor <- block_stats(windowed.data = windowed.data ,old.inst.flags )
2542
26- plot_summary(inst.data = windowed.data ,inst.flags ,block.data = sensor.stats ,block.flags ,
27- compare.data = old.sensor ,sqc = cnfg )
43+ if (plot.diagnostic ){
44+ plot_summary(inst.data = windowed.data ,inst.flags ,block.data = sensor.stats ,block.flags ,
45+ compare.data = old.sensor ,sqc = cnfg )
46+ }
47+
48+ if (write.file ){
49+ output = paste0(folder ,deploy ," _sqc_out.tsv" )
50+ flat.block <- flatten_flags(block.flags )
51+ write.out <- sensor.stats [! flat.block , ]
52+ write.table(write.out ,file = output ,col.names = TRUE , quote = FALSE , row.names = FALSE , sep = " \t " )
53+ }
54+
55+
2856
2957
3058
0 commit comments