HARPgroup / HARParchive

This repo houses HARP code development items, resources, and intermediate work products.
1 stars 0 forks source link

HARP 2024/2025 Week 2: June 10th-June 14th #1271

Open mwdunlap2004 opened 2 weeks ago

mwdunlap2004 commented 2 weeks ago

Here's our plan for the following week after our discussion on Thursday afternoon.

durelles commented 2 weeks ago

@mwdunlap2004 @ilonah22

Here's a great place to get started: https://cran.r-project.org/web/views/Hydrology.html

Here's some more ideas to jump off from:::

Prompt: I am a hydrologist that uses the R programming language to analyse long-term daily streamflow records. I would like to use a R-package that includes an approach for baseflow separation. List some R-packages that I can explore to perform this task.

Copilot Certainly! Here are some R packages that you can explore for baseflow separation in hydrology:

hydroTSM: This package is excellent for working with timeseries data. While it doesn’t specifically focus on baseflow separation, it provides useful tools for hydrological analysis1. lfstat: If you’re interested in calculating various low-flow statistics, lfstat is a good choice2. EcoHydRology: This package contains an automated digital filter for baseflow separation from streamflow data2. baseflow: The baseflow package computes hydrograph separation using the conceptual automated process from Pelletier and Andreassian (2020). It includes scalar and vectorized functions to compute correlation criteria for calibrating the baseflow separation model3. baseflow_sep: Another package that performs baseflow separation. It uses a parameter c (varying between 0 and 1) to separate baseflow from runoff. The method “constant_slope” draws a line with a constant slope from the hydrograph minima to the next intersection with it4.

durelles commented 2 weeks ago

Team - I tried grwat package this morning that has a base flow separation function. See below.

Screenshot 2024-06-10 at 9 34 02 AM
library(grwat)
library(ggplot2)
library(dplyr)
library(tidyr)
library(lubridate)

Obtain Streamflow

Initially tried 15-minute data and separation fails. Daily data appears to work. There are multiple approaches to apply; I used the default. Examples are provided in the function help menu.


site_id <- "01634000"
parameterCd <- "00060"
startDate <- "2022-10-01"
endDate <- "2023-10-01"

rawdata <- dataRetrieval::readNWISdv(site_id, parameterCd, startDate, endDate)
rawdata <- rawdata %>% 
  rename(Q = X_00060_00003, dateTime = Date)

Baseflow in grwat

Daily data appears to work. There are multiple approaches to apply; I used the default. Examples are provided in the function help menu.


hdata = rawdata %>% 
  mutate(Qbase = gr_baseflow(Q, method = 'lynehollick', 
                                   a = 0.925, passes = 3))

gp <- ggplot(hdata) +
  geom_area(aes(dateTime, Q), fill = 'steelblue', color = 'black') +
  geom_area(aes(dateTime, Qbase), fill = 'orangered', color = 'black')
gp