R/detections/si_run.R

source("R/detections//input_data.R")

log_info("Building long timeseries detection heatmaps by individuals ...")
to_path <-
  file.path(OUTPUT, paste("individual_vs_months", suffix, sep = ""))
ind_det_matrices <- build_all_detection_matrices(monthly_detections,
                                                 ind_or_station = TRUE)
ind_det_matrices <- correct_ind_names(ind_det_matrices)

# Create heatmaps for only_loops, no_loop transitions and both types
title <- paste("Monthly detections by individuals", main_title)
heat_maps <-
  generate_heatmaps(
    ind_det_matrices,
    title,
    legend_title,
    is_individual = TRUE,
    by_col_rows_order = HEAT_MAP_ORDER
  )

# Generate stats for all graph types
title <- paste("placeholder detections in descending order", main_title)
bar_plots <-
  build_detection_stats(ind_det_matrices, title, "Num Detections")

all_plots <- rbind(heat_maps, bar_plots)

# Combine heatmpas and plots
plots_to_pdf(all_plots, to_path, paper_type, paper_height, paper_width)
log_info("Timeseries detection heatmaps by individual finished")


log_info("Building long timeseries detection heatmaps by stations ...")
to_path <-
  file.path(OUTPUT, paste("stations_vs_months", suffix, sep = ""))
station_det_matrices <-
  build_all_detection_matrices(monthly_detections,
                               ind_or_station = FALSE)
title <- paste("Monthly detections by stations", main_title)
heat_maps <-
  generate_heatmaps(
    station_det_matrices,
    title,
    legend_title,
    is_individual = FALSE,
    by_col_rows_order = HEAT_MAP_ORDER
  )

title <- paste("placeholder detections in descending order", main_title)
bar_plots <-
  build_detection_stats(station_det_matrices, title, "Num Detections")

all_plots <- rbind(heat_maps, bar_plots)

plots_to_pdf(all_plots, to_path, paper_type, paper_height, paper_width)
log_info("Timeseries detection heatmaps by station finished")
d2gex/seabasstfm documentation built on July 29, 2022, 2:20 a.m.