Skip to content

Commit

Permalink
Merge pull request #18 from birdflow-science/update-preprocess
Browse files Browse the repository at this point in the history
preprocess_species updated for latest version of ebirdst. Fixes #17
  • Loading branch information
ethanplunkett committed Feb 27, 2023
2 parents 964a62f + 8d6c661 commit 0ac8775
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 43 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: BirdFlowR
Title: Forecast and Visualize Bird Movement
Version: 0.0.0.9003
Version: 0.0.0.9017
Authors@R:
c(person("Ethan", "Plunkett", email = "plunkett@umass.edu", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-4405-2251")),
Expand All @@ -9,11 +9,11 @@ Description: BirdFlowR forecasts bird movement and distribution from previously
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.2
RoxygenNote: 7.2.3
Suggests:
auk,
BirdFlowModels,
ebirdst,
ebirdst (>= 2.2021.0),
knitr,
rmarkdown,
rnaturalearthdata,
Expand Down
58 changes: 32 additions & 26 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
# BirdFlowR 0.0.0.9003 2023-02-27

* Updated installation instructions. Closing [#11](https://github.com/birdflow-science/BirdFlowR/issues/11).

* Added docker file. [Usage instructions.](https://github.com/birdflow-science/BirdFlowR/pull/15#issuecomment-1445152787)

# BirdFlowR 0.0.0.9002 2023-02-23

* Added "biocViews:" before "Imports:" in DESCRIPTION so that devtools can find
and install rhdf5 (from Bioconductor) while installing the packages BirdFlowR
needs. [#13](https://github.com/birdflow-science/BirdFlowR/issues/13)

* Vignette now attempts to load rnaturalearthdata with utils::install.packages()
instead of devtools::install_cran() in attempt to fix [#11](https://github.com/birdflow-science/BirdFlowR/issues/11)

* Updated get_naturalearth() so that it handles some cases in which it previously
failed. In particular extents that span more than 180 deg of longitude, and
extents that cross the 180 deg. meridian that defines the edge of the WGS84
projection both now work. The function still doesn't handle polar projections or
global extents in most projections. Fixes [#14](https://github.com/birdflow-science/BirdFlowR/issues/14)

# BirdFlowR 0.0.0.9001 2023-02-21
* Switched order of package installation in readme and added installation of
rnaturalearthdata to vignette [#11](https://github.com/birdflow-science/BirdFlowR/issues/11)

* Added a `NEWS.md` file to track changes to the package.

# BirdflowR 0.0.0.9017

* Fix bug introduced by ebirdst 2.2021.0 (switch from raster to terra)
[#17](https://github.com/birdflow-science/BirdFlowR/issues/17).

# BirdFlowR 0.0.0.9003 2023-02-27

* Updated installation instructions. Closing [#11](https://github.com/birdflow-science/BirdFlowR/issues/11).

* Added docker file. [Usage instructions.](https://github.com/birdflow-science/BirdFlowR/pull/15#issuecomment-1445152787)

# BirdFlowR 0.0.0.9002 2023-02-23

* Added "biocViews:" before "Imports:" in DESCRIPTION so that devtools can find
and install rhdf5 (from Bioconductor) while installing the packages BirdFlowR
needs. [#13](https://github.com/birdflow-science/BirdFlowR/issues/13)

* Vignette now attempts to load rnaturalearthdata with utils::install.packages()
instead of devtools::install_cran() in attempt to fix [#11](https://github.com/birdflow-science/BirdFlowR/issues/11)

* Updated get_naturalearth() so that it handles some cases in which it previously
failed. In particular extents that span more than 180 deg of longitude, and
extents that cross the 180 deg. meridian that defines the edge of the WGS84
projection both now work. The function still doesn't handle polar projections or
global extents in most projections. Fixes [#14](https://github.com/birdflow-science/BirdFlowR/issues/14)

# BirdFlowR 0.0.0.9001 2023-02-21
* Switched order of package installation in readme and added installation of
rnaturalearthdata to vignette [#11](https://github.com/birdflow-science/BirdFlowR/issues/11)

* Added a `NEWS.md` file to track changes to the package.
20 changes: 11 additions & 9 deletions R/preprocess_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,18 @@ preprocess_species <- function(species,

){

# ebirdst is listed under suggests so may not be installed.
# I anticipate a group of users who work with fit models provided by the
# BirdFlow team but don't fit their own models, and my initial installation
# of ebirdst was tricky so I didn't want all users to need to import it.
a <- requireNamespace("ebirdst", versionCheck = list(op =">=", version = "2.2021.0"))
if(!a){
stop("Install ebirdst >= 2.2021.0 to use preprocess_species()")
}

# Validate inputs
if(length(species) != 1)
stop("Can only preprpocess one species at a time")
stop("Can only preprocess one species at a time")
stopifnot( is.logical( tiff ),
is.logical( hdf5 ),
length( tiff ) == 1,
Expand Down Expand Up @@ -249,9 +258,7 @@ preprocess_species <- function(species,
cat("Calculating resolution\n")
# Load low res abundance data and calculate total areas birds occupy at any
# time (active_sq_m)
abunds <- terra::rast(ebirdst::load_raster("abundance",
path = sp_path,
resolution="lr"))
abunds <- ebirdst::load_raster("abundance",path = sp_path, resolution="lr")


mask <- make_mask(x = abunds)
Expand Down Expand Up @@ -422,11 +429,6 @@ preprocess_species <- function(species,
abunds_uci <- ebirdst::load_raster("abundance", metric = "upper",
path = sp_path, resolution=load_res)

# Convert to terra::rast
abunds <- terra::rast(abunds)
abunds_lci <- terra::rast(abunds_lci)
abunds_uci <- terra::rast(abunds_uci)

if(verbose)
cat("Creating mask in target resolution and projection\n")

Expand Down
5 changes: 0 additions & 5 deletions tests/testthat/test-preprocess_species.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
test_that("preprocess_species runs on test dataset", {


skip_on_ci()
skip_on_covr()
skip_on_cran()

# Run on example data setting resolution based on gb (and then overiding for example_data)
Expand All @@ -13,8 +10,6 @@ test_that("preprocess_species runs on test dataset", {

test_that("preprocess_species runs with pre-set resolution and matches prior results", {

skip_on_ci()
skip_on_covr()
skip_on_cran()

# Using snapshot on 50 m version because it results in a small object.
Expand Down

0 comments on commit 0ac8775

Please sign in to comment.