Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-rohan-NOAA committed Sep 15, 2023
1 parent 231cc23 commit 4c41b72
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions R/data2raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,23 @@ data2raster <- function(dat,
{


if(is.character(bbox)) {
in_bbox <- NULL
}

if(is.numeric(bbox)) {
bbox <- sf::st_bbox(st_buffer(mymask, cell.resolution*5))
bbox <- round(bbox/cell_resolution)*cell_resolution # round to align rows/cols
xshift <- ((-1625000/cell_resolution) - floor(-1625000/cell_resolution))*cell_resolution
yshift <- ((379500/cell_resolution) - floor(379500/cell_resolution))*cell_resolution
in_bbox <- bbox + c(xshift,yshift,xshift,yshift)
mymask <- parseregion(select.region, interpolation.crs)

if(is.character(bbox)) {
in_bbox <- NULL
}

if(is.null(bbox)) {
bbox <- sf::st_bbox(st_buffer(mymask, cell.resolution*5))
bbox <- round(bbox/cell_resolution)*cell_resolution # round to align rows/cols
xshift <- ((-1625000/cell_resolution) - floor(-1625000/cell_resolution))*cell_resolution
yshift <- ((379500/cell_resolution) - floor(379500/cell_resolution))*cell_resolution
in_bbox <- bbox + c(xshift,yshift,xshift,yshift)
}


for(ii in 1:length(fittypes)) {
fit_terra <- interpolate_variable(
fit_terra <- interpolate_variable(
dat = dat,
dat.year = dat.year,
var.col = var.col,
Expand All @@ -93,8 +95,6 @@ data2raster <- function(dat,
}
}

mymask <- parseregion(select.region, interpolation.crs)

out <- out |>
akgfmaps::rasterize_and_mask(mymask)

Expand Down Expand Up @@ -366,6 +366,7 @@ calcindices_temp <- function (datafile,
bottomvar = "gear_temperature",
surfacevar = "surface_temperature")
{

# Read temperature data from .csv file

print("Reading temperature data...")
Expand Down Expand Up @@ -445,7 +446,7 @@ calcindices_temp <- function (datafile,
mean(na.rm = TRUE)

lt100_temp <- terra::mask(ras, lt100_strata, touches = FALSE)
bt_df$MEAN_BT_LT100M[i] <- terra::values(lt100_temp ) |>
bt_df$MEAN_BT_LT100M[i] <- terra::values(lt100_temp) |>
mean(na.rm = TRUE)

for (it in 1:nthresh) {
Expand Down

0 comments on commit 4c41b72

Please sign in to comment.