Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week of 5/30/23 #872

Open
6 tasks done
glenncampagna opened this issue May 30, 2023 · 11 comments
Open
6 tasks done

Week of 5/30/23 #872

glenncampagna opened this issue May 30, 2023 · 11 comments

Comments

@glenncampagna
Copy link
Collaborator

glenncampagna commented May 30, 2023

From 5/30 Meeting:

  • using existing Rmd, supply a river segment, and pull in model results
    • specifically, compare runid_11 (2020) and runid_13 (2040)
      • JK: I can't recall if your script ws_model_summary.Rmd is already set up to pull data from these vahydro-1.0 models or not. You should be able to pull in the metrics no problem
        • For this exploration effort you may just need to comment out the Time Series Analysis and FTABLE portions of your Rmd to allow you to pull in the metrics only
      • If you're interested in pulling in the full run data itself, you can pull this model data like so: Week of 3/13 & 3/22 #769 (comment)
    • optionally, pull in model results upstream of that river segment
  • Try running EasyMapGen.R for now (deep dive into mapping to come later), see Watershed Feature Extraction and Mapping Tools #856
  • Calc simple metric % diffs inws_model_summary.Rmd, iterating & comparing to first model supplied
  • Save map to export_path if the variable exists in WSP_basemap.R (export_path set in each of our config.local.private)
@glenncampagna
Copy link
Collaborator Author

glenncampagna commented May 30, 2023

Vahydro runIDs connection to demand and climate change scenarios

  • At the bottom of a object model scenario page in VAhydro, the Run Model section and Model Run ID dropdown -> WSP Runs can be used to connect different runIDs to demand and climate change scenarios
  • Key scenarios
    runid_11: 2020 demand scenario
    runid_13: 2040 demand scenario
    runid_14: Median climate change scenario (50/50) -- 2020 demand
    runid_15: Dry climate change scenario (10/10) -- 2020 demand
    runid_16: Wet climate change scenario (90/90) -- 2020 demand
    runid_17: Dry climate change scenario (10/10) -- 2040 demand
    runid_19: Median climate change scenario (50/50) -- 2040 demand
    runid_20: Wet climate change scenario (90/90) -- 2040 demand
    *CC scenarios for year 2055

Example:

  • Compared scenarios for Segment RU4_5640_6030 (Rapp. near Culpeper) w/ ws_model_summary.Rmd
    2020 vs 2040: point source flow in grows by a factor > 2 (aligns w/ expected population growth in the region)
    2020 vs Dry Climate: mean outflow decreases and large decrease in L90 & L30

@glenncampagna
Copy link
Collaborator Author

glenncampagna commented May 30, 2023

Trying to generate maps with EasyMapGen.R

  • Glenn having R crash when running line 128 to create seglist
    seglist <- ds$get('dh_feature', config=list(ftype='vahydro',bundle='watershed'))
    Also gives error/output: No encoding supplied: defaulting to UTF-8

  • Megan gets the same error with fn_extract_basin() in line 131 as when trying to run Rob's watershed extraction mapping script:

app_segs <- fn_extract_basin(seglist, 'JL4_6520_6710')
Error in fn_ALL.upstream(end_seg, AllSegList) : 
  object 'AllSegList' not found
  • Ella does not get a specific error at any line anymore, but the .png of the map does not seem to have been formed.

Update:

  • Megan was able to generate a map .png after adding the following code chunk above line 131, and changing the fpath so that it exports locally. Neither Ella nor Glenn needed to explicitly set the AllSegList.
## Example Code to get AllSegList
# Download and Import csv with all river segments (copy commented lines below)
localpath <- tempdir()
filename <- paste("vahydro_riversegs_export.csv",sep="")
destfile <- paste(localpath,filename,sep="\\")
download.file(paste(site,"/vahydro_riversegs_export",sep=""), destfile = destfile, method = "libcurl")
RSeg.csv <- read.csv(file=paste(localpath , filename,sep="\\"), header=TRUE, sep=",")
AllSegList <- substring(RSeg.csv$hydrocode, 17)
  • Ella was able to generate a map .png after adding library(rgeos) and changing the fpath to export locally. Neither Megan nor Glenn needed to load rgeos.
  • Glenn was able to generate a map .png after updating his R version to 4.3.0 (However, Ella is using R 4.1.2 and Megan is using R 4.1.3). Glenn can now also render the summary .rmd with his updated R.

@glenncampagna
Copy link
Collaborator Author

glenncampagna commented May 30, 2023

General plan for summary documents we'll be providing localities

  • Region identification and include localities within

  • Framing text describing how document should be used per regulatory requirements

  • Regional coverage maps and tables:
    2020 vs 2040 demand scenarios
    Maps likely @ watershed scale w/ regional planning boundary shown
    Table accompanying map (facility, source, location, permitted capacity)
    Table of unmet demands 2040
    Dry climate vs differential climate scenario
    Table w/ riversegs expected to decrease flow (< -10%?)

  • Locality focus

  • Regional appendix for things not suited for more brief sections above

  • The change in metrics (L90, 7Q10) as a percentile will be useful (state plan does this)

more to come from us based on ideas from @gmahadwar

@megpritch
Copy link
Collaborator

megpritch commented May 30, 2023

Pulling Upstream Segment Models

## Example Code to get AllSegList
# Download and Import csv with all river segments (copy commented lines below)
localpath <- tempdir()
filename <- paste("vahydro_riversegs_export.csv",sep="")
destfile <- paste(localpath,filename,sep="\\")
download.file(paste(site,"/vahydro_riversegs_export",sep=""), destfile = destfile, method = "libcurl")
RSeg.csv <- read.csv(file=paste(localpath , filename,sep="\\"), header=TRUE, sep=",")
AllSegList <- substring(RSeg.csv$hydrocode, 17)

#get upstream river segs
riv.seg <- "JA4_7280_7340" # !! user input
upstr <- fn_upstream(riv.seg, AllSegList)
[1] "JA1_7640_7280" "JA2_7550_7280"

upstr.df <- data.frame(matrix(nrow=0, ncol=ncol(RSeg.csv)))
  colnames(upstr.df) <- colnames(RSeg.csv)
for(i in upstr){
  row.i <- as.numeric(rownames(RSeg.csv[grep(i, RSeg.csv$hydrocode),]))
  upstr.df <- rbind(upstr.df, RSeg.csv[row.i,])
}

for(i in 1:length(upstr)){
  #get model run data
  rseg.i <- RomFeature$new(ds,list(
      hydrocode = upstr.df$hydrocode[i],
      ftype = upstr.df$ftype[i],
      bundle = upstr.df$bundle[i]),
    TRUE)
  model.i <- RomProperty$new(ds,list(
      featureid = rseg.i$hydroid,
      entity_type = 'dh_feature',
      propcode = "vahydro-1.0"), #all climate change scenarios are under vahydro-1.0... can we keep this hard-coded?
    TRUE)
  
  model.i_url_base <- paste(site, 'node/62', sep = "/")
  model.i_obj_url <- paste(model.i_url_base, model.i$pid, sep = "/")
  model.i_info <- ds$auth_read(model.i_obj_url, "text/json", "")
  model.i_info <- jsonlite::fromJSON(model.i_info)
  
  assign(paste0(upstr[i], "_model"), model.i_info)
}

@glenncampagna
Copy link
Collaborator Author

glenncampagna commented May 30, 2023

Question about segment naming & upstream segments

  • We know that the first 4 numbers in a segment ID correspond to that segment and the last 4 correspond to the downstream segment
  • So, for segment JA4_7280_7340, are both JA2_7550_7280 and JA1_7640_7280 directly upstream?
  • Update: thank you @megpritch for answering my question!

@glenncampagna
Copy link
Collaborator Author

glenncampagna commented May 31, 2023

CC scenario comparison -- impacts on Upstream vs. Downstream segments

  • Structure: Dry CC (runid_15) vs. Median CC (runid_14) vs. Wet CC (runid_16)
  • Upstream Segment JA1_7640_7280:
    image
  • Downstream Segment JA4_7280_7340:
    image

@jdkleiner
Copy link
Member

jdkleiner commented Jun 1, 2023

ggmap()

  • See below for a summary of our findings from today and the proposed solution (use ggmap version 3.0.2 with maptype = "terrain")

ggmap 3.0.0:
basemap_toner <- get_map(source = "stamen", maptype = "toner", color=c("color"), location = ggmap_bbox, zoom = 12)
Picture1

ggmap 3.0.2:
basemap_toner <- get_map(source = "stamen", maptype = "toner", color=c("color"), location = ggmap_bbox, zoom = 12)
Picture2

ggmap 3.0.2:
basemap_toner <- get_map(source = "stamen", maptype = "terrain", color=c("color"), location = ggmap_bbox, zoom = 12)
Picture3

@EllaF21
Copy link
Contributor

EllaF21 commented Jun 1, 2023

Questions on Mapping

These are based on the EasyMapGen.R file

  • How do we find a coordinate reference system(crs value in code) for where we want the map to be?
  • What coordinates lat and lon should we be using in the mapgen function creation vs outlet_point later on(how do we find the right coords)?
  • How to pick specific fn_extract_basin riverseg value
  • Can we change run ids/why are there 2 in the example?
  • Can we change model version or does it have to be vahydro?
  • How does scaling/zooming work(in the future we would have to automate this)?

@megpritch
Copy link
Collaborator

megpritch commented Jun 2, 2023

Mapping Update

Thought it may be cool to vary the size of the facility points depending on their consumption. We can also compare different runid's, but you can't see much of a difference unless the metric varies drastically. Below you can at least tell that they overlap because the points on the map become orange.

If the point sizes look too much like they correspond with facility area, then we could also have the point colors vary with a gradient.

This is done with a new Rmd called mapping_workflow.Rmd. I tried to format the workflow so that different metrics and runid's can be passed in. I'm not sure if the unmet demands statistics are calculated for each facility, but those may be a cool way to draw attention to facilities that are most in need of supply plan revisions.

image image

@durelles
Copy link

durelles commented Jun 2, 2023 via email

@rburghol
Copy link
Contributor

rburghol commented Jun 2, 2023

@megpritch This looks really great and the sizing was on our wishlist for a while now! Can't wait to dive in next week.

@glenncampagna glenncampagna mentioned this issue Jun 5, 2023
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants