Flow Data
totals and means
LADWP data
OVGA
time series
LADWP water-year monthly volumetric flow data transfer. Code automates extracting volumetric flow data from ZRXP ASCII data exchange format, transforming and merging updates with the active database, and exporting a csv file formatted for the OVGA data management system for groundwater production and surface water gage totals.
Data
read data
file_path_flow <-here('data','hydro','2022-23 Water Year Transfer Packet for ICWD','VolumeMonthAF_2022-23.dat')
# annual update
sum_stations <- read_csv(here('data','hydro','2022-23 Water Year Transfer Packet for ICWD','summary_stations22-23.csv'))
# attribute data from wells database
staidlist <- read_csv(here('data','hydro','staid_current.csv'))
# meta data on production wells
production.meta <- read_csv(here('data','hydro','Production.csv')) %>%
select(mon_pt_name, method) %>% unique()
#historical data
monthlies <- read_csv(here('data','hydro','totals_means_thru_sep_2022.csv'))#
# meta on flow pts
flow.meta <- read_csv(here('data','hydro','Flows.csv')) %>% select(mon_pt_name, LADWP_ID) %>% unique() %>% mutate(staid = as.character(LADWP_ID)) %>% select(-LADWP_ID)
parse .dat ascii
dat_content <- readLines(file_path_flow)
# Initialize variables to store data
data_list <- list()
# Function to check if a line contains timestamp and value
is_data_line <- function(line) {
grepl("\\d+ \\d+\\.\\d+", line)
}
# Loop through each line in the file
for (line in dat_content) {
# Check if the line starts with '#TSPATH'
if (startsWith(line, "#TSPATH")) {
# Extract 'staid' from the '#TSPATH' line
staid <- sub('.*/([^/]+)/VOLUME/.*', '\\1', line)
}
# Check if the line does not start with '#' and contains timestamp and value
if (!startsWith(line, "#") && is_data_line(line) && !is.na(staid)) {
# If the line does not start with '#' and contains timestamp and value,
# add data to the list directly
data_list <- c(data_list, list(data.frame(staid, dateread = line)))
}
}
# Combine the data frames in the list into a single data frame
ann.update <- dplyr::bind_rows(data_list)
date columns
ann.update2$datetime <- ymd_hms(ann.update2$date)
ann.update3<-ann.update2 %>% mutate(year = year(datetime),
month = month(datetime),
month_abbr = month(datetime, label = TRUE, abbr = TRUE),
day = mday(datetime),
date.y.m.d = make_date(year, month,day))
# select, rename, ljoin, select columns
ann.update4<-ann.update3 %>% select(-date)%>% rename(date = date.y.m.d)%>% left_join(staidlist, by = 'staid') %>% select(staid,description,read,date,year,month,month_abbr)
# mutate case when year breaks/types
ann.update5 <- ann.update4 %>% mutate(wy = case_when(month >= 10 ~ year + 1,
month <= 9 ~ year),
roy = case_when(month <= 3 ~ year - 1,
month >= 4 ~ year),
irrag = case_when(month %in% c(4,5,6,7,8,9) ~ year))
ICWD Flow export
OVGA Flow export
split flow vs production
# 6758+2244
# flow
flowdf <- tm %>% filter(!str_detect(staid, "[[:alpha:]]"))%>%
mutate(staid = ifelse(str_detect(staid, "^0"), str_replace(staid, "^0+", ""), staid))
flow_ovga <- flowdf %>% left_join(flow.meta, by = 'staid')
# %>% filter(!is.na(mon_pt_name))
# use below
#production
proddf <- tm %>% filter(str_detect(staid, "[[:alpha:]]"))
ovga flow columns
OVGA Production export
ovga production columns
prod_ovga <- proddf %>% left_join(production.meta, by = c('staid' = 'mon_pt_name'))
tm.well.flow <- prod_ovga %>%
mutate(WellName = staid,
StartDate = date,
EndDate = ceiling_date(date,'month'),
AgUsageAF = '',
MIUsageAF = read,
TotalUsageAF = read,
Method = method,
Notes = '') %>%
select(WellName,StartDate,EndDate, AgUsageAF, MIUsageAF, TotalUsageAF, Method, Notes)
#up to date 1-30-24
removed the following staids after some iteration as they are not on the basin list: F103 V082 F380 F381 F382 F104 W426 F022 F391
QAQC Check updates on plots
Totals and Means - summary stations requested
OVR Owens Valley Runoff
OVPW Owens Valley Pumped Water
FTC L.A.A. Total Flow to the City
LOLU Lower Owens River Project – Lakes and Ponds Use
LOOU Lower Owens River Project – Operations
LORPDU Lower Owens River – Delta Uses
LORPRU Lower Owens River – River Uses
LORPTU Lower Owens River Project Total Uses
LOWU Lower Owens River Project – Waterfowl Uses
MBR Mono Basin Runoff
MTWP Mono Tunnel at West Portal
OLTU Owens Lake Total Uses
OVFG Owens Valley Flowing Groundwater
OVGR Owens Valley Groundwater Recharge
OVIR Owens Valley Irrigation
SHTO South Haiwee Total Outflow (1+2+3+BP)
Stream Flow
Little Pine Creek
Pumping
runoff year pumping totals
BP1
Code
linked_wells <- c("W210","W378","W379","W389")
DF <- tm2 %>% filter(staid %in% linked_wells) %>% mutate(case_when(read < 0 ~ 0)) %>% group_by(roy,staid)%>% summarise(total_pumping = sum(read)) %>% select(roy,staid,total_pumping) %>% mutate(roy2 = make_date(roy,4,1))
DF[is.na(DF)] <- 0
# %>% replace(is.na(.), 0)
Data <- do.call(merge, lapply(split(DF, DF$staid), tozoo))
Data %>% dygraph(group = 'a') %>%
dyStackedBarGroup(c("W210","W378","W379","W389"))%>%
dyAxis("y", label = "Total Annual Pumping (AF)", valueRange = c(0, 8000))
BP1 linked wells
BP2
Code
linked_wells <- c("W220","W229","W374","W375")
DF <- totals_means %>% filter(staid %in% linked_wells) %>% mutate(case_when(read == -777 ~ 0)) %>% group_by(roy,staid)%>% summarise(total_pumping = sum(read)) %>% select(roy,staid,total_pumping) %>% mutate(roy2 = make_date(roy,4,1)) %>% replace(is.na(.), 0)
Data <- do.call(merge, lapply(split(DF, DF$staid), tozoo))
Data %>% dygraph(group = 'a') %>%
dyStackedBarGroup(c("W220","W229","W374","W375"))%>%
dyAxis("y", label = "Total Annual Pumping (AF)", valueRange = c(0, 6000))
BP2 linked wells
BP3
Code
linked_wells <- c("W222","W223","W231","W232")
DF <- tm2 %>% filter(staid %in% linked_wells) %>% mutate(case_when(read == -777 ~ 0)) %>% group_by(roy,staid)%>% summarise(total_pumping = sum(read)) %>% select(roy,staid,total_pumping) %>% mutate(roy2 = make_date(roy,4,1))%>% replace(is.na(.), 0)
Data <- do.call(merge, lapply(split(DF, DF$staid), tozoo))
Data %>% dygraph(group = 'a') %>%
dyStackedBarGroup(c("W222","W223","W231","W232"))%>%
dyAxis("y", label = "Total Annual Pumping (AF)", valueRange = c(0, 12000))
BP3 linked wells
BP4
Code
linked_wells <- c("W331")
DF <- tm2 %>% filter(staid %in% linked_wells) %>% mutate(case_when(read == -777 ~ 0)) %>% group_by(roy,staid)%>% summarise(total_pumping = sum(read)) %>% select(roy,staid,total_pumping) %>% mutate(roy2 = make_date(roy,4,1))%>% replace(is.na(.), 0)
Data <- do.call(merge, lapply(split(DF, DF$staid), tozoo))
# Data <- tozoo(DF)
# Data
Data %>% dygraph(group = 'a') %>%
dyBarChart()%>%
dyAxis("y", label = "Total Annual Pumping (AF)", valueRange = c(0, 6000))
Exempt Wells - Fish Hatchery and 218, 219
Code
linked_wells <- c("W218","W219","W330","W332")
DF <- tm2 %>% filter(staid %in% linked_wells) %>% mutate(case_when(read == -777 ~ 0)) %>% group_by(roy,staid)%>% summarise(total_pumping = sum(read)) %>% select(roy,staid,total_pumping) %>% mutate(roy2 = make_date(roy,4,1))%>% replace(is.na(.), 0)
Data <- do.call(merge, lapply(split(DF, DF$staid), tozoo))
# Data <- tozoo(DF)
# Data
Data %>% dygraph(group = 'a')%>%
dyStackedBarGroup(c("W218","W219","W330","W332"))%>%
dyBarChart()%>%
dyAxis("y", label = "Total Annual Pumping (AF)", valueRange = c(0, 32000))
Big Pine Pumping Totals
Code
linked_wells <- c("W210","W378","W379","W389","W220","W229","W374","W375","W222","W223","W231","W232","W331","W218","W219","W330","W332")
DF <- tm2 %>% filter(staid %in% linked_wells) %>% mutate(case_when(read == -777 ~ 0)) %>% group_by(roy,staid)%>% summarise(total_pumping = sum(read)) %>% select(roy,staid,total_pumping) %>% mutate(roy2 = make_date(roy,4,1))%>% replace(is.na(.), 0)
Data <- do.call(merge, lapply(split(DF, DF$staid), tozoo))
# Data <- tozoo(DF)
# Data
Data %>% dygraph(group = 'a')%>%
dyStackedBarGroup(c("W210","W378","W379","W389","W220","W229","W374","W375","W222","W223","W231","W232","W331","W218","W219","W330","W332"))%>%
dyBarChart()%>%
dyAxis("y", label = "Total Annual Pumping (AF)", valueRange = c(0, 32000))
Big Pine Wellfield Pumping
Citation
BibTeX citation:
@report{nelson2023,
author = {Nelson, Zach},
publisher = {Inyo County Water Department},
title = {Flow {Data}},
date = {2023-01-30},
url = {https://inyo-gov.github.io/hydro-data/},
langid = {en}
}
For attribution, please cite this work as:
Nelson, Zach. 2023. “Flow Data.” Data Report. Inyo
County Water Department. https://inyo-gov.github.io/hydro-data/.