Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: remora
Title: Rapid Extraction of Marine Observations for Roving Animals
Version: 0.9.9
Date: 2025-10-16
Version: 0.9.10.9002
Date: 2026-05-19
Authors@R:
c(person(given = "Fabrice",
family = "Jaine",
Expand Down Expand Up @@ -117,6 +117,8 @@ Depends: R (>= 4.1.0)
SystemRequirements: GDAL (>= 3.6.2), GEOS (>= 3.11.0), PROJ (>= 9.2.0)
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Remotes:
erocoar/gghalves
RoxygenNote: 7.3.3
Config/testthat/edition: 3
Config/testthat/parallel: true
69 changes: 42 additions & 27 deletions R/extractBlue.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extractBlue <- function(df,
.parallel = FALSE,
.ncores = NULL,
verbose = TRUE) {

# Initial checks of parameters
if(!X %in% colnames(df)){stop("Cannot find X coordinate in dataset, provide column name where variable can be found")}
if(!Y %in% colnames(df)){stop("Cannot find Y coordinate in dataset, provide column name where variable can be found")}
Expand All @@ -125,13 +125,21 @@ extractBlue <- function(df,
stop("Please provide the extract_depth argument as numeric")
}
if(full_timeperiod) {
if(is.null(station_name))
stop("Please provide column with station names in the 'station_name' argument.")
if(is.null(station_name))
stop("Please provide column with station names in the 'station_name' argument.")
}
if (fill_gaps & is.null(buffer)) {
stop("Please provide a 'buffer' size to fill gaps.")

}

# Tranform longitudes because BRAN is 0-360
long_neg <- which(df[,X] < 0)
long_pos <- which(df[,X] > 0)
if (length(long_neg) > 0)
df[long_neg,X] <- df[long_neg,X] + 180.001
if (length(long_pos) > 0)
df[long_pos,X] <- df[long_pos,X] + 179.001

# Define spatial and temporal extent of data fetch:
data_details <- ext_find(
Expand All @@ -141,13 +149,13 @@ extractBlue <- function(df,
.datetime = datetime,
.full_timeperiod = full_timeperiod,
verbose = verbose
)
)

# Create URLs to open data remotely
var_urls <- remote_urls(input = data_details,
var_name = env_var,
verbose = TRUE)
var_name = env_var,
verbose = TRUE)

# Open data remotely
if(verbose){
if (.parallel) {
Expand All @@ -157,26 +165,33 @@ extractBlue <- function(df,
}
}
df_env <- remote_open(input = var_urls,
depth = extract_depth,
data_details = data_details,
.fill_gaps = fill_gaps,
.buffer = buffer,
env_buffer = env_buffer,
.parallel = .parallel,
.ncores = .ncores,
var_name = env_var)
depth = extract_depth,
data_details = data_details,
.fill_gaps = fill_gaps,
.buffer = buffer,
env_buffer = env_buffer,
.parallel = .parallel,
.ncores = .ncores,
var_name = env_var)

# Match detections
df_output <- locs_match(aux_df = df,
X = X,
Y = Y,
datetime = datetime,
aux_env = df_env,
full_timeperiod = full_timeperiod,
station_name = station_name,
var_name = env_var)

X = X,
Y = Y,
datetime = datetime,
aux_env = df_env,
full_timeperiod = full_timeperiod,
station_name = station_name,
var_name = env_var)

# Revert longitudes back to original to export in lat/lon
long_neg <- which(df_output[,X] < 180)
long_pos <- which(df_output[,X] > 180)
if (length(long_neg) > 0)
df_output[long_neg,X] <- df[long_neg,X] - 180.001
if (length(long_pos) > 0)
df_output[long_pos,X] <- df_output[long_pos,X] - 179.001

# Export
return(df_output)

}
Loading