Skip to content

Commit

Permalink
newhall-1.6.4: (BASICSimulationModel) proposed changes to cryic/frigi…
Browse files Browse the repository at this point in the history
…d logic

 - Use `fcd` not `1-fcd` for conversion MSAT->MSST for now, check `cs` expression
 - check `fcd` and `cs` usage -- make sure that the numerator and denominator of this ratios are correctly converted for different temperatures they may be used with and _documented_ as how they should be calculated
 - More adjustments
   - don't correct summer temperature threshold twice
 - JAR 1.6.4-3: clean and working without O/wet toggle
  • Loading branch information
brownag committed Jul 23, 2023
1 parent 92388eb commit bc50806
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
6 changes: 4 additions & 2 deletions R/AAAA.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ newhall_version <- function() {
# rJava::.jpackage(pkgname, lib.loc = libname)

# allow an option to add additional characters to jar file name (custom jar file)
jas <- getOption("jNSMR.JAR_SUFFIX", default = "-1.6.4")
jas <- getOption("jNSMR.JAR_SUFFIX", default = .get_default_suffix())

# jnf0 <- .jnsm_jar_file()
jnf <- .jnsm_jar_file(suffix = jas)
Expand All @@ -42,7 +42,7 @@ newhall_version <- function() {
#' @importFrom rJava .jfield .jnew
#' @importFrom utils packageVersion
.onAttach <- function(libname, pkgname) {
jas <- getOption("jNSMR.JAR_SUFFIX", default = "-1.6.4")
jas <- getOption("jNSMR.JAR_SUFFIX", default = .get_default_suffix())
jnf <- .jnsm_jar_file(suffix = jas)
packageStartupMessage(paste0("jNSMR (", packageVersion("jNSMR"), ") -- R interface to the classic Newhall Simulation Model\nAdded JAR file (", basename(jnf), ") to Java class path."))

Expand All @@ -52,3 +52,5 @@ newhall_version <- function() {
name = "NSM_VERSION"
))
}

.get_default_suffix <- function() "-1.6.4-3"
Binary file added inst/java/newhall-1.6.4-1.jar
Binary file not shown.
Binary file added inst/java/newhall-1.6.4-2.jar
Binary file not shown.
Binary file added inst/java/newhall-1.6.4-3.jar
Binary file not shown.
24 changes: 15 additions & 9 deletions java/org/psu/newhall/sim/BASICSimulationModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ public static NewhallResults runSimulation(double[] temperature,
}

double dif = Math.abs(at1 - at2);
double cs = dif * (1.0D - fcd) / 2.0D;
/**
* The cr[] arrays hold critera to determine temperature regime. Then
// double cs = dif * (1.0D - fcd) / 2.0D;
// TODO: check (1.0D - fcd) v.s. fcd v.s. cr[7] expression

/**
* The cr[] arrays hold criteria to determine temperature regime. Then
* the reg[] array holds the flags for each regime. The last-most flag
* that is true indicates the temp regime.
*/
Expand All @@ -232,14 +234,18 @@ public static NewhallResults runSimulation(double[] temperature,
boolean[] reg = new boolean[13];
cr[1] = tma < 0; // Mean annual air temp (MAAT) < 0C.
cr[2] = 0 <= tma && tma < 8; // 0C <= MAAT <= 8C.
cr[3] = (st - cs) < 15; // Summer temp ave minus (summer/winter difference * (1 - SOIL_AIR_REL) * 0.5) < 15C.
cr[7] = (dif * fcd) > 5; // Summer/winter difference * SOIL_AIR_REL > 5. Change to 6?
// cr[3] = (st - cs) < 15; // Summer temp ave minus (summer/winter difference * (1 - SOIL_AIR_REL) * 0.5) < 15C.
// TODO: where did latter part ^^ (... - SWD...) of this come from? Misread cryic crit 1?
cr[3] = st >= 0 && st < 15; // "non-saturated, organic surface, mean _summer_ soil temperature between 0 and 8C/15C
// TODO: st upper limit depends on saturation, O horizon
cr[7] = (dif * fcd) >= 6; // Summer/winter difference * SOIL_AIR_REL >= 6
// NOTE: Taxonomy clearly states difference greater/equal than 6, not 5
cr[8] = (tma >= 8) && (tma < 15); // 8C <= MAAT < 15C.
cr[9] = (tma >= 15) && (tma < 22); // 15C <= MAAT < 22C.
cr[10] = tma >= 22; // 22C <= MAAT.
cr[11] = tma < 8; // MAAT < 8C.
reg[1] = cr[1]; // PERGELIC
reg[2] = cr[2] && cr[3]; // CRYIC
reg[2] = cr[2] && cr[3]; // CRYIC
reg[3] = cr[11] && !cr[3] && cr[7]; // FRIGID
reg[4] = cr[8] && cr[7]; // MESIC
reg[5] = cr[9] && cr[7]; // THERMIC
Expand All @@ -249,8 +255,8 @@ public static NewhallResults runSimulation(double[] temperature,
reg[9] = cr[9] && !cr[7]; // ISOTHERMIC
reg[10] = cr[10] && !cr[7]; // ISOHYPERTHERMIC

st -= cs;
wt += cs;
//st -= cs;
//wt += cs;
dif = st - wt;

String trr = "";
Expand Down Expand Up @@ -3349,7 +3355,7 @@ public static NewhallResults runSimulation(NewhallDataset dataset, double waterH
boolean[] reg = new boolean[13];
cr[1] = (tma < 0.0D);
cr[2] = (0.0D <= tma && tma < 8.0D);
cr[3] = (st - cs < 15.0D);
cr[3] = (st * (1 - fcd) < 15.0D);
/* 230 */ cr[7] = (dif * fcd > 5.0D);
cr[8] = (tma >= 8.0D && tma < 15.0D);
cr[9] = (tma >= 15.0D && tma < 22.0D);
Expand Down
4 changes: 4 additions & 0 deletions misc/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Manifest-Version: 1.0
Main-Class: org.psu.newhall.Newhall
Created-By: 14.0.2 (Private Build)

0 comments on commit bc50806

Please sign in to comment.