Skip to content

Commit 0838976

Browse files
Merge pull request #114 from COMPASS-DOE/handle-no-footer-data
Warn and skip if no smart chamber footer data
2 parents 17dd8fb + a0acb22 commit 0838976

File tree

4 files changed

+136
-2
lines changed

4 files changed

+136
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ Suggests:
3636
testthat (>= 3.0.0),
3737
withr (>= 2.0)
3838
Config/testthat/edition: 3
39-
RoxygenNote: 7.3.2
39+
RoxygenNote: 7.3.3
4040
VignetteBuilder: knitr
4141
BugReports: https://github.com/COMPASS-DOE/fluxfinder/issues

R/read_data_functions.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,15 @@ ffi_read_LIsmartchamber <- function(file, concentrations = TRUE) {
291291
}
292292
footer_df <- as.data.frame(footer_info)
293293

294+
# Sanity check: make sure header and footer have data
295+
if(nrow(header_df) == 0) {
296+
warning("No header information for observation ", obs, "; skipping")
297+
next
298+
}
299+
if(nrow(footer_df) == 0) {
300+
warning("No footer information for observation ", obs, "; skipping")
301+
next
302+
}
294303
# Combine and store; note that the 1-row data frames get
295304
# replicated to have as many rows as the data
296305
final_dat[[paste(obs, rep)]] <- cbind(rep_df, header_df, data_df, footer_df)
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
{ "name": "LE_CRC_11_7_2022",
2+
"remark": "",
3+
"date":1667815847,
4+
"datasets": [
5+
{ "TrS33":
6+
{
7+
"remark": "",
8+
"reps":
9+
{
10+
"REP_1": {
11+
"header":{
12+
"Chamber":"82s-1031",
13+
"Version":"1.1",
14+
"InstrumentModel":"generic",
15+
"InstrumentSerialNumber":"generic",
16+
"Date":"2022-11-07 12:17:00",
17+
"RepNum":1,
18+
"DeadBand":5,
19+
"Area":318,
20+
"Offset":5,
21+
"ChamVolume":4244.1,
22+
"IrgaVolume":80.46,
23+
"TotalVolume":5914.56,
24+
"gps_time":1667841420,
25+
"latitude":41.622,
26+
"longitude":-83.2381,
27+
"gps_hdop":1.05,
28+
"altitude":178.7,
29+
"gps_sats":11,
30+
"TimeZone":"US/Eastern"
31+
},
32+
"labels":{
33+
"area":"Area",
34+
"volume":"TotalVolume",
35+
"deadband":"DeadBand",
36+
"etime":"timestamp",
37+
"pressure":"chamber_p",
38+
"temperature":"chamber_t",
39+
"h2o":""
40+
},
41+
"data":{
42+
"timestamp":[1,2,3,4,5,6,7,8,9,
43+
10,11,12,13,14,15,16,17,18,19,
44+
20,21,22,23,24,25,26,27,28,29,
45+
30,31,32,33,34,35,36,37,38,39,
46+
40,41,42,43,44,45,46,47,48,49,
47+
50,51,52,53,54,55,56,57,58,59,
48+
60],
49+
"chamber_p":[100.988,100.983,100.989,100.985,100.986,100.979,100.983,100.976,100.981,
50+
100.982,100.978,100.975,100.971,100.975,100.971,100.972,100.968,100.972,100.977,
51+
100.973,100.968,100.967,100.968,100.965,101.005,100.996,100.985,100.981,100.979,
52+
100.975,100.973,100.995,100.995,100.982,100.988,100.987,100.98,100.982,100.979,
53+
100.983,100.986,100.979,100.979,100.981,100.991,100.981,100.986,100.984,100.983,
54+
100.987,100.989,100.988,100.984,100.992,100.99,100.987,100.985,100.986,100.988,
55+
100.989],
56+
"chamber_p_t":[20.8438,20.8333,20.8646,20.875,20.9062,20.9062,20.9479,20.9375,21.0125,
57+
21.0417,21.0312,21.0625,21.0729,21.0938,21.1146,21.1458,21.1625,21.1875,21.2292,
58+
21.2292,21.2292,21.2604,21.2708,21.2917,21.3438,21.3125,21.3438,21.375,21.3958,
59+
21.4167,21.4062,21.4583,21.4792,21.475,21.5104,21.5417,21.5312,21.5833,21.5833,
60+
21.625,21.6562,21.6354,21.6625,21.6667,21.7292,21.7083,21.7396,21.75,21.7604,
61+
21.7917,21.8125,21.8333,21.8333,21.8854,21.8958,21.8854,21.8854,21.9271,21.9375,
62+
21.975],
63+
"chamber_t":[16.4906,16.4805,16.4738,16.4724,16.4741,16.4758,16.4785,16.4815,16.4845,
64+
16.4881,16.4894,16.4884,16.4879,16.4881,16.4876,16.4874,16.4886,16.4908,16.4968,
65+
16.5034,16.5094,16.5138,16.5197,16.5249,16.5279,16.5307,16.5338,16.5412,16.5484,
66+
16.5544,16.5573,16.56,16.5647,16.5699,16.5732,16.5776,16.5831,16.5878,16.592,
67+
16.5999,16.6081,16.6173,16.6273,16.6357,16.6401,16.6446,16.6483,16.6535,16.6617,
68+
16.6692,16.6735,16.6784,16.6866,16.6941,16.7008,16.7107,16.7177,16.7227,16.7274,
69+
16.7356],
70+
"soil_t":[9999,9999,9999,9999,9999,9999,9999,9999,9999,
71+
9999,9999,9999,9999,9999,9999,9999,9999,9999,9999,
72+
9999,9999,9999,9999,9999,9999,9999,9999,9999,9999,
73+
9999,9999,9999,9999,9999,9999,9999,9999,9999,9999,
74+
9999,9999,9999,9999,9999,9999,9999,9999,9999,9999,
75+
9999,9999,9999,9999,9999,9999,9999,9999,9999,9999,
76+
9999],
77+
"soilp_c":[0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.001,0.019,
78+
0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,
79+
0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,
80+
0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,
81+
0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,
82+
0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,0.019,
83+
0.019],
84+
"soilp_m":[0,0,0,0,0,0,0,0,0.178,
85+
0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,
86+
0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,
87+
0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,
88+
0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,
89+
0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,0.178,
90+
0.178],
91+
"soilp_t":[16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,
92+
16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,
93+
16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,
94+
16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,
95+
16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,
96+
16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,16.7,
97+
16.7]
98+
},
99+
"summary":{
100+
"timestamp":[0,30.5,59],
101+
"chamber_p":[100.988,100.982,0.0395813],
102+
"chamber_p_t":[20.7963,21.415,1.14167],
103+
"chamber_t":[16.4778,16.5705,0.263294],
104+
"soil_t":[9999,9999,0],
105+
"soilp_c":[-0.005,0.0166,0.018],
106+
"soilp_m":[-0.0593333,0.154267,0.178],
107+
"soilp_t":[16.7,16.7,0]
108+
},
109+
"footer":{
110+
"P_o":100.988,
111+
"T_o":16.4778,
112+
"W_o":0,
113+
"fluxes":[
114+
]
115+
}
116+
}
117+
}
118+
}
119+
}
120+
]
121+
}

tests/testthat/test-read_functions.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,13 @@ test_that("ffi_read_LIsmartchamber works", {
107107
expect_true("TIMESTAMP" %in% names(x))
108108
expect_s3_class(x$TIMESTAMP, "POSIXct")
109109

110-
# Bad data with no concentration data
110+
# Bad data -- no concentration data
111111
expect_warning(ffi_read_LIsmartchamber("data/LI8200-01S-bad-data.json"),
112112
regexp = "0-row data")
113+
# Bad data -- no footer
114+
# (see https://github.com/COMPASS-DOE/fluxfinder/issues/113)
115+
expect_warning(ffi_read_LIsmartchamber("data/LI8200_bad_no_footer.json"),
116+
regexp = "No footer")
113117
})
114118

115119
test_that("ffi_read_LI850 works", {

0 commit comments

Comments
 (0)