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

Read more daily input #228

Merged
merged 34 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a453395
Updated submodule to `read_more_daily_input`
Jan 10, 2023
e0329b1
New constant: MAX_INPUT_COLUMNS
Jan 11, 2023
26d8006
Read and transfer new weather input values
Jan 11, 2023
aac3d5f
New scaling factors and flags
Jan 11, 2023
ba7c61f
New input calculations/interpolation to `rSW2_setAllWeather()`
Jan 11, 2023
7e55a7f
Merge branch 'release/devel_v6.0.0' into read_more_daily_input
Jan 17, 2023
1c7b55b
Updated submodule
Jan 17, 2023
8b8390f
Adjusted functions for new input flag array on SOILWAT2 side
Jan 17, 2023
3fb9828
Correct "nINT" size to include MAX_INPUT_COLUMNS
Jan 17, 2023
53e8c34
New function: `strip_weather_data_NA_columns()`
Feb 13, 2023
66db0e2
Updated submodule
Feb 13, 2023
df3ea0d
Reversed commit 53e8c34891b6a6ef98a32d90a78fd0d353e4c356
Feb 21, 2023
4203367
`swWeatherData` mimics "allHist" from SOILWAT2
Feb 21, 2023
58cc60e
Merge branch 'release/devel_v6.0.0' into read_more_daily_input
dschlaep May 2, 2023
b9ca8c7
Update SOILWAT2 to latest version on "read_more_daily_input"
dschlaep Jun 2, 2023
8de12d7
Update SOILWAT2 (v7.0.0) example inputs
dschlaep Jun 2, 2023
e65f89e
Fix updated "MonthlyScalingParams"
dschlaep Jun 2, 2023
61b6494
Merge branch 'release/devel_v6.0.0' into read_more_daily_input
dschlaep Jun 2, 2023
4d67488
`get_version()` now passes through numeric version objects
dschlaep Jun 2, 2023
2101c3a
Update weather and weather data classes to match SOILWAT2
dschlaep Jun 2, 2023
e115d33
`getWeatherData_folders()` now handles new daily weather inputs
dschlaep Jun 2, 2023
cfc106b
Upgrade mechanism for updated classes "swWeather" and "swWeatherData"
dschlaep Jun 2, 2023
bb024a1
Update all weather-related functions to handle new daily inputs
dschlaep Jun 2, 2023
70ca97a
Update data for package and tests
dschlaep Jun 2, 2023
1648229
Update tests for new daily variables and updated functionality
dschlaep Jun 2, 2023
6b6fbf8
New tests for previous versions of weather history objects
dschlaep Jun 2, 2023
1d79d80
New tests that run with different supported weather input datasets
dschlaep Jun 2, 2023
bb1428b
Updates to vignette for functionality related to new daily variables
dschlaep Jun 2, 2023
785d11c
Update NEWS to reflect changes with new daily input variables
dschlaep Jun 2, 2023
7c4ea2e
Fix some lint problems
dschlaep Jun 2, 2023
44d2363
`get_version()` now again returns consistently a character output
dschlaep Jun 2, 2023
edcb10e
Simplify weather generator unit tests
dschlaep Jun 2, 2023
fa83af5
Update SOILWAT2 to latest version on "read_more_daily_input"
dschlaep Jun 3, 2023
2f427a3
Improve weather generator tests
dschlaep Jun 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "src/SOILWAT2"]
path = src/SOILWAT2
url = https://github.com/DrylandEcology/SOILWAT2
branch = release/devel_v7.0.0
branch = read_more_daily_input
dschlaep marked this conversation as resolved.
Show resolved Hide resolved
66 changes: 57 additions & 9 deletions R/D_swWeather.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ setClass(
prototype = list(
MonthlyScalingParams = array(
NA_real_,
dim = c(12, 6),
dim = c(12, 8),
dimnames = list(
NULL,
c("PPT", "MaxT", "MinT", "SkyCover", "Wind", "rH")
c("PPT", "MaxT", "MinT", "SkyCover", "Wind", "rH", "actVP", "shortWR")
)
)
)
Expand All @@ -72,10 +72,10 @@ setValidity(
val <- TRUE
temp <- dim(object@MonthlyScalingParams)

if (temp[2] != 6) {
if (temp[2] != 8) {
msg <- paste(
"@MonthlyScalingParams must have exactly 6 columns ",
"corresponding to PPT, MaxT, MinT, SkyCover, Wind, rH"
"corresponding to PPT, MaxT, MinT, SkyCover, Wind, rH, ActVP, ShortWR"
)
val <- if (isTRUE(val)) msg else c(val, msg)
}
Expand Down Expand Up @@ -163,7 +163,24 @@ setClass(
pct_SnowRunoff = "numeric",
use_weathergenerator = "logical",
use_weathergenerator_only = "logical",
FirstYear_Historical = "integer"
FirstYear_Historical = "integer",
use_cloudCoverMonthly = "logical",
use_windSpeedMonthly = "logical",
use_humidityMonthly = "logical",
has_tempMax = "logical",
has_tempMin = "logical",
has_ppt = "logical",
has_cloudCover = "logical",
has_sfcWind = "logical",
has_windEast = "logical",
has_windNorth = "logical",
has_hurs = "logical",
has_hursMax = "logical",
has_hursMin = "logical",
has_huss = "logical",
has_tdps = "logical",
has_vp = "logical",
has_rsds = "logical"
),
# TODO: this class should not contain `swMonthlyScalingParams` but
# instead be a composition, i.e., have a slot of that class
Expand All @@ -174,7 +191,24 @@ setClass(
pct_SnowRunoff = NA_real_,
use_weathergenerator = NA,
use_weathergenerator_only = NA,
FirstYear_Historical = NA_integer_
FirstYear_Historical = NA_integer_,
use_cloudCoverMonthly = NA,
use_windSpeedMonthly = NA,
use_humidityMonthly = NA,
has_tempMax = NA,
dschlaep marked this conversation as resolved.
Show resolved Hide resolved
has_tempMin = NA,
has_ppt = NA,
has_cloudCover = NA,
has_sfcWind = NA,
has_windEast = NA,
has_windNorth = NA,
has_hurs = NA,
has_hursMax = NA,
has_hursMin = NA,
has_huss = NA,
has_tdps = NA,
has_vp = NA,
has_rsds = NA
)
)

Expand Down Expand Up @@ -427,9 +461,23 @@ setMethod(
object@pct_SnowRunoff <- readNumeric(infiletext[6])
object@use_weathergenerator <- readLogical(infiletext[7])
object@FirstYear_Historical <- readInteger(infiletext[8])

data <- matrix(data = c(rep(1, 12), rep(NA, 12 * 5)), nrow = 12, ncol = 6)
colnames(data) <- c("PPT", "MaxT", "MinT", "SkyCover", "Wind", "rH")
object@use_cloudCoverMonthly <- readLogical(infiletext[9])
object@use_windSpeedMonthly <- readLogical(infiletext[10])
object@use_relHumidityMonthly <- readLogical(infiletext[11])
object@has_temp2 <- readLogical(infiletext[12])
object@has_ppt <- readLogical(infiletext[13])
object@has_cloudCover <- readLogical(infiletext[14])
object@has_sfcWind <- readLogical(infiletext[15])
object@has_windComp <- readLogical(infiletext[16])
object@has_hurs <- readLogical(infiletext[17])
object@has_hurs2 <- readLogical(infiletext[18])
object@has_huss <- readLogical(infiletext[19])
object@has_tdps <- readLogical(infiletext[20])
object@has_vp <- readLogical(infiletext[21])
object@has_rsds <- readLogical(infiletext[22])

data <- matrix(data = c(rep(1, 12), rep(NA, 12 * 5)), nrow = 12, ncol = 8)
colnames(data) <- c("PPT", "MaxT", "MinT", "SkyCover", "Wind", "rH", "actVP", "shortWR")
rownames(data) <- c("January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November", "December")

Expand Down
8 changes: 5 additions & 3 deletions R/D_swWeatherData.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ setClass(
# NOTE: 999 should be rSW2_glovars[["kSOILWAT2"]][["kNUM"]][["SW_MISSING"]]
data = array(
data = c(1:366, rep(999, 366 * 3)),
dschlaep marked this conversation as resolved.
Show resolved Hide resolved
dim = c(366, 4),
dimnames = list(NULL, c("DOY", "Tmax_C", "Tmin_C", "PPT_cm"))
dim = c(366, 15),
dimnames = list(NULL, c("DOY", "Tmax_C", "Tmin_C", "PPT_cm", "cloudCov", "windSpeed",
dschlaep marked this conversation as resolved.
Show resolved Hide resolved
"windSpeed_east", "windSpeed_north", "rel_H", "rel_H_max", "rel_H_min",
"spec_H", "dewpointTemp_C", "actVP", "shortWR"))
),
year = NA_integer_
)
Expand All @@ -87,7 +89,7 @@ setValidity(
}

tmp <- dim(object@data)
if (tmp[2] != 4) {
if (tmp[2] != rSW2_glovars[["kSOILWAT2"]][["kINT"]][["MAX_INPUT_COLUMNS"]] + 1) {
msg <- paste(
"@data must have exactly 4 columns corresponding to",
dschlaep marked this conversation as resolved.
Show resolved Hide resolved
"DOY, Tmax_C, Tmin_C, PPT_cm"
Expand Down
6 changes: 3 additions & 3 deletions src/SW_R_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ SEXP sw_consts(void) {
#endif

const int nret = 9; // length of cret
const int nINT = 13; // length of vINT and cINT
const int nINT = 14; // length of vINT and cINT
const int nNUM = 1; // length of vNUM and cNUM

#ifdef RSWDEBUG
Expand Down Expand Up @@ -528,14 +528,14 @@ SEXP sw_consts(void) {
SWRC_PARAM_NMAX,
eSW_NoTime, SW_OUTNPERIODS, SW_OUTNKEYS, SW_NSUMTYPES, NVEGTYPES,
OUT_DIGITS,
N_SWRCs, N_PTFs
N_SWRCs, N_PTFs, MAX_INPUT_COLUMNS
};
char *cINT[] = {
"SW_NFILES", "MAX_LAYERS", "MAX_TRANSP_REGIONS", "MAX_NYEAR",
"SWRC_PARAM_NMAX",
"eSW_NoTime", "SW_OUTNPERIODS", "SW_OUTNKEYS", "SW_NSUMTYPES", "NVEGTYPES",
"OUT_DIGITS",
"N_SWRCs", "N_PTFs"
"N_SWRCs", "N_PTFs", "MAX_INPUT_COLUMNS"
};

// Vegetation types
Expand Down
Loading