Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/dbzh
Browse files Browse the repository at this point in the history
  • Loading branch information
adokter authored Oct 20, 2023
2 parents dc9f3ed + 0582320 commit 15bc256
Show file tree
Hide file tree
Showing 20 changed files with 164 additions and 350 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ inst/extdata/vpts.txt.zip
^CRAN-SUBMISSION$
^doc$
^Meta$
rosm.cache
^rosm\.cache$
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ Imports:
viridisLite
Suggests:
aws.s3,
ggmap (>= 3.0.0),
ggspatial,
knitr,
prettymapr,
rmarkdown,
rosm,
sf,
testthat (>= 3.0.0),
tidyselect,
Expand Down
18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# bioRad 0.7.3

## New features

* Replaced the `ggmap` package with `ggspatial` for map visualizations. This change was made as `ggmap` no longer provides reliable open-source basemaps without the necessity to register for an API key (#638).

## Bugfixes

* Corrected incorrect mapping of to `dbz_all` data column in [VPTS CSV](https://aloftdata.eu/vpts-csv/) format to corresponding `DBZH` data column in bioRad vpts object (#634).

* Improved the VPTS file fetching mechanism from s3: now skips a day if there are issues with fetching instead of aborting the entire download (#636)

## Deprecations

* `download_basemap()` has been deprecated, function `map()` now automatically downloads a basemap (#638).

# bioRad 0.7.2

## Bugfixes
Expand Down Expand Up @@ -48,6 +64,8 @@ bioRad 0.7 includes a major backend overhaul that deprecates the use of Docker.

## Deprecations



* Argument `local_install` in `calculate_vp()` and `apply_mistnet()` is now deprecated.

* Functions `check_docker()` and `update_docker()` have been deprecated.
Expand Down
12 changes: 11 additions & 1 deletion R/bioRad-deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,14 @@ vol2bird_version <- function(...) {
warning("vol2bird_version has been moved to package vol2birdR")
vol2birdR::vol2bird_version()
}

#' @section download_basemap:
#' This function has been deprecated
#' ggmap has been replaced by ggspatial which no longer requires a pre-downloaded raster basemap
#'
#' @rdname bioRad-deprecated
#' @export
#' @return No return value, called for warning message side effect only
download_basemap <- function(...) {
warning("download_basemap has been deprecated; ?bioRad::map for details")
return("cartolight")
}
59 changes: 30 additions & 29 deletions R/color_scale.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# Color scale used in map plots:
colors_dbz <- c(
"lightblue", "darkblue",
"green", "yellow", "red",
"magenta"
)
colors_vrad <- c("blue", "white", "red")

# Color scale used in vertical profile plots:
r_points <- c(1, 63, 82, 94, 146, 177, 192, 209, 256)
r_values <- c(255, 255, 163, 255, 255, 81, 81, 0, 0)
g_points <- c(1, 65, 80, 111, 143, 256)
g_values <- c(255, 255, 163, 163, 0, 0)
b_points <- c(1, 80, 97, 111, 128, 160, 207, 256)
b_values <- c(255, 0, 0, 82, 0, 0, 255, 0)
vpts_default_palette <- grDevices::rgb(approx(
r_points, r_values,
seq(1, 255, length.out = 255)
)$y,
approx(
g_points, g_values,
seq(1, 255, length.out = 255)
)$y,
approx(
b_points, b_values,
seq(1, 255, length.out = 255)
)$y,
maxColorValue = 255
)

color_scale <- function(param, zlim, na.value = "transparent") {
if (param %in% c("VRADH", "VRADV", "VRAD")) {
colorscale <- ggplot2::scale_colour_gradient2(
Expand Down Expand Up @@ -118,35 +148,6 @@ add_color_transparency <- function(color, alpha = 1) {
}
}

# Color scale used in map plots:
colors_dbz <- c(
"lightblue", "darkblue",
"green", "yellow", "red",
"magenta"
)
colors_vrad <- c("blue", "white", "red")

# Color scale used in vertical profile plots:
r_points <- c(1, 63, 82, 94, 146, 177, 192, 209, 256)
r_values <- c(255, 255, 163, 255, 255, 81, 81, 0, 0)
g_points <- c(1, 65, 80, 111, 143, 256)
g_values <- c(255, 255, 163, 163, 0, 0)
b_points <- c(1, 80, 97, 111, 128, 160, 207, 256)
b_values <- c(255, 0, 0, 82, 0, 0, 255, 0)
vpts_default_palette <- grDevices::rgb(approx(
r_points, r_values,
seq(1, 255, length.out = 255)
)$y,
approx(
g_points, g_values,
seq(1, 255, length.out = 255)
)$y,
approx(
b_points, b_values,
seq(1, 255, length.out = 255)
)$y,
maxColorValue = 255
)

get_zlim <- function(param, zlim) {
if (param %in% c("DBZH", "DBZV", "DBZ")) {
Expand Down
5 changes: 1 addition & 4 deletions R/composite_ppi.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@
#' # across the available scans at each geographic location
#' composite <- composite_ppi(ppis, method = "max", res=1000)
#'
#' # Download basemap
#' bm <- download_basemap(composite)
#'
#' # Plot the calculated max product on the basemap
#' map(composite, bm)
#' map(composite)
#' }
composite_ppi <-
function(x,
Expand Down
128 changes: 0 additions & 128 deletions R/download_basemap.R

This file was deleted.

19 changes: 16 additions & 3 deletions R/download_pvolfiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,19 @@ download_pvolfiles <- function(date_min, date_max, radar,
if (nrow(bucket_df) == 0) {
# Check if date is correct
prefix_tmp <- paste(gsub("-", "/", dates[i_d]), sep = "/")
assertthat::assert_that(assertthat::not_empty(
msg <- assertthat::validate_that(assertthat::not_empty(
aws.s3::get_bucket_df(bucket = bucket, prefix = prefix_tmp, max = 1)
),
msg = paste0(
"No data availble on the ", dates[i_d],
". Please check data availability for this date."
)
)
assertthat::assert_that(assertthat::not_empty(
if(msg != TRUE){
warning(msg)
next
}
msg <- assertthat::validate_that(assertthat::not_empty(
aws.s3::get_bucket_df(bucket = bucket, prefix = prefix, max = 1)
),
msg = paste0(
Expand All @@ -114,6 +118,10 @@ download_pvolfiles <- function(date_min, date_max, radar,
" https://noaa-nexrad-level2.s3.amazonaws.com/index.html"
)
)
if(msg != TRUE){
warning(msg)
next
}
}

# filter bucket with exact date
Expand All @@ -130,12 +138,17 @@ download_pvolfiles <- function(date_min, date_max, radar,
# throw out occasional NA keys, see e.g. 2015/03/01/KEPZ/
bucket_df %>% dplyr::filter(!is.na(.data$Key)) -> bucket_df

assertthat::assert_that(nrow(bucket_df) > 0,
msg <- assertthat::validate_that(nrow(bucket_df) > 0,
msg = paste0(
"No data available for ", radar, " on the ", dates[i_d],
"within the selected datetime range. Check radar code and data availability on",
" https://noaa-nexrad-level2.s3.amazonaws.com/index.html"
))
if(msg != TRUE){
warning(msg)
next
}


# create progress bar
message(paste0("\nDownloading pvol for ", prefix))
Expand Down
3 changes: 1 addition & 2 deletions R/integrate_to_ppi.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@
#' plot(ppi, param = "VID", zlim = c(0, 200))
#'
#' # Download a basemap and map the ppi
#' bm <- download_basemap(ppi)
#' map(ppi, bm)
#' map(ppi)
#'
#' # The ppi can also be projected on a user-defined raster, as follows:
#'
Expand Down
Loading

0 comments on commit 15bc256

Please sign in to comment.