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

Feature swrc #8

Open
wants to merge 13 commits into
base: release/devel_v0.3.0
Choose a base branch
from
Open

Feature swrc #8

wants to merge 13 commits into from

Conversation

dschlaep
Copy link
Member

- new internal `convert_with_swrc()` translates between volumetric water content and soil water potential for any suitable version combination of `rSOILWAT2` input objects and currently installed `rSOILWAT2` package
- new internal `has_fun_swrc_as_arg()` detects if a metric function requires a `SWRC` translation by checking for the presence of a `"swrcp_and_usage"` argument
- metrics that require a `SWRC` translation **will** gain argument `"swrcp_and_usage"`; this argument contains all necessary information about the `SWRC` which was active during a simulation, and is then internally used to call `convert_with_swrc()`

-> this commit prepares for the new argument `"swrcp_and_usage"` of metrics functions but does not actually implement them; implementation is planned for later commits
new functionality gathers information for the new `"swrcp_and_usage"`arguments (following structure of existing functionality that prepares soil properties information for the `"soils"` arguments), i.e., such information can either be extracted from a `rSOILWAT2` input object when needed to calculate a metrics or, alternatively (but not implemented yet), be loaded from a pre-prepared file stored on disk
* new `load_swrcp_and_usage()` determines available `SWRC` functionality and prepares required parameters depending on `rSOILWAT2` version
* `process_values_one_site()`, `prepare_soils_for_site()`, and `get_soillayers_variable()` gain arguments to load and/or prepare necessary `SWRC` information at the same time as soil properties are prepared (to avoid reading multiple times a `rSOILWAT2` input objects from disk)
* `extract_metrics()` now checks if a metric requires `SWRC` functionality and handles loading and/or preparing of necessary information to be passed on to the metric function.

-> note: handling of pre-extracted SWRC information stored on disk is not implemented by this commit
- `calc_SWA_mm()`: replace call to `rSOILWAT2::SWPtoVWC()` (deprecated by rSOILWAT2 v6.0.0) with `convert_with_swrc()`
- this works correctly with versions of rSOILWAT2 at v6.0.0 and earlier

- all functions and metrics that utilize `calc_SWA_mm()` gain argument "swrcp_and_usage"
- updated metrics:
  * `metric_SW2toTable_daily()`
  * `metric_SWAat0to020cm39bar_daily()`
  * `metric_SWAat0to020cm39bar_dailyClim()`
  * `metric_SWAat0to020cm39bar_JJA()`
  * `metric_SWAat0to020to100cm39bar_quarterly()`
  * `metric_SWAat0to100cm30bar()`
  * `metric_SWAat0to100cm39bar()`
  * `metric_SWAat0to100cm39bar_daily()`
  * `metric_SWAat0to100cm39bar_JJA()`
  * `metric_SWAat20to040cm39bar_daily()`
  * `metric_SWAat20to040cm39bar_JJA()`
  * `metric_SWAat20to100cm39bar_daily()`
  * `metric_SWAat20to100cm39bar_dailyClim()`
  * `metric_SWAat20to100cm39bar_JJA()`
  * `metric_SWAat40to060cm39bar_daily()`
  * `metric_SWAat40to060cm39bar_JJA()`
  * `metric_SWAat60to080cm39bar_daily()`
  * `metric_SWAat60to080cm39bar_JJA()`
  * `metric_SWAat80to100cm39bar_daily()`
  * `metric_SWAat80to100cm39bar_JJA()`
@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Attention: Patch coverage is 0% with 263 lines in your changes are missing coverage. Please review.

Project coverage is 6.34%. Comparing base (82edd2d) to head (0369757).

❗ Current head 0369757 differs from pull request most recent head f45fb0d. Consider uploading reports for the commit f45fb0d to get more accurate results

Files Patch % Lines
R/Functions_Supporting.R 0.00% 93 Missing ⚠️
R/rSW2metrics-deprecated.R 0.00% 54 Missing ⚠️
R/Functions_Metrics_001_SEUG.R 0.00% 32 Missing ⚠️
R/Extractions_Main.R 0.00% 29 Missing ⚠️
R/Functions_Collect_Inputs.R 0.00% 19 Missing ⚠️
R/Functions_Metrics_003_ATlinkages.R 0.00% 16 Missing ⚠️
R/Functions_Metrics_002_newRR.R 0.00% 12 Missing ⚠️
R/Functions_Metrics_008_SW2toTable.R 0.00% 3 Missing ⚠️
R/Functions_Metrics_006_Quarterly.R 0.00% 2 Missing ⚠️
R/Functions_Metrics_009_DailyClim.R 0.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@                   Coverage Diff                   @@
##           release/devel_v0.3.0      #8      +/-   ##
=======================================================
+ Coverage                  6.16%   6.34%   +0.17%     
=======================================================
  Files                        18      18              
  Lines                      5839    5614     -225     
=======================================================
- Hits                        360     356       -4     
+ Misses                     5479    5258     -221     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- `get_NonDrySWA_Seasonal()`: replace call to `rSOILWAT2::SWPtoVWC()` (deprecated by rSOILWAT2 v6.0.0) with `convert_with_swrc()`
- this works correctly with versions of rSOILWAT2 at v6.0.0 and earlier

- all functions and metrics that utilize `get_NonDrySWA_Seasonal()` gain argument "swrcp_and_usage"
- updated metrics:
  * `metric_NonDrySWA_Seasonal_wholeprofile()`
  * `metric_NonDrySWA_Seasonal_top50cm()`
- `get_SWA_Seasonal()`: replace call to `rSOILWAT2::SWPtoVWC()` (deprecated by rSOILWAT2 v6.0.0) with `convert_with_swrc()`
- this works correctly with versions of rSOILWAT2 at v6.0.0 and earlier

- all functions and metrics that utilize `get_SWA_Seasonal()` gain argument "swrcp_and_usage"
- updated metrics:
  * `metric_SWA_Seasonal_wholeprofile()`
  * `metric_SWA_Seasonal_top50cm()`
- `metric_SWP_SoilLayers_MeanMonthly()`: replace call to `rSOILWAT2::VWCtoSWP()` (deprecated by rSOILWAT2 v6.0.0) with `convert_with_swrc()`
- this works correctly with versions of rSOILWAT2 at v6.0.0 and earlier

- updated metrics:
  * `metric_SWP_SoilLayers_MeanMonthly()`
- this function is unused and likely remains unused
- SWRC functionality is not implemented
…l()`

- see commit f65ecf5 --> all functions and metrics that utilize `calc_SWA_mm()` gain argument "swrcp_and_usage"

- new function `get_EcologicalDroughtMetrics2023_annual()` now also gains argument "swrcp_and_usage" (which is passed to `calc_SWA_mm()`

- this works correctly with versions of rSOILWAT2 at v6.0.0 and earlier

- updated metrics:
* `metric_EcologicalDroughtMetrics2023_annual()`
* `metric_EcologicalDroughtMetrics2023_annualClim()`
- prepare_soils_for_site() can now prepare "swrcp_and_usage" from `soils` (previously, it failed if swInputData was not available)
- load_swrcp_and_usage() now accepts as input (renamed to `x`) either an object of class "swInputData" (as previously) or (new) a data frame with soil properties
- load_swrcp_and_usage() is now exported
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

Successfully merging this pull request may close these issues.

1 participant