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

Release/devel v6.0.0 #214

Merged
merged 287 commits into from
Jun 9, 2023
Merged

Release/devel v6.0.0 #214

merged 287 commits into from
Jun 9, 2023

Conversation

dschlaep
Copy link
Member

@dschlaep dschlaep commented Jul 29, 2022

see https://github.com/DrylandEcology/rSOILWAT2/milestone/9

dschlaep and others added 30 commits March 10, 2022 13:39
- problem: existing setup was not capable to deal with outdated class objects that lacked slots
--> follow community recommendations: class prototypes and helper constructors instead of "initialize" methods, see https://adv-r.hadley.nz/s4.html#s4 and https://stackoverflow.com/questions/16247583/inheritance-in-r/16248773#16248773

- each class gained a helper constructor function of the same name with only "..." as argument
* "..." can either be arguments with names of slots to fill or an object of that class
* if "..." is missing, then values from "rSOILWAT2::sw_exampleData" (i.e., the SOILWAT2 "testing" defaults) are copied -- with the exception of site-specific values that are set to NA to avoid mis-specifying a new simulation run
--> now `new("swClass")` creates an object with prototype data (instead of what previously the "initialize" method returned)
--> now `swClass()` creates an object that contains default data (replicating the previous "initialize" method)

- new `weatherHistory()` that acts on list of "swWeatherData" objects and behaves similarly to a helper constructor
--> for instance,`weatherHistory()` now replaces previous `list(swWeatherData()))` or `list(new("swWeatherData"))`

- new `get_swEstab()` with signature "swInputData" for completeness of methods
- new `get_swMarkov()` and `set_swMarkov()` -- synonyms to the previous `get_Markov()` and `set_Markov()` but now with class-consistent name

- new unit tests for class helper constructor functions
- now just one method with "ANY" signature -- instead of multiple methods that did the same
- `get_version()` now consistently returns an object of type character (consistenly formatted via numeric version)
- `get_timestamp()` now consistently returns an object of type numeric

-> unit tests "exec and aggregate" using development versions of rSOILWAT2 work again
- upgrade an outdated "swInputData" object (from a previous rSOILWAT2 version) and add default values for missing slots

-> `sw_exec()` now calls this function prior to passing it to SOILWAT2
- define `set_swMarkov()` -- as synonym to existing `set_Markov()` which is not consistent to class name as other similar methods
- improve documentation to reduce "check" warnings
- define "UTF-8" encoding in `DESCRIPTION` -- to avoid roxygen2 warnings
- improve documentation of `sw_exec()` and related functions
- improve documentation of `sw_verbosity()`
- `sw_out_flags()` now returns (again) a correctly named vector -- as prior to commit 1b344d3 (Feb 23, 2022)
- remove "swof" from "rSW2_glovars" since unused
- `pdf_Rosetta3_for_vanGenuchten1980()` requires live internet to connect to Rosetta3 and obtain parameters

-> document
-> catch errors in unit tests if no internet available
- move loop over SWRC/PDF inside loop of test examples
- turn off summation over SWP -- because summed VWC may be larger than theta_sat (and SWRC may fail)
- catch if `pdf_estimate()` fails due to no internet
- new unit tests that loop over all SWRC/PDF combinations including "NoPDF"
- catch if `pdf_estimate()` fails due to no internet
- update expected SWP values for Campbell1974/Cosby1984AndOthers unit tests
- set version number to v6.0.0-9000 to reflect major changes (still under development)
- update package and unit test data
- start NEWS entry (TODO: complete before release)
- issue specific error message if PDF requires live internet but fails
- capture that error message in unit tests -- only skip if error due to offline status and fail otherwise

- see commits b75d7e1 and 70a7269

- also update internet requirements of SWRC/PDF-scripts in "tools/"
- update vignette "rSOILWAT2_demo": if no live internet, then no Daymet weather data --> use locally available data (and adjust simulated years accordingly)
- update test objects

# Conflicts:
#	DESCRIPTION
#	NEWS.md
#	R/L_swOutput.R
#	data/sw_exampleData.rda
#	src/SOILWAT2
#	src/SW_R_lib.c
#	tests/test_data/Ex1_input.rds
#	tests/test_data/Ex1_output.rds
#	tests/test_data/Ex2_input.rds
#	tests/test_data/Ex3_input.rds
#	tests/test_data/Ex3_output.rds
#	tests/test_data/Ex4_input.rds
#	tests/test_data/Ex4_output.rds
#	tests/test_data/Ex5_input.rds
#	tests/test_data/Ex5_output.rds
#	tests/testthat/test_exec_and_aggregate.R
…nuchten1980()`

- live interaction with the ROSETTA API can at times be slow or pending for some seconds
- now, if new argument `verbose` (TRUE by default if used interactively) displays a message
- Updated script (in "tools"): `test_SWRCs_and_PDFs_Simulations.R` first introduced by commit 9d603ba (March 3, 2022)

This script runs SOILWAT2 simulations (using the package default dataset)
* for each implemented pair of SWRC/PDF
* for default and 50% reduced precipitation events
* (new) for each soil texture class

and produced time-series plots by soil layer and by year of
volumetric water content (VWC), soil water potential (SWP), and transpiration

-> note: output based van Genuchten1980/Rosetta3 for sandy soils!
-`version` selects the Rosetta version number: 1, 2, or 3 (default)
- renamed from `pdf_Rosetta3_for_vanGenuchten1980()` to `pdf_Rosetta_for_vanGenuchten1980()`
- currently only used (optionally) by Rosetta

- update SOILWAT2 submodule on branch `feature_swrc` to commit 8be1d98e4a022ba25edcf0a50c1e6745cc3597e6

- function argument `bdensity` gained by
* `C_rSW2_SWRC_PDF_estimate_parameters()`
* `rSW2_SWRC_PDF_estimate_parameters()`
* `pdf_estimate()`
* `pdf_Rosetta_for_vanGenuchten1980()`
* `swrc_conversion()`
- update SOILWAT2 submodule on branch `feature_swrc` to commit 5653f7ffea715b7f82c501ff3a3d8ff97ea14800
- updated `pdf_Rosetta_for_vanGenuchten1980()` now also returns saturated hydraulic conductivity
* if one set of `swrcp` but many `x` values are passed, then we now repeat `swrcp` for each `x`
# Conflicts:
#	DESCRIPTION
#	NEWS.md
#	R/A_swGenericMethods.R
#	R/B_swFiles.R
#	R/C_swYears.R
#	R/D_swWeather.R
#	R/E_swProd.R
#	R/F_swSoils.R
#	R/H_swSWC.R
#	R/I_swEstab.R
#	R/K_swContainer.R
#	R/swWeatherGenerator.R
#	data/sw_exampleData.rda
#	src/SOILWAT2
#	tests/test_data/Ex1_input.rds
#	tests/test_data/Ex1_output.rds
#	tests/test_data/Ex2_input.rds
#	tests/test_data/Ex3_input.rds
#	tests/test_data/Ex3_output.rds
#	tests/test_data/Ex4_input.rds
#	tests/test_data/Ex4_output.rds
#	tests/test_data/Ex5_input.rds
#	tests/test_data/Ex5_output.rds
#	tests/testthat/test_WaterBalance.R
#	tests/testthat/test_class_swProd.R
#	tests/testthat/test_pedotransferfunctions.R
…new SWRC

- SOILWAT2 updated to commit 0c7162bd387edc6f2dd1498657d07bc9a5bbb4e9
- `pdfs_implemented_in_rSW2()`: now includes "neuroFX2021"
- new `pdf_neuroFX2021_for_FXW()` to estimate SWRC parameters of FXW based on Rudiyanto et al. 2021

-> Rudiyanto et al. 2021 provides the trained neural net object as RData file in the supplementary materials
* this file must be downloaded by the user (i.e., it is not included in rSOILWAT2) and the path to the file passed as argument `file_neuroFX2021`
* the file path may also be set by the (global) option "RSW2_FILENEUROFX2021" which is automatically retrieved by `pdf_neuroFX2021_for_FXW()`

- `pdf_estimate()` gains argument `...` so that it can pass additional arguments (e.g., `file_neuroFX2021`) to the selected PDFs

-> "neuroFX2021" works best with sand, clay, (silt), and bulk density
* updated examples and scripts in tools to provide bulk density

-> new `check_pdf_availability()` checks if requested PDFs are available
* each R-implemented PDF now requires a function with a name that matches pattern "pdf_XXX_availability" where XXX = name of PDF
* arguments `verbose` (with default `interactive()`) will print helpful messages to inform users why a requested PDF is not available
* exclude code examples from running if PDF is not available
* updated unit tests and scripts
- the correct interpretation of `swrcp[3]` is "m" (changed from previous incorrect "n"; `swrcp[2]` is "n")
- Created mentioned function to mirror allocation actions on SOILWAT side
- Renamed old `onSet_SW_WTH_read()` to `onSet_SW_WTH_setup()`
- updated SOILWAT2 submodule
- updated reference input files and test objects

# Conflicts:
#	DESCRIPTION
#	NEWS.md
#	data/sw_exampleData.rda
#	src/SOILWAT2
#	tests/test_data/Ex1_input.rds
#	tests/test_data/Ex1_output.rds
#	tests/test_data/Ex2_input.rds
#	tests/test_data/Ex3_input.rds
#	tests/test_data/Ex3_output.rds
#	tests/test_data/Ex4_input.rds
#	tests/test_data/Ex4_output.rds
#	tests/test_data/Ex5_input.rds
#	tests/test_data/Ex5_output.rds
dschlaep and others added 20 commits June 2, 2023 08:24
- class "swWeather" gains `desc_rsds` (description of radiation inputs) and `dailyInputFlags` (logical vector describing which daily weather input variables are active in the associated weather data object)
- class "swWeatherData" holds now up to 14 daily weather input variables: "Tmax_C", "Tmin_C", "PPT_cm", "cloudCov_pct", "windSpeed_mPERs", "windSpeed_east_mPERs", "windSpeed_north_mPERs",  "rHavg_pct", "rHmax_pct", "rHmin_pct", "specHavg_pct", "Tdewpoint_C", "actVP_kPa", "shortWR"

- update C functions that copy values between R and C functionality
- `getWeatherData_folders()` can read new daily weather inputs either via R code (that leaves values and variables as is) or via C code (connecting to SOILWAT2 which processes variables as needed for a simulation run)
- new C level `rSW2_readAllWeatherFromDisk()` to use SOIILWAT2 to read (and process) daily weather inputs from disk
- weather data are a list of elements of the class "swWeatherData" -- we cannot use S4 method `sw_upgrade()` --> `upgrade_weatherHistory()`
- monthly scaling parameters of class "swMonthlyScalingParams" are contained within "swWeather" -- we cannot use its S4 method `sw_upgrade()` --> `sw_upgrade_MonthlyScalingParams()`

- `dbW_check_weatherData()` now checks for valid "swWeatherData" objects carefully and via new argument `check_all` checks carefully for slot "year" in case it is missing
new:
- `calc_dailyInputFlags()` estimates which weather variables are active (here, those that are not only missing)
- `is_missing_weather()` produces a logical matrix checking for all possible values that could indicate missing weather values
- `weatherGenerator_dataColumns()` lists weather variables that the Markov weather generator implements
- `weather_dataAggFun()` lists functions that are used to temporally summarize each weather variable (e.g., `mean()` for temperature, `sum()` for precipitation amount)

updated:
- `dbW_convert_to_GregorianYears()`: argument `name_data` is now by default the result of `weather_dataColumns()`
- `dbW_dataframe_to_weatherData()`: argument `weatherDF_dataColumns` is now by default the result of `weather_dataColumns()` (plus "DOY")
- `dbW_weatherData_to_monthly()` and `dbW_dataframe_aggregate()`: new argument `funs` with default the result of `weather_dataAggFun()`plus "DOY")
- `dbW_weather_to_SOILWATfiles()`: argument `weatherDF_dataColumns` is now by default the result of `weather_dataColumns()` (plus "DOY")
- `dbW_weatherData_round()`: argument `weatherDF_dataColumns` is now by default the result of `weather_dataColumns()`
- `dbW_check_weatherData()`: now also checks if each "swWeatherData" object is valid and gains argument `check_all` to carefully check for year slot and correct number of days
- `dbW_generateWeather()`: now handles correctly new daily weather variables (but only those in `weatherGenerator_dataColumns()` are implemented by the weather generator)
- update scripts that prepare package and test data: they now make sure that weather history objects pass checks
- comparisons of weather data now makes mostly sense for those variables that don't have the potential to be calculated/processed by SOILWAT2
- check that previous versions can be successfully upgraded so that they validity and other checks
- tests for inputs with "standard" variables, and with variable sets from Daymet, gridMET, and MACA
- Vapor pressure and radiation variables from Daymet are now supported inputs
included changes:
- Fix `mvnorm()`: avoid NaN as tmin output
- set seed for reproducible output
Read more daily input

Daily weather inputs, in addition to the previous variables
  maximum air temperature, minimum air temperature, and precipitation amount,
  can now process the following variables (issue #341; @dschlaep, @N1ckP3rsl3y):
    * Cloud cover (can be replaced by shortwave radiation)
    * Wind speed (can be replaced by wind components)
    * Wind speed eastward component (optional)
    * Wind speed northward component (optional)
    * Relative humidity (can be replaced by max/min humidity, specific humidity
      dew point temperature, or vapor pressure)
    * Maximum relative humidity (optional)
    * Minimum relative humidity (optional)
    * Specific humidity (optional)
    * Dew point temperature (optional)
    * Actual vapor pressure (optional)
    * Downward surface shortwave radiation (optional)
Address:
> warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
>     static SEXP onGet_SW_SWRCp()
- Address warning:
> rSW_Output.c:59:7: variable 'use' set but not used [-Wunused-but-set-variable]
>           int *use, *timePeriods, *sumtype, *first_orig, *last_orig;
dschlaep added a commit to DrylandEcology/SOILWAT2 that referenced this pull request Jun 9, 2023
Release v7.0.0

see https://github.com/DrylandEcology/SOILWAT2/milestone/13

- Read daily weather before the simulations enhancement (#311)
- Calculate climate variables before simulation loop (#317)
- Estimate vegetation cover from climate before simulation run (#318)
- Implement multiple soil water retention curves (#315)
- Soil density: input either for < 2 mm fraction or for whole soil? enhancement (#280)
- Re-organize repository with more sub-folders question (#89)
- Daily variables for atmospheric demand (#341)
- STEPWAT2 updated to work with this release (see DrylandEcology/STEPWAT2#535)
- rSOILWAT2 updated to work with this release (see DrylandEcology/rSOILWAT2#214)
@dschlaep dschlaep marked this pull request as ready for review June 9, 2023 14:40
@dschlaep dschlaep requested a review from N1ckP3rsl3y June 9, 2023 14:40
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.

2 participants