Skip to content

Commit c3371f1

Browse files
authored
Merge pull request #47 from NOAA-EDAB/dev
sync dev with main
2 parents f825cf9 + 66c0ce8 commit c3371f1

40 files changed

Lines changed: 3896 additions & 2184 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Workflow derived from https://github.com/posit-dev/setup-air/tree/main/examples
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
8+
name: format-check.yaml
9+
10+
permissions: read-all
11+
12+
jobs:
13+
format-check:
14+
name: format-check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Install
20+
uses: posit-dev/setup-air@v1
21+
22+
- name: Check
23+
run: air format . --check

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ Authors@R:
2020
role = c("aut"),
2121
email = "Robert.Gamble@noaa.gov"),
2222
person(given = "Ryan",family = "Morse", role = c("aut"),
23-
email = "ryan.morse@noaa.gov",
24-
comment = c(ORCID = "YOUR-ORCID-ID")))
23+
email = "ryan.morse@noaa.gov"))
2524
Description: Atlantis diagnostics functions in this package are used to determine whether the model
2625
is meeting defined performance and review criteria. Processing functions are used to format the model output for
2726
plotting and diagnostic tests

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
export(compare_spatial_vars)
44
export(diag_cohortBiomass)
5+
export(diag_combine)
56
export(diag_fleet_catch)
67
export(diag_footprints)
78
export(diag_maxsize)
@@ -11,6 +12,7 @@ export(diag_stability)
1112
export(diag_temp_thresholds)
1213
export(get_atl_paramfiles)
1314
export(get_forcing_temperature)
15+
export(get_habitable_boxes)
1416
export(get_param_FXXX_SY)
1517
export(get_param_move_temp)
1618
export(get_param_recruit_hdistrib)

R/agg_custom.R

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,33 @@
66
#'
77
#' @noRd
88

9-
10-
agg_custom <- function(data, groups, fun, agg.scale){
9+
agg_custom <- function(data, groups, fun, agg.scale) {
1110
out = atlantistools::agg_data(data = data, groups = groups, fun = fun) %>%
12-
mutate(date = as.POSIXct(time*365*86400, origin = '1964-01-01 00:00:00',tz = 'UTC'))
11+
mutate(
12+
date = as.POSIXct(
13+
time * 365 * 86400,
14+
origin = '1964-01-01 00:00:00',
15+
tz = 'UTC'
16+
)
17+
)
1318

14-
if(agg.scale == 'month') {
15-
out$time.agg = as.numeric(factor(format(out$date,format = '%m')))
16-
}else if(agg.scale == 'year'){
19+
if (agg.scale == 'month') {
20+
out$time.agg = as.numeric(factor(format(out$date, format = '%m')))
21+
} else if (agg.scale == 'year') {
1722
out$time.agg = as.numeric(factor(format(out$date, format = '%Y')))
18-
}else{
19-
out$time.agg = out$time*365
23+
} else {
24+
out$time.agg = out$time * 365
2025
}
2126

22-
match.cols = c(groups[-which(groups == 'time')],'time.agg')
27+
match.cols = c(groups[-which(groups == 'time')], 'time.agg')
2328
out.agg = out %>%
2429
group_by_at(match.cols) %>%
25-
dplyr::summarise(time = floor(min(time)),
26-
atoutput = mean(atoutput,na.rm=T),.groups="drop")
27-
dplyr::select(all_of(c(groups,'atoutput')))
30+
dplyr::summarise(
31+
time = floor(min(time)),
32+
atoutput = mean(atoutput, na.rm = T),
33+
.groups = "drop"
34+
)
35+
dplyr::select(all_of(c(groups, 'atoutput')))
2836

2937
return(out.agg)
3038
}

R/calc_mef.R

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,18 @@
1111
#'
1212
#'@noRd
1313

14-
15-
1614
calc_mef <- function(observed, expected) {
17-
1815
#remove NAs. Exist only in observed data
1916
expected <- expected[!is.na(observed)]
2017
observed <- observed[!is.na(observed)]
2118

22-
oo <- sum((observed-mean(observed))^2)
19+
oo <- sum((observed - mean(observed))^2)
2320
po <- sum((expected - observed)^2)
2421

25-
mef <- (oo-po)/oo
22+
mef <- (oo - po) / oo
2623

2724
# number of data point used in calculation
2825
n <- length(expected)
2926

30-
return(list(mef=mef,n=n))
27+
return(list(mef = mef, n = n))
3128
}

R/check_species_codes.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,29 @@
1111
#'
1212
#' @noRd
1313

14-
check_species_codes <- function(modelBiomass,speciesCodes){
15-
14+
check_species_codes <- function(modelBiomass, speciesCodes) {
1615
# use default options
1716
atlantisCodes <- modelBiomass %>%
1817
dplyr::filter(!is.na(.data$code)) %>%
1918
dplyr::distinct(.data$code) %>%
2019
dplyr::pull()
2120
# use default options
22-
if (is.null(speciesCodes)) { # select all species
21+
if (is.null(speciesCodes)) {
22+
# select all species
2323
speciesCodes <- atlantisCodes
2424
} else {
2525
# remove NA's check for codes not in atlantis
2626
speciesCodes <- speciesCodes[!is.na(speciesCodes)]
2727
# check to make sure no non atlantis codes
28-
invalidCodes <- base::setdiff(speciesCodes,atlantisCodes)
28+
invalidCodes <- base::setdiff(speciesCodes, atlantisCodes)
2929

30-
if (!(length(invalidCodes)==0)){
31-
stop("Invalid Atlantis group codes: ",paste0(invalidCodes,collapse=", "))
30+
if (!(length(invalidCodes) == 0)) {
31+
stop(
32+
"Invalid Atlantis group codes: ",
33+
paste0(invalidCodes, collapse = ", ")
34+
)
3235
}
3336
}
3437

3538
return(speciesCodes)
36-
3739
}

0 commit comments

Comments
 (0)