Skip to content

Commit f825cf9

Browse files
authored
Merge pull request #41 from NOAA-EDAB/dev
temp diagnostic bug fix
2 parents 67347e5 + dab7d15 commit f825cf9

4 files changed

Lines changed: 20 additions & 10 deletions

File tree

R/diag_temp_thresholds.R

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#'\item{pass}{Logical indicating if the species passes the temperature threshold test. All fields < 0.01}
2525
#'
2626
#' @section Layers:
27-
#' 0 = Surface, 4 is sediment
27+
#' 1 = Surface, n is sediment
2828
#' The sediment layer is not returned in the output.
2929
#'
3030
#'@family diagnostics
@@ -68,7 +68,10 @@ diag_temp_thresholds <- function(paramList, speciesCodes=NULL) {
6868
}
6969

7070
# get the temperature forcing data by time/polygon/layer
71-
temperatureData <- get_forcing_temperature(paramList, plotFigs=F)
71+
# increase layer vlaue to match other outputs
72+
temperatureData <- get_forcing_temperature(paramList, plotFigs=F) |>
73+
dplyr::mutate(layer = as.numeric(levels(layer)[layer])+1)
74+
sedimentLayer <- max(temperatureData$layer)
7275
# read in the output frequency to scale the recruitment time diagnostic
7376
toutinc <- get_run_prm(paramList$run.prm, "toutinc")
7477
numValsPerYear <- 365/toutinc$value
@@ -101,12 +104,10 @@ diag_temp_thresholds <- function(paramList, speciesCodes=NULL) {
101104
vdistAge <- vdistAge |>
102105
dplyr::filter(daynight == "day") |>
103106
dplyr::select(-daynight)
104-
107+
} else {
108+
stop("Not coded for dt != 24 hours")
105109
}
106110

107-
108-
109-
110111
## diagnostic to indicate which species have temperature values
111112
# within the bounds of the forcing time series. This would indicate that
112113
# the species is forced to move.
@@ -208,6 +209,8 @@ diag_temp_thresholds <- function(paramList, speciesCodes=NULL) {
208209
dplyr::filter(polygon %in% spatialExtentOfSpeciesAgeJuv)
209210

210211
# Adults
212+
nBoxesOccupiedAdult <- length(unique(spatialExtentOfSpeciesAgeAdult))
213+
nBoxesOccupiedJuv <- length(unique(spatialExtentOfSpeciesAgeJuv))
211214
# find proportion of boxes in extremeD that relative to extent
212215
propBoxesAgeAdult <- length(unique(extremeDAdult$polygon)) / length(unique(spatialExtentOfSpeciesAgeAdult))
213216
# find proportion of time intervals in extremeD that relative to extent
@@ -236,7 +239,9 @@ diag_temp_thresholds <- function(paramList, speciesCodes=NULL) {
236239
layer = ilayer,
237240
recruitBoxes = propBoxesRecruits,
238241
ageBoxesAdult = propBoxesAgeAdult,
242+
nBoxesOccupiedAdult = nBoxesOccupiedAdult,
239243
ageBoxesJuv = propBoxesAgeJuv,
244+
nBoxesOccupiedJuv = nBoxesOccupiedJuv,
240245
recruitTime = propTimeRecruits,
241246
ageTimeAdult = propTimeAgeAdult,
242247
ageTimeJuv = propTimeAgeJuv,
@@ -258,7 +263,7 @@ diag_temp_thresholds <- function(paramList, speciesCodes=NULL) {
258263
tab <- outdf |>
259264
dplyr::filter(!is.na(pass),
260265
pass == FALSE,
261-
layer != 4) |>
266+
layer != sedimentLayer) |>
262267
dplyr::as_tibble()
263268

264269
if (nrow(tab) == 0) {

R/get_param_vert.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
#'
33
#' @description
44
#' Get the values (proportion of the population) that define the distribution among layers
5-
#' of a boxes for each 12 hour period.
5+
#' of a boxes for each 12 hour period. vertDAY_XXX and vertNIGHT_XXX are vectors. The length is the number of
6+
#' non sediment layers. The first entry for each vector refers to water column layer
7+
#' closest to the sediment and then up through the water column. Sediment layer is absent
8+
#'
69
#'
710
#' @param bio.prm path to the biology prm file
811
#'

man/diag_temp_thresholds.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/get_param_vert.Rd

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)