-
Notifications
You must be signed in to change notification settings - Fork 2
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 veg estimation #321
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
dschlaep
commented
Jul 29, 2022
- close Estimate vegetation cover from climate before simulation run #318
- Added `allHist` double pointer to SW_WEATHER - Adjusted `_read_weather_hist` to store weather in year it is called with
- Created function `SW_WTH_read` that allocates allHist and calls `readAllWeather` - Created function `readAllWeather` which: * Reads in all weather history at once * Handles the case of missing weather (moved from and deleted _todays_weth) * Scales data depending on month (moved from `SW_WTH_new_day`) - Deleted `SW_WTH_new_year` as it is no longer needed
- Created function that is called by `SW_WTH_deconstruct` to deallocated allHist
- Deleted static version of weth_found and is now in `readAllWeather`
- Added most of documentation from old `SW_WTH_new_year()` * Describing how SOILWAT handles missing weather data
- Instead of calculating number of years multiple times, it is calculated once - n_years is initialized to 0
- Fixed how the months days are incremented - Fixed "temp_avg" calculations
- Removed numYears from `deallocateAllHistory` header - Added `isnull` to prevent empty lists from attempting to free itself
- Swapped SW_Weather.scale_temp_max/min for allHist[yearIndex]->temp_max/min
- When running STEPWAT, n_years in `SW_Weather` will be the correct value
- Swapped `ST_defines.h` for `SW_globals.h` - Removed extern `SuperGlobals` to prevent duplicates
- Updated header of `readAllWeather()` to accept `n_years` - Replaced instance of using `SW_Weather.n_years` with `n_years` from header - Updated unit test to include `SW_Weather.n_years` in call to `readAllWeather()`
- Added call to `deallocateAllHistory()` to fix memory leak
- Swapped `endYear` for `n_years` in documentation for `readAllWeather` - Deleted previously removed `numYears` parameter documentation - Added `yearWeather` documentation to `_read_weather_hist()` - Added descriptions to `_read_weather_hist()` parameters in documentation
- weather-related "WaterBalance" tests use non-default weather inputs * "WithWeatherGeneratorOnly" utilizes the weather generator for all values * "WithWeatherGeneratorForSomeMissingValues" utilizes available inputs from non-default source "Input/data_weather_missing" and uses the weather generator for missing values - updates related to `readAllWeather()` require that these tests prepare their weather data before running the simulation loop -- otherwise, they are using the "default" weather values previously obtained by `Reset_SOILWAT2_after_UnitTest()` and they would actually no longer perform the intended checks
- Added deallocation call before allocation process occurs * NOTE: In SOILWAT2 runs alone, this does not change anything * Eliminates the chance of forgetting to call `deallocateAllWeather()` in tests
- Created unit tests for the following conditions of `readAllWeather()`: * Use of weather generator to fill in missing days * Use of weather generator to fill in missing years * Only use weather generator to fill weather data
- `_clear_hist_weather()` now fills `allHist` instead of `SW_Weather.hist` - Now takes in `yearWeather` (current year's weather data) to fill with `MISSING`
- Eliminates chance of false "is not null" result when running tests
- Added new test to check for missing yearly input - "SomeMissingValuesYears" test no longer directly calls `readAllWeather()`
- Added two functions from `feature_weather_before_sim` branch
- Added input in file `veg.in` to specify method of vegetation estimation - Changed file reading to accommodate new user input
- `SW_WEATHER_2DAYS` no longer has - Accommodated code for no longer needing a "Yesterday" index - Deleted `SW_WTH_end_day()` and `_update_yesterday()`
- Moved `estimateVegetationFromClimate()` from `feature_weather_before_sim` branch - Added check to call `estimateVegetationFromClimate()`
- The parameter "latitude" for `estimateVegetationFromClimate()` has existed for awhile and hasn't gotten documentation, so it has now been added
- Renamed parameter from "value" to "testValue" to be a little more descriptive - Added documentation for `cutZeroInf()` parameter, which wasn't existent previously - Replaced "value = 0." with use of macro `LT()` to account for floating-point arithmetic
dschlaep
commented
Nov 16, 2022
- new test helper functions * `copyL0()`: copies L0-cover inputs to expected L0-output array * `calcVegCoverL1FromL0()`: calculates L1-cover from L0-cover array * `calcGrassCoverFromL0()`: calculates grass cover components relative to total grass cover - organize tests: (i) comment; (ii) set inputs; (iii) set or calculate expected output; (iv) calculate cover; (v) test expectations - calculate expected output from (fixed) inputs or from more detailed expected output where possible -- instead of repeating hard-coded values in several places (up to three copies per value) - loop over expected grass cover array -> all but one test are passing -> the one failing test is because L1-cover output for bare ground is incorrect if bare ground input is `SW_MISSING` (see https://github.com/DrylandEcology/SOILWAT2/pull/321/files/cdbfa8b929a1c6b34e9a1c94d9b3c5e0a483c326#r1024294338)
- Appended to "inputValues" documentation to explain how SW_MISSING is handled, and that a value of 0-1 means the value is fixed - Appended to "SumGrassesFraction" documentation to elaborate on how a value that isn't SW_MISSING is handled including that grasses are estimated relative to that value
- Created a new death test handling when SumGrassesFraction is added to the initial input sum and is greater than 1 - Added documentation specifying what the two different death cases are doing
- Fixed "SumGrassFraction" to "SumGrassesFraction" where needed - Changed SW_MISSING with 0.0 when needed (within lines 283-289), fixing a failing test
…ted equations - documented behavior: "Some of the land cover/vegetation types, i.e., trees, annual grasses, and bare-ground are not estimated from climate relationships; they are either set to 0, or alternatively fixed at the value of the input argument(s)." -> explicitly set cover of trees, annual grasses, or bare ground to 0 if their input is `SW_MISSING` (user request to estimate) -> this addresses failed unit test identified by commit 3e01bb6 (2022-Nov-16) and by comment https://github.com/DrylandEcology/SOILWAT2/pull/321/files/cdbfa8b929a1c6b34e9a1c94d9b3c5e0a483c326#r1024294338
- "WaterBalanceTest" that turns on estimation of vegetation from climate (currently vegetation cover)
- Appended to the documentation of variables with names with "7thMon" or "2ndMon" to mention the targeted months in the two hemispheres - Removed all but one mention of units of a variable within the documentation * For the most part, SW_CLIMATE_YEARLY contained units in documentation and SW_CLIMATE_CLIM did not * Variables already have their unit at the end of their name * Kept unit specification in the documentation for "ddAbove65F_degday" for a bit more explanation on unit * Added a note for the structs pointing out the unit of data are within the variables' name
- Created `allocateClimateStructs()` and `deallocateClimateStructs()` to specifically allocate or deallocate climate structs - Allows the removal of "allocate = 1;" and "deallocate = 0;" lines of code in current and future uses
- The program tries to read a line of text that is not commented out, so it is interpreting it as values for vegetation type values, causing an error
- Previously, the units within the two climate structs, SW_CLIMATE_YEARLY and SW_CLIMATE_CLIM, were deleted, which was found not to be preferable - Documentation was backtracked to the most recent version that contained units within SW_CLIMATE_YEARLY - Units within SW_CLIMATE_CLIM were added to add consistency as the deletion of units was meant to do - Units within SW_CLIMATE_CLIM documentation mirror the units in the variable name, even for averages. * For example, the unit for "meanTemp_C" in the documentation is [C] and not [C / year]
…ature_veg_estimation # Conflicts: # NEWS.md
…into feature_veg_estimation
"Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: actions/checkout@v2, codecov/codecov-action@v2" -> https://github.com/actions/checkout/releases/tag/v3.0.0 -> https://github.com/codecov/codecov-action/releases/tag/v3.0.0
- `driestQtrSouthAdjMonYears()`: reads, sets, and returns parameters depending on time of year; some calls do not read some parameters * we can either dissolve this function as it is used only once or silence the compile warnings `-Wunused-but-set-parameter` -> silence warnings with coercion to void
N1ckP3rsl3y
approved these changes
Dec 4, 2022
dschlaep
added a commit
to DrylandEcology/rSOILWAT2
that referenced
this pull request
Dec 7, 2022
Feature veg estimation, climate predictors, and read all weather This merge combines - feature_read_weather (close #204): read and process daily weather before main simulation loop - feature_climate_predictors (close #205): calculate long-term climate summaries - feature_veg_estimation (close #206): estimate fractional land cover representing a potential natural vegetation based on climate relationships This PR matches the underlying PR in SOILWAT2 DrylandEcology/SOILWAT2#321
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.