Skip to content

Commit

Permalink
Merge pull request #61 from afsc-gap-products/dev
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
sean-rohan-NOAA authored Nov 15, 2024
2 parents b853ec7 + 194f35c commit 8159f7c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
27 changes: 27 additions & 0 deletions 0_update_cold_pool_index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,33 @@ nbs_mean_temperature$LAST_UPDATE <- Sys.Date()
```

```{r cpa_change}
cpa_previous_year <- tail(coldpool:::cold_pool_index$AREA_LTE2_KM2,2)[1]
cpa_this_year <- tail(coldpool:::cold_pool_index$AREA_LTE2_KM2,1)
(cpa_previous_year - cpa_this_year) /cpa_previous_year
lte1_previous_year <- tail(coldpool:::cold_pool_index$AREA_LTE1_KM2,2)[1]
lte1_this_year <- tail(coldpool:::cold_pool_index$AREA_LTE1_KM2,1)
(lte1_previous_year - lte1_this_year) / lte1_previous_year
lte0_previous_year <- tail(coldpool:::cold_pool_index$AREA_LTE0_KM2,2)[1]
lte0_this_year <- tail(coldpool:::cold_pool_index$AREA_LTE0_KM2,1)
(lte0_previous_year - lte0_this_year) / lte0_previous_year
lteminus1_previous_year <- tail(coldpool:::cold_pool_index$AREA_LTEMINUS1_KM2,2)[1]
lteminus1_this_year <- tail(coldpool:::cold_pool_index$AREA_LTEMINUS1_KM2,1)
(lteminus1_previous_year - lteminus1_this_year) / lteminus1_previous_year
```

# 5. Add data to R/sysdata.rda ----

Update sysdata.rda with cold pool area, mean bottom temperature, mean surface temperature, and and 5-km resolution rasters of surface and bottom temperature.
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: coldpool
Type: Package
Title: AFSC/RACE Groundfish Assessment Program EBS and NBS temperature products
Version: 3.3-1
Version: 3.4-2
Authors@R: c(person("Sean", "Rohan", email = "sean.rohan@noaa.gov", role = c("aut", "cre")),
person("Lewis", "Barnett", email = "lewis.barnett@noaa.gov", role = c("aut", "ctb")),
person("Kelly", "Kearney", role = c("ctb")),
Expand All @@ -25,7 +25,7 @@ Description: This package calculates the area of the cold pool in the eastern Be
License: GPL (>=2)
Encoding: UTF-8
LazyData: false
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Imports: colorspace,
viridis,
raster,
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
coldpool 3.4-2 (November 15, 2024)
----------------------------------------------------------------

BUG FIX

- Fix error when interpolate_variable(bbox = NULL).

coldpool 3.4-1 (August 22, 2024)
----------------------------------------------------------------

Expand Down
13 changes: 6 additions & 7 deletions R/interpolate_variable.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,17 @@ interpolate_variable <- function(dat,
plot.boundary <- akgfmaps::transform_data_frame_crs(data.frame(x = c(extrap.box['xmn'], extrap.box['xmx']),
y = c(extrap.box['ymn'], extrap.box['ymx'])),
out.crs = interpolation.crs)




n_dim <- floor(abs(plot.boundary$x[1] - plot.boundary$x[2]))/cell.resolution

interp_raster <- terra::rast(xmin = plot.boundary$x[1],
xmax = plot.boundary$x[2],
ymin = plot.boundary$y[1],
ymax = plot.boundary$y[2],
nrow = n_dim,
ncol = n_dim,
nrow = n_dim[1],
ncol = n_dim[2],
crs = interpolation.crs)

}
} else { # Default interpolation bounds for sf object regions
bbox <- sf::st_bbox(st_buffer(region_mask, cell.resolution*5))
Expand All @@ -140,6 +138,7 @@ interpolate_variable <- function(dat,
nrows = floor((bbox["ymax"]-bbox["ymin"])/cell.resolution),
ncols = floor((bbox["xmax"]-bbox["xmin"])/cell.resolution),
crs = interpolation.crs)

}
} else { # User-customized interpolation bounds

Expand Down Expand Up @@ -283,4 +282,4 @@ interpolate_variable <- function(dat,



}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ Documentation for the dataset can be accessed using:
```

## Accessing datasets without installing the package
Users can access temperature products in an R data format (.rda) without installing the package. To do so, download the [sysdata.rda](./R/sysdata.rda) file in the R directory of the coldpool repository. The data set can then be loaded in R after installing and loading the [raster](https://cran.r-project.org/web/packages/raster/index.html) package (version >= 3.2-1), as follows:
Users can access temperature products in an R data format (.rda) without installing the package. To do so, download the [sysdata.rda](./R/sysdata.rda) file in the R directory of the coldpool repository. The data set can then be loaded in R after installing and loading the [terra](https://cran.r-project.org/web/packages/terra/index.html) package, as follows:

```{r}
# Load raster package and data
library(raster)
# Load SpatRast package and data
library(terra)
load("[local_path]\\sysdata.rda")
# View loaded cold pool index data frame
Expand Down

0 comments on commit 8159f7c

Please sign in to comment.