Skip to content

Commit c9ca7bd

Browse files
committed
Flag suspicious 1999-2001 CO drop
1 parent f2aaa84 commit c9ca7bd

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
### Changed
1515
- Prioritize V4 over V1 flags when both apply.
1616
- Replace NA flag values with M1.
17+
- Flag suspicious 1999-2001 WFMS CO drop as V4.
1718
- Create unified dataset package instead of yearly data files.
1819
- Reprocess all data starting from 2018-10-01.
1920
- Set R package version number to match dataset version.

datasets/clean_old_routine.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ patch_wfms = function(f, df) {
9797
sub('WS ', 'WS_raw ', .) %>%
9898
sub('WD ', 'WD_raw ', .)
9999
}
100+
# Flag very suspicious (probably wrong) CO dip with V4
101+
suspicious_co = df$`Time (EST)` >= as.POSIXct('1999-03-01', tz = 'EST') &
102+
df$`Time (EST)` < as.POSIXct('2001-05-02 05:00', tz = 'EST')
103+
if (any(suspicious_co)) {
104+
make_v4 = suspicious_co & df$`CO (flag)` != 'M1'
105+
df$`CO (flag)`[make_v4] = 'V4'
106+
}
100107
# In July 2014, something knocked the wind direction sensor off by 140
101108
# degrees. Brian, not yet knowing the true offset or timing of the error,
102109
# corrected the winds by 75 degrees, gradually phasing in the full 75 degree
@@ -277,7 +284,7 @@ read_processed = function(f, index_cols = 5) {
277284
## make sure non-flag columns are numeric
278285
for (n in (index_cols + 1):(ncols - 1)) {
279286
if (!grepl('.*flag', units[n], ignore.case = T)) {
280-
if (is(df[, n], 'factor')) {
287+
if (is(df[, n], 'factor') || is(df[, n], 'character')) {
281288
warning('non-numeric values in ', names(df)[n])
282289
tmp_char = as.character(df[, n])
283290
old_nas = is.na(df[, n])

0 commit comments

Comments
 (0)