From 97eb6cd8e6a826b52d0c28b71cb2ffb4c2fe7ed1 Mon Sep 17 00:00:00 2001 From: sean-rohan-NOAA Date: Wed, 11 Sep 2024 11:56:36 -0700 Subject: [PATCH 1/3] Update README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9990264..ca63082 100644 --- a/README.md +++ b/README.md @@ -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 From 8e29a8a100e6d86d9e29c2faf8737869dbaa93e4 Mon Sep 17 00:00:00 2001 From: sean-rohan-NOAA Date: Fri, 15 Nov 2024 15:37:33 -0800 Subject: [PATCH 2/3] Bug fix --- 0_update_cold_pool_index.Rmd | 27 +++++++++++++++++++++++++++ DESCRIPTION | 4 ++-- NEWS | 7 +++++++ R/interpolate_variable.R | 4 ++-- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/0_update_cold_pool_index.Rmd b/0_update_cold_pool_index.Rmd index cba0c7e..3fe72f9 100644 --- a/0_update_cold_pool_index.Rmd +++ b/0_update_cold_pool_index.Rmd @@ -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. diff --git a/DESCRIPTION b/DESCRIPTION index 39c912a..950b29c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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")), @@ -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, diff --git a/NEWS b/NEWS index f571323..36c9313 100644 --- a/NEWS +++ b/NEWS @@ -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) ---------------------------------------------------------------- diff --git a/R/interpolate_variable.R b/R/interpolate_variable.R index e7a4723..fa373bd 100644 --- a/R/interpolate_variable.R +++ b/R/interpolate_variable.R @@ -121,8 +121,8 @@ interpolate_variable <- function(dat, 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) } From 194f35cc7580abe6a348334103ae455743cbd912 Mon Sep 17 00:00:00 2001 From: Sean Rohan <65584161+sean-rohan-NOAA@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:55:11 -0800 Subject: [PATCH 3/3] Update interpolate_variable.R --- R/interpolate_variable.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/R/interpolate_variable.R b/R/interpolate_variable.R index b7d1ad5..8d2d1e2 100644 --- a/R/interpolate_variable.R +++ b/R/interpolate_variable.R @@ -130,6 +130,15 @@ interpolate_variable <- function(dat, xshift <- ((-1625000/cell_resolution) - floor(-1625000/cell_resolution))*cell_resolution yshift <- ((379500/cell_resolution) - floor(379500/cell_resolution))*cell_resolution bbox <- bbox + c(xshift,yshift,xshift,yshift) + + interp_raster <- terra::rast(xmin = bbox["xmin"], + xmax = bbox["xmax"], + ymin = bbox["ymin"], + ymax = bbox["ymax"], + nrows = floor((bbox["ymax"]-bbox["ymin"])/cell.resolution), + ncols = floor((bbox["xmax"]-bbox["xmin"])/cell.resolution), + crs = interpolation.crs) + } } else { # User-customized interpolation bounds @@ -273,4 +282,4 @@ interpolate_variable <- function(dat, -} \ No newline at end of file +}