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 ) {
0 commit comments