Commit efd72951 authored by Dorchies David's avatar Dorchies David
Browse files

refactor: some simplifications

parent f95a3be1
1 merge request!2Calculate filling rule curve based on mSPA
Showing with 11 additions and 14 deletions
+11 -14
...@@ -7,24 +7,23 @@ data <- readr::read_delim( ...@@ -7,24 +7,23 @@ data <- readr::read_delim(
delim = "\t", col_names = c("inflow", "release", "precip", "evapo", "downstreamFlow") delim = "\t", col_names = c("inflow", "release", "precip", "evapo", "downstreamFlow")
) )
time <- time <- seq(as.Date("1961/1/1"), as.Date("2007/12/31"), "month")
data.frame(seq(as.Date("1961/1/1"), as.Date("2007/12/31"), "month")) stora <- data.frame(
month <- Month = format(
data.frame(format(
as.Date( as.Date(
time$seq.as.Date..1961.1.1....as.Date..2007.12.31.....month.., time,
format = "%Y-%m-%d" format = "%Y-%m-%d"
), ),
"%m" "%m"
)) ),
year <- Year= format(
data.frame(format(
as.Date( as.Date(
time$seq.as.Date..1961.1.1....as.Date..2007.12.31.....month.., time,
format = "%Y-%m-%d" format = "%Y-%m-%d"
), ),
"%Y" "%Y"
)) )
)
n <- NROW(na.omit(data)) n <- NROW(na.omit(data))
Inflow <- data$inflow Inflow <- data$inflow
dem <- data$release dem <- data$release
...@@ -80,10 +79,8 @@ for (i in 2:n + 1) { ...@@ -80,10 +79,8 @@ for (i in 2:n + 1) {
Zt[i - 1] <- S - Kt1[i - 1] Zt[i - 1] <- S - Kt1[i - 1]
} }
stora <- stora$Zt <- Zt # [ Storage = reservoir capacity - Deficit ]
data.frame(year, month, Zt) # [ Storage = reservoir capacity - Deficit ]
names(stora)[1] <- "Year"
names(stora)[2] <- "Month"
ST <- reshape( ST <- reshape(
data = stora, data = stora,
idvar = "Year", idvar = "Year",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment