README.md

CSLSscenarios

CSLSscenarios is an R package containing code and results generated by the Wisconsin Department of Natural Resources for the lake ecosystem response analysis of the Central Sands Lakes Study (CSLS).

Key datasets contain calculated hydrologic metrics for each simulation of each 38-year scenario (data/MODFLOW_metrics) and a comparison to no-irrigated-agriculture metrics (data/MODFLOW_comparison), with significant thresholds and impact (T/F) determinations. These datasets are generated by data-raw/calculate_MODFLOW_metrics.R and data-raw/compare_MODFLOW_scenarios. Rerunning requires the MODFLOW results contained in CSLSdata and may take a while - generally 30 min++ on my machine to run for all scenarios and simulations.

The full suite of hydrologic metrics is calculated for each simualtion via R/calculate_metrics.R. The ecological rules underpinning the significant impact assessment are collated in data/ecological_rules and interpreted by the R/compare_scenarios.R.

Details on data and code can also be found in inst/CSLSscenarios_1.0.0.pdf.

Installation

Several data files in this package are hosted via Git Large File Storage (LFS). You may need to install LFS in order for some files to download properly via git.

To install or explore this R package, you may:

  1. Use devtools to install the package. This will allow you to load the cleaned Rda data files and explore vignettes. devtools::install_github("WDNR-Water-Use/CSLSdata", build_vignettes=T)

  2. Fork from github, clone or download ZIP, then open the cslsdata.prj file in R. This will allow you to also explore the raw data files and cleaning scripts included in data-raw/.

  3. You may instead be interested in the csv equivalents of Rda data files, which are saved under inst/csv/. These are updated every time the Rda data files are, and may be more accessible for non-R users or those more comfortable in other programming languages.

# Updating ecological rules If you need to update the ecological rules used for Pleasant, Long, and Plainfiled Lakes or add ecological rules for new lakes:

  1. Update data-raw/ecological_rules.csv.
    1. Follow the existing conventions for names of indicators, metrics, variables, etc.
    2. If adding a new lake, add a column for that lake to the right of the columns for Pleasant, Long, and Plainfield.
    3. If adding a new metric, make sure code to calculate that metric exists in R/ and is incorporated in R/calculate_metrics.R.
  2. Run the code for data-raw/import_ecological_rules.R
    1. If you added a new lake or other column, update the documentation in R/ecological_rules.R to reflect this.
  3. Re-install CSLSscenarios and restart R (Session > Restart R) to ensure new version of data/ecological_rules is available.

# Updating MODFLOW results If you need to rerun to analyze new MODFLOW results (e.g., a new scenario):

  1. First, make sure you have updated the MODFLOW data frame in the CSLSdata R package (here).
  2. If you have added new wells and are interested in re-evaluating the "wells_off" scenario, then:
    1. Update data-raw\pfl_dist_ranks.csv and data-raw\psnt_dist_ranks.csv
    2. Rerun data-raw\import_well_rank_dist.R
    3. Re-install CSLSscenarios and restart R (Session > Restart R) to ensure new version of data/well_rank_dist is available.
  3. Run data-raw/calculate_MODFLOW_metrics.R to calculate relevant hydrologic metrics for each scenario.
    1. Make sure the lakes and scenario names under the PARAMETERS section are correct for the lakes and scenarios you want to evaluate. If you added new lakes or scenarios, be sure to update here. Note that this code assumes you always want to compare new scenarios to the "no_irr" scenario. If this is not true, you may need to write a new script.
    2. Confirm same burn-in period under the DATA section
    3. Note that code assumes the "no_irr" and "cur_irr" have many (300+) simulations which explored SWB parameterization, while all other scenarios correspond to the parameterization used in the "no_irr"/"cur_irr" simulation #1. If this changes, check code for what may be impacted (e.g., checks to ensure all "cur_irr" simulations have a "no_irr" pair here, which "no_irr" exceedance levels to use for duration calculation in other scenarios here).
    4. Note that all durations will be calculated based on exceedance levels from the "no_irr" scenario. If you want to calculate them relative to each scenario's own exceedance levels, adjust the ifelse statements here.
    5. Running this for all scenarios and simulations may take a while (30min++ on my laptop).
    6. When finished, will save a new summary data frame MODFLOW_metrics.
    7. Re-install CSLSscenarios and restart R (Session > Restart R) to ensure new version of data/MODFLOW_metrics is available for the next step.
    8. A csv version of this data frame will simultaneously be saved to inst/csv/MODFLOW_metrics.csv.
  4. Run data-raw/compare_MODFLOW_metrics.R to evaluate whether changes in hydrologic metrics are large enough to cause a significant impact to the lake ecosystems.
    1. Code assumes (here) that you have separately calculated water chemistry budget metrics using CSLSfluxes (see repo here).
    2. Code also assumes you have all 300+ simulations for the "no_irr" scenario to use for calculating uncertainty in a few key ecological indicators which allow "no change" (see here)
    3. Ensure each scenario you want to evaluate has a section of code to compare to the "no_irr" scenario (e.g., here)
    4. When finished, will save a new summary data frame MODFLOW_comparison which indicates which ecological indicators are impacted for each lake under each scenario.
    5. Re-install CSLSscenarios and restart R (Session > Restart R) to ensure new version of data/MODFLOW_comparison is available for subsequent analysis.
    6. A csv version of this data frame will simultaneously be saved to inst/csv/MODFLOW_comparison.csv.


WDNR-Water-Use/CSLSscenarios documentation built on Nov. 10, 2021, 4:14 p.m.