HARPgroup / HARParchive

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

Water Availability Case Studies #1156

Open glenncampagna opened 7 months ago

glenncampagna commented 7 months ago

Script: https://github.com/HARPgroup/HARParchive/blob/master/HARP-2023-Summer/WaterAvailability/WaterAvailability_CaseStudies.Rmd

Description: A case study is a descriptive example of a particular area (ex. a watershed/region) where water availability is calculated. For that example watershed, we can take a detailed look at the individual calculations and resulting values generated.

From #818

Current Table Examples: https://github.com/HARPgroup/HARParchive/tree/master/HARP-2023-Summer/WaterAvailability/CaseStudiesTables

Table/Figure Descriptions (modified from original guidelines):

Note: tables 5 and 6 are only created and exported when the input Smin_analysis is set to TRUE

Notes/Discussion: particular notes about running this watershed calculation, any discussion about the results as noted above, would then get written down to accompany the tables/graphs and become the case study.

*Original guidelines contained in an email from Gouri on 2/1/2024

Impoundments for Case Studies:

Inputs/Parameters: outlet_list: list of riverseg IDs which are the Case Study watershed outlets demand_scenario: scenario ID for a demand scenario (ex. runid_11) baseline_scenario: scenario ID for a baseline scenario (ex. runid_0) mif_coef: Minimum Instream Flow (PoF) coefficient (ex. 0.9) Smin_analysis: indicates whether or not the user wants to see Smin methods compared (TRUE/FALSE) write_Qavailable: whether or not to write Qavailable metric to VAhydro (TRUE/FALSE) write_outputs: where to write/save tables (local, github)

Render Example:

rmarkdown::render("~/Desktop/GitHub/HARParchive/HARP-2023-Summer/WaterAvailability/WaterAvailability_CaseStudies.Rmd", 
                  output_file = "~/Desktop/HARPteam23/WAcasestudies_knit_runid11_runid0_0.9.docx",
                  output_format = "word_document",
                  params = list(
                      outlet_list = c("PL3_5360_5250", "JU4_7000_7300", "JA5_7480_0001", "YP3_6670_6720", "OR3_7740_8271", "PU4_3970_3890"),
                      demand_scenario = 'runid_11', 
                      baseline_scenario = 'runid_0', 
                      mif_coef = 0.9, 
                      Smin_analysis = TRUE,
                      write_outputs = c("local", "github")))

Tasks:

Related Scripts and Issues:

glenncampagna commented 6 months ago

Initial 3 Table Previews

image image image

glenncampagna commented 6 months ago

Additional Table/Map/Graph Ideas

rburghol commented 6 months ago

Hey @glenncampagna these are really shaping up. In terms of showing the lowest WA in the state, I think that the overall map of WA should do that implicitly. Moreover, we would expect small streams to have low W.A., and large streams to have higher WA, so that comparison may not really be relevant.

Looking at table 3, etc., I think an important piece of context should be wd_cumulative_mgd. Including that will allow us to draw connections. Question: are you using 90% BASELINE as the target MIF for calculating the portion of WA that comes from flow? I suppose you should indicate the target MIF as well.

glenncampagna commented 6 months ago

@rburghol Ok sounds good, I'll retrieve and include the wd_cumulative_mgd values in tables. I understand what you're saying about the table being somewhat redundant to the map in terms of WA values; I guess my thinking of the table was that it could be useful to see other metrics for the segments with the lowest WA (baseflow, demand, withdrawal which we'll be adding) and if those make sense.

The in stream flow coefficient is being multiplied by the base flow metric in the Water Availability equation, yes. I currently have the coefficient as an input to the script which I forgot to include (set to 0.9 for now). Are you saying that it'd be helpful to include in table titles? I'd agree with this since the other 2 important inputs (demand and baseline scenarios) are included in the titles/headers

rburghol commented 6 months ago

Hey @glenncampagna thanks for your thoughts. I think a separate table of lowest avail would be redundant, though if we had streams with negative values that could be of interest for a separate table. Those streams would likely be ones without storage, so, you will have to make sure you're not filtering out only impoundment segments. What do you think about negative AW?

Thanks for confirming the 90% mif, and I was thinking add it as a column, i.e. L90 MIF, which would allow us to later reflect cases where we use ELFs to customize them by basin. This will make the table fairly busy so we may regret this :)

glenncampagna commented 6 months ago

@rburghol Gotcha. Are you wanting the column to contain the actual minimum in stream flow values (MIF coefficient * Baseflow metric) or just the coefficient we're using?

rburghol commented 6 months ago

Actual would be my first guess - what do you think pros/cons @gmahadwar @glenncampagna

gmahadwar commented 6 months ago

MIF: Would decide based on how often is there a MIF that's separate

Third table: Also agree on the wd_cumulative_mgd in the third table, I'm thinking about if there are other helpful columns like cumulative point source (I assume that's ps_cumulative_mgd) or the L30/L90 value itself for the rseg, and the rseg flow out

glenncampagna commented 5 months ago

Carvins question

rburghol commented 5 months ago

@glenncampagna - this is because there are no upstream segments from Carvins, it is a headwater, so where you want to do it is with the outlet being Roanoke River in Roanoke, which will then have Carvin's, Tinker Creek and all the Roanoke segments upstream of Carvins. Thus:

roaroa_data <- fn_extract_basin(wshed_data,'OR3_7740_8271')
glenncampagna commented 5 months ago

Carvins update, similar Lake Anna question

Update:

glenncampagna commented 5 months ago

Graph preview for Lake Moomaw watershed (upstream & downstream) @gmahadwar

image
gmahadwar commented 5 months ago

Thanks, @glenncampagna, can you write out the elements that go into Qavailable? Just adding to this comment is fine right now. I know you said it verbally but would be helpful for reference to explain this graph.

rburghol commented 5 months ago

Error ! object 'table_imp' not found testing with the following:

rmarkdown::render(paste0(github_location,"/HARP-2023-Summer/WaterAvailability/WaterAvailability_CaseStudies.Rmd"), 
                  output_file = paste0(export_path,"/WAcasestudies_knit_runid11_runid0_0.9.docx"),
                  output_format = "word_document",
                  params = list(
                      demand_scenario = 'runid_11', 
                      baseline_scenario = 'runid_0', 
                      mif_coef = 0.9))
glenncampagna commented 5 months ago

No baseline for Lake Anna watershed

The only case study we've chosen where it appears the baseline scenario has not been run yet is Lake Anna:

image image
glenncampagna commented 5 months ago

Lake Chesdin case study mystery basins

image

glenncampagna commented 4 months ago

Where is the function vahydro_post_metric_to_scenprop() created? I don't believe we have ever loaded it in R before and only used it in R via the command line

Answer: Add source(paste(cbp6_location, "code/cbp6_functions.R", sep = "/")) to config.R

glenncampagna commented 4 months ago

Map/Table Preview

Lake Manassas: image image

glenncampagna commented 4 months ago

Lake Chesdin WA L90 Map & Table + Questions

image image
glenncampagna commented 4 months ago
rburghol commented 4 months ago

Thanks for the heads up on this @glenncampagna -- I agree this looks suspicious. I am doing some model diagnostics now and then I'll rerun to see what gives.

rburghol commented 4 months ago

Glenn -- the bad segment was rerun and now has data that makes sense. I am rerunning the segments downstream of it now, and they should be done in a bout 30 minutes (2:30 EST). Thanks for seeing that anomaly!

rburghol commented 4 months ago

@glenncampagna Now, to your questions:

glenncampagna commented 4 months ago

Lake Chesdin Updates

glenncampagna commented 4 months ago

Carvins Wshed Map & Table after Ordering by cumulative withdrawal

image image

glenncampagna commented 2 months ago

Example with Outputs Linked

Render used:

rmarkdown::render("~/Desktop/GitHub/HARParchive/HARP-2023-Summer/WaterAvailability/WaterAvailability_CaseStudies.Rmd", 
                  output_file = "~/Desktop/HARPteam23/WAcasestudies_knit_runid11_runid0_0.9.docx",
                  output_format = "word_document",
                  params = list(
                      outlet_list = c("PL3_5360_5250", "JU4_7000_7300", "JA5_7480_0001", "YP3_6670_6720", "OR3_7740_8271", "PU4_3970_3890"),
                      demand_scenario = 'runid_11', 
                      baseline_scenario = 'runid_0', 
                      mif_coef = 0.9, 
                      Smin_analysis = TRUE,
                      write_Qavailable = FALSE, 
                      write_outputs = c("local", "github")))

Table 1: WA eqn breakdown

Table 2: Case study segments

Table 3 example: Case study watershed (Carvins)

Table 4 example: Case study watershed for L90 (Carvins) (matches map at the bottom)

Table 5: Smin method comparison

Table 6: Segments where Smin in VAhydro needs updating

Plot example (L90 for Carvins) https://github.com/HARPgroup/HARParchive/blob/master/HARP-2023-Summer/WaterAvailability/CaseStudiesPlots/WAcaseStudies_Plot_5_OR3_7740_8271_QvsQavail_L90.png

Map example (L90 for Carvins) https://github.com/HARPgroup/HARParchive/blob/master/HARP-2023-Summer/WaterAvailability/CaseStudiesMaps/WAcaseStudiesMapL90_5_OR3_7740_8271.png