forked from hydromad/hydromad
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQueanbeyan.R
30 lines (26 loc) · 930 Bytes
/
Queanbeyan.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Queanbeyan <- local({
## read files from doc directory
pqdat <- read.table("Queanbeyan.dat",
sep = ",", col.names = c("P", "Q", "Date"), as.is = TRUE
)
tdat <- read.table("t_cotter.csv",
sep = ",", col.names = c("T", "Date"), as.is = TRUE
)
## convert dates
pqdat$Date <- as.Date(pqdat$Date, "%d/%m/%Y")
tdat$Date <- as.Date(tdat$Date, "%d/%m/%Y")
## convert missing values
pqdat$P[pqdat$P < 0] <- NA
pqdat$Q[pqdat$Q < 0] <- NA
tdat <- subset(tdat, !is.na(Date))
## convert from ML to mm (i.e. divide by catchment area km^2)
pqdat$Q <- pqdat$Q / 490
# pqdat$Q <- convertFlow(pqdat$Q, from = "ML", area.km2 = 490)
## zoo objects
library(zoo)
tsPQ <- zoo(pqdat[, 1:2], order.by = pqdat$Date, frequency = 1)
tsT <- zoo(tdat[, 1], order.by = tdat$Date, frequency = 1)
tsPQE <- merge(tsPQ, E = tsT, all = FALSE)
na.trim(tsPQE)
})
usethis::use_data(Queanbeyan, overwrite = TRUE)