Skip to content

Commit f10372f

Browse files
Merge pull request #45 from noaa-afsc/21-update_inputs_for_2026
21 update inputs for 2026
2 parents 845d8f4 + 66fd492 commit f10372f

File tree

17 files changed

+784
-1358
lines changed

17 files changed

+784
-1358
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
*.Rproj.user
44
*.Ruserdata
55
*.RData
6+
/analyses/monitoring_costs/ais_billable_sea_days/*.xlsx
7+
/analyses/monitoring_costs/ais_billable_sea_days/travel/*.xlsx
8+
*SCRATCH.*
69
.Rproj.user

analyses/effort_prediction/effort_prediction.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
## User inputs ---- ADPyear, whether outputs are to be saved this run, and the auth token for getting data.
1515
#==============================#
1616

17-
ADPyear <- as.numeric(rstudioapi::showPrompt(title = "Enter year",
18-
message = "What year is the ADP year? (four digits, example: 2025)"))
19-
17+
ADPyear <- 2026
2018
saveoutputs <- "YES" # Must be "YES" to save figures and rdata file. Use any other value to skip saves.
2119

2220
if(!require("FMAtools")) devtools::install_github("Alaska-Fisheries-Monitoring-Analytics/FMAtools")
-22 Bytes
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This folder contains the monthly travel cost spreadsheets given to Lisa Thompson by AIS. Occasionally the .xlsx files are not alwas immediately readable by R so copies that work are made (e.g., `April 2025 Travel_FINAL.xlsx` has a copy that works called `April 2025 Travel_FIXED.xlsx`).
2+
3+
The travel spreadsheet folder is here:
4+
https://drive.google.com/drive/folders/15lu3k2glo5Msa9F_bEo9lUSstRlSE6J6
5+
6+
...and resides within the folder that contains the AIS billable days spreadsheets: https://drive.google.com/drive/folders/1T1u8JuXQ1XLEAJR9So4HtHEA8upz1I8C
7+
8+
Lisa Thompson is the owner.
9+

analyses/monitoring_costs/monitoring_costs.R

Lines changed: 670 additions & 282 deletions
Large diffs are not rendered by default.
6.42 KB
Loading
597 Bytes
Loading
-1.22 KB
Loading

get_data.R

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -652,37 +652,11 @@ fg_em <- unique(fg_em)
652652
# Counts of vessels listed in EM
653653
fg_em[, .N, by = FLAG]
654654

655-
# * Effort prediction ----
656-
effort_strata <- work.data |>
657-
# select necessary columns
658-
_[CVG_NEW == "PARTIAL", .(ADP, STRATA = STRATA_NEW, TRIP_TARGET_DATE, TRIP_ID)
659-
# ensure one trip target date per trip, making it the minimum trip target date
660-
][, TRIP_TARGET_DATE := min(TRIP_TARGET_DATE), by = TRIP_ID] |>
661-
unique() |>
662-
setorder(ADP, STRATA, TRIP_TARGET_DATE) |>
663-
_[ , TRIPS := 1/.N, by = TRIP_ID
664-
# find julian dates
665-
][, JULIAN_DATE := yday(TRIP_TARGET_DATE)
666-
# set julian date to 1 for trips that left in year adp - 1
667-
][, JULIAN_DATE := ifelse(year(TRIP_TARGET_DATE) < ADP, 1, JULIAN_DATE)
668-
# set julian date to 366 for trips that left in year adp + 1
669-
][, JULIAN_DATE := ifelse(year(TRIP_TARGET_DATE) > ADP, 366, JULIAN_DATE)][]
670-
671-
#' isolate the latest date for which we have data in the most recent year of VALHALLA
672-
effort_strata.max_date <- max(effort_strata[ADP == ADPyear - 1, JULIAN_DATE])
673-
# count trips through max_date and total trips by year and stratum
674-
effort_strata <- effort_strata[, .(
675-
MAX_DATE_TRIPS = sum(TRIPS[JULIAN_DATE <= effort_strata.max_date]),
676-
TOTAL_TRIPS = sum(TRIPS)
677-
), by = .(ADP, STRATA)
678-
# make total trips NA for ADPyear - 1, since the year is not over
679-
][ADP == ADPyear - 1, TOTAL_TRIPS := NA][]
680-
681655
#' *===================================================================================================================*
682656

683-
# MANUAL CORRECTIONS : Split long TRIP_IDs ----
657+
# FINAL MANUAL CORRECTIONS : Split long TRIP_IDs ----
684658

685-
# These corrections need to be made before they affect trip_duration.R
659+
#' *These corrections need to be made before they affect effort_prediction.R and trip_duration.R*
686660

687661
#' [2026FinalADP: Splitting two OB_TRW_GOA tender trips that merged trips over a large time span]
688662

@@ -717,6 +691,32 @@ work.data |>
717691

718692
#' *===================================================================================================================*
719693

694+
# * Effort prediction ----
695+
effort_strata <- work.data |>
696+
# select necessary columns
697+
_[CVG_NEW == "PARTIAL", .(ADP, STRATA = STRATA_NEW, TRIP_TARGET_DATE, TRIP_ID)
698+
# ensure one trip target date per trip, making it the minimum trip target date
699+
][, TRIP_TARGET_DATE := min(TRIP_TARGET_DATE), by = TRIP_ID] |>
700+
unique() |>
701+
setorder(ADP, STRATA, TRIP_TARGET_DATE) |>
702+
_[ , TRIPS := 1/.N, by = TRIP_ID
703+
# find julian dates
704+
][, JULIAN_DATE := yday(TRIP_TARGET_DATE)
705+
# set julian date to 1 for trips that left in year adp - 1
706+
][, JULIAN_DATE := ifelse(year(TRIP_TARGET_DATE) < ADP, 1, JULIAN_DATE)
707+
# set julian date to 366 for trips that left in year adp + 1
708+
][, JULIAN_DATE := ifelse(year(TRIP_TARGET_DATE) > ADP, 366, JULIAN_DATE)][]
709+
710+
#' isolate the latest date for which we have data in the most recent year of VALHALLA
711+
effort_strata.max_date <- max(effort_strata[ADP == ADPyear - 1, JULIAN_DATE])
712+
# count trips through max_date and total trips by year and stratum
713+
effort_strata <- effort_strata[, .(
714+
MAX_DATE_TRIPS = sum(TRIPS[JULIAN_DATE <= effort_strata.max_date]),
715+
TOTAL_TRIPS = sum(TRIPS)
716+
), by = .(ADP, STRATA)
717+
# make total trips NA for ADPyear - 1, since the year is not over
718+
][ADP == ADPyear - 1, TOTAL_TRIPS := NA][]
719+
720720
# * Trip duration ----
721721

722722
#' First, trim off the most recent 4 years of trips. Modeling trip duration over the entire dataset is not needed and

0 commit comments

Comments
 (0)