Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8a02f7d
add regular checks
Aug 14, 2025
126103a
update cran comments
Oct 14, 2025
f525e36
Increment version number to 0.2.3
Oct 14, 2025
156b846
Increment version number to 0.2.3.9000
Oct 14, 2025
b4cd0b6
Fix later to latter
peterdesmet Nov 14, 2025
68db134
Make error messages consistent and wrap
peterdesmet Nov 14, 2025
1ea4839
make test order independent
Nov 14, 2025
1fd4888
improve message, make sure the right example is given
Nov 14, 2025
9c81b0a
More robust romanian file format
Nov 17, 2025
a728492
Update error message
peterdesmet Nov 17, 2025
59d6712
Standardize all messages
peterdesmet Nov 17, 2025
bf14741
Add vector for cli::cli_abort() where needed
peterdesmet Nov 17, 2025
e255bd9
Update NEWS.md
peterdesmet Nov 17, 2025
c5ca61e
Fix typo
peterdesmet Nov 17, 2025
098b06b
Remove coverage argument (use default)
peterdesmet Nov 18, 2025
fb4f469
Remove catch condition test
peterdesmet Nov 18, 2025
63d6e30
restore additional information, and test
Nov 18, 2025
40c4579
restore air.toml https://posit-dev.github.io/air/configuration.html#c…
Nov 18, 2025
0884e2f
fix #148
Dec 1, 2025
5454755
appearently the non polar files are not in the repo anymore
Dec 1, 2025
9b41845
estonian url was not working in test, now restored
Dec 2, 2025
44a6252
Merge pull request #146 from aloftdata/latter
bart1 Dec 2, 2025
bdb949d
Merge branch '148-get_pvol-leaves-files-on-disk-for-the-netherland' i…
bart1 Dec 2, 2025
ae8a7c3
Merge pull request #150 from aloftdata/fix-news
bart1 Dec 2, 2025
2379fc1
Merge pull request #149 from aloftdata/148-get_pvol-leaves-files-on-d…
bart1 Dec 2, 2025
f5f48eb
Merge pull request #152 from aloftdata/main
bart1 Dec 2, 2025
367217a
Merge pull request #108 from aloftdata/106-implement-regular-checks
bart1 Dec 2, 2025
77907dd
Merge branch '133-fail-early-on-not-finding-a-dutch-converter' into m…
bart1 Dec 2, 2025
d4eda20
Fix syntax error in get_pvol_nl.R
bart1 Dec 2, 2025
7021b56
Apply suggestions from code review
bart1 Dec 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/regular-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
schedule:
- cron: '34 6 * * 1'

name: regular-checks.yaml

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: getRad
Title: Download Radar Data for Biological Research
Version: 0.2.2.9000
Version: 0.2.3.9000
Authors@R: c(
person("Bart", "Kranstauber", , "b.kranstauber@uva.nl", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8303-780X", affiliation = "University of Amsterdam")),
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# getRad (development version)

* Make error messages more consistent (#146).
* Restore access to Estonian data.
* Prevent leaving temporary files for downloading Dutch polar volume data (#148).

# getRad 0.2.3

* Improve error for requesting German data out of temporal restrictions (#131).
* Start using the air formatter (#128).
* Do not fail but rather warn when csv is missing from repository (#136).
Expand Down
21 changes: 10 additions & 11 deletions R/get_pvol.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ get_pvol <- function(radar = NULL, datetime = NULL, ...) {
check_odim_nexrad(radar)
if (anyDuplicated(radar)) {
cli::cli_abort(
"The argument {.arg radar} contains duplications these should be removed.",
"{.arg radar} contains duplications that must be removed.",
class = "getRad_error_radar_duplicated"
)
}
if (inherits(datetime, "POSIXct") && length(datetime) == 2) {
if (any(duplicated(datetime))) {
cli::cli_abort(
"When providing two {.cls POSIXct} as a {.arg datetime}
they should differ to represent an inverval.",
"{.arg datetime} contains duplicate {.cls POSIXct}. Values must differ
to represent an interval.",
class = "getRad_error_duplicated_timestamps"
)
}
Expand All @@ -61,9 +61,8 @@ get_pvol <- function(radar = NULL, datetime = NULL, ...) {
!rlang::is_scalar_vector(datetime)
) {
cli::cli_abort(
"The argument {.arg datetime} to the {.fn get_pvol} function
should be a single {.cls POSIXct} or a {.cls interval}.
The later can also be specified by two {.cls POSIXct}.",
"{.arg datetime} should be a single {.cls POSIXct} or a {.cls interval}.
The latter can also be specified by two {.cls POSIXct}.",
class = "getRad_error_time_not_correct"
)
}
Expand All @@ -88,10 +87,10 @@ get_pvol <- function(radar = NULL, datetime = NULL, ...) {
if (lubridate::is.interval(datetime)) {
if (lubridate::as.duration(datetime) > lubridate::hours(1)) {
cli::cli_warn(
"The interval specified for {.arg datetime} ({.val {lubridate::int_start(datetime)}}-{.val {lubridate::int_end(datetime)}}) likely results
in many polar volumes, when loading that may polar
volumes at the same time computational issues frequently
occur.",
"{.arg datetime} represent an interval ({.val
{lubridate::int_start(datetime)}}-{.val {lubridate::int_end(datetime)}})
that likely covers many polar volumes. Computational issues can occur
when loading that many polar volumes at the same time.",
class = "getRad_warn_many_pvols_requested"
)
}
Expand Down Expand Up @@ -148,7 +147,7 @@ select_get_pvol_function <- function(radar, ..., call = rlang::caller_env()) {
))
if (rlang::is_na(fun)) {
cli::cli_abort(
"No suitable function exist downloading from the radar {.val {radar}}",
"No suitable function exist to download data for radar {.val {radar}}.",
class = "getRad_error_no_function_for_radar_with_country_code",
call = call
)
Expand Down
9 changes: 5 additions & 4 deletions R/get_pvol_de.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ get_pvol_de <- function(radar, time, ..., call = rlang::caller_env()) {
if (nrow(files_to_get) != 50) {
cli::cli_abort(
c(
x = "The server returned an unexpected number of files.",
i = "In many cases this because no data is available for the time requested. For Germany only the last three days are available.",
i = "Alternatively there is an unstable connection or temporal error in the German data provided."
"The server returned an unexpected number of files.",
"i" = "In many cases this because no data are available for the time
requested. For Germany only the last three days are available.
The error can also be caused by an unstable connection or
temporal error in the German data provided."
),

class = "getRad_error_germany_unexpected_number_of_files",
call = call
)
Expand Down
8 changes: 4 additions & 4 deletions R/get_pvol_ee.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ get_pvol_ee <- function(radar, time, ..., call = rlang::caller_env()) {
list(
greaterThanOrEqual = list(
field = "Timestamp",
value = strftime(time, "%Y-%m-%dT%H:%M:%OS6%z")
value = strftime(time, "%FT%TZ", tz = 'UTC')
)
),
list(
lessThanOrEqual = list(
field = "Timestamp",
value = strftime(time, "%Y-%m-%dT%H:%M:%OS6%z")
value = strftime(time, "%FT%TZ", tz = "UTC")
)
)
)
Expand All @@ -62,7 +62,7 @@ get_pvol_ee <- function(radar, time, ..., call = rlang::caller_env()) {
)
)
files <- httr2::request(
"https://avaandmed.keskkonnaportaal.ee/_vti_bin/RmApi.svc/active/items/query"
"https://avaandmed.keskkonnaportaal.ee/api/lists/active/items/query"
) |>
req_user_agent_getrad() |>
httr2::req_body_json(json_list) |>
Expand All @@ -71,7 +71,7 @@ get_pvol_ee <- function(radar, time, ..., call = rlang::caller_env()) {
httr2::resp_body_json()
if (files$numFound == 0 || length(files$documents) != 1) {
cli::cli_abort(
"The expected number of files is not found",
"The expected number of files is not found.",
class = "getRad_error_get_pvol_ee_differing_n_files"
)
}
Expand Down
43 changes: 28 additions & 15 deletions R/get_pvol_nl.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ get_pvol_nl <- function(radar, time, ..., call = rlang::caller_env()) {
if (converter == "") {
cli::cli_abort(
c(
x = "The program to convert KNMI data to ODIM format is not found.",
i = "The source code for this binary can be obtained from this location {.file {system.file('extra/KNMI_vol_h5_to_ODIM_h5.c', package='getRad')}}",
i = "Please compile the binary and include it in the search path as a program named {.arg KNMI_vol_h5_to_ODIM_h5}",
i = "On linux systems this can be done with the following command {.code h5cc KNMI_vol_h5_to_ODIM_h5.c -o KNMI_vol_h5_to_ODIM_h5}.",
i = "If another name is used or the program is not in the search path use options to locate the program ({.run options(getRad.nl_converter='')})."
"The program to convert KNMI data to the ODIM format can't be found.",
"i" = "The source code for this binary can be obtained from {.file
{system.file(\"extra/KNMI_vol_h5_to_ODIM_h5.c\",
package=\"getRad\")}}.",
"i" = "Please compile the binary and include it in the search path as
a program named {.val KNMI_vol_h5_to_ODIM_h5}. On linux systems
this can be done with the command {.code h5cc
KNMI_vol_h5_to_ODIM_h5.c -o KNMI_vol_h5_to_ODIM_h5}. If another
name is used or the program is not in the search path, use
options to locate the program ({.code
options(getRad.nl_converter=\"\")})."
),
class = "getRad_error_no_nl_converter_found",
call = call
Expand Down Expand Up @@ -55,8 +61,10 @@ get_pvol_nl <- function(radar, time, ..., call = rlang::caller_env()) {
httr2_http_403 = function(cnd) {
cli::cli_abort(
c(
"There was an authorization error, possibly this relates to using an invalid API key",
i = "Please check if you set the correct `nl_api_key` with {.code get_secret('nl_api_key')}"
"There was an authorization error. You may have used an invalid API
key.",
"i" = "Please check if you set the correct {.val nl_api_key} with
{.code get_secret(\"nl_api_key\")}."
),
cnd = cnd,
class = "getRad_error_get_pvol_nl_authorization_failure",
Expand All @@ -70,7 +78,8 @@ get_pvol_nl <- function(radar, time, ..., call = rlang::caller_env()) {
httr2::req_url(req = resp$request) |>
httr2::req_headers(Authorization = NULL) |>
httr2::req_perform(path = file, error_call = call)
pvol_path <- paste0(req$body, ".odim.h5")

withr::with_tempfile("pvol_path", fileext = ".odim.h5", {
system(
paste(converter, pvol_path, req$body),
ignore.stdout = TRUE,
Expand All @@ -79,13 +88,17 @@ get_pvol_nl <- function(radar, time, ..., call = rlang::caller_env()) {
if (!file.exists(pvol_path)) {
cli::cli_abort(
c(
x = "The converter for the Netherland has not generated the output file.",
i = "Using {.file {converter}} an attempt was made to convert {.file {req$body}} to the odim format. Most likely the converter is incorrect."
),
class = "getRad_error_dutch_converter_failed"
)
}
bioRad::read_pvolfile(pvol_path, ...)
x = "The converter for the Netherland has not generated the expected
output file.",
i = "Using {.file {converter}} an attempt was made to convert
{.file {req$body}} to the odim format. Most likely the
converter is incorrect."
),
class = "getRad_error_dutch_converter_failed"
)
}
bioRad::read_pvolfile(pvol_path, ...)
})
})
return(pvol)
}
7 changes: 4 additions & 3 deletions R/get_pvol_se.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ get_pvol_se <- function(radar, time, ..., call = rlang::caller_env()) {
httr2_http_404 = function(cnd) {
cli::cli_abort(
c(
x = "No polar volume data could be found for {.val {radar}} at time {.val {time}}",
i = "Volume data in Sweden is only available for 24 hours",
i = "If the requested time is within the last 24 hours the error might relate to a server outage or package problem"
"Can't find polar volume data for {.val {radar}} at {.val {time}}.",
"i" = "Polar volume data in Sweden is only available for 24 hours.
If the requested time is within the last 24 hours the error
might relate to a server outage or package problem."
),
parent = cnd,
call = call,
Expand Down
8 changes: 4 additions & 4 deletions R/get_pvol_us.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ get_pvol_us <- function(radar, datetime, ..., call = rlang::caller_env()) {
httr2::req_perform(path = file, error_call = call),
httr2_http_404 = function(cnd) {
cli::cli_abort(
"NEXRAD file not found at {.url {url}}.",
"Can't find NEXRAD file at {.url {url}}.",
call = call,
cnd = cnd,
class = "getRad_error_us_file_not_found"
Expand Down Expand Up @@ -48,8 +48,7 @@ get_pvol_us <- function(radar, datetime, ..., call = rlang::caller_env()) {
d <- as.Date(date, tz = "UTC")
if (!rlang::is_scalar_character(radar)) {
cli::cli_abort(
"Radar should be a character of length one as otherwise not all
key date combinations might be tried",
"{.arg radar} must be single radar code.",
class = "getRad_error_pvol_us_radar_not_scalar",
call = call
)
Expand Down Expand Up @@ -145,7 +144,8 @@ get_pvol_us <- function(radar, datetime, ..., call = rlang::caller_env()) {
)
if (!length(ts)) {
cli::cli_abort(
"No scans found for {.val {radar}} near {.val {format(datetime, '%F %T %Z')}}",
"Can't find scans for radar {.val {radar}} near {.val {format(datetime,
\"%F %T %Z\")}}.",
class = "getRad_error_us_no_scan_found",
call = call
)
Expand Down
32 changes: 12 additions & 20 deletions R/get_vpts.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,14 @@ get_vpts <- function(
if (missing(source)) {
source <- "baltrad"
}
supported_sources <- eval(rlang::fn_fmls()$source)

if (is.null(source)) {
# providing NULL isn't allowed either
cli::cli_abort(
glue::glue(
"Please provide a value for the source argument:
possible values are {possible_sources}.",
possible_sources = glue::glue_collapse(
glue::backtick(eval(rlang::fn_fmls()$source)),
sep = ", ",
last = " or "
)
c(
"{.arg source} must be provided.",
"i" = "Supported sources: {.val {supported_sources}}."
),
class = "getRad_error_source_missing"
)
Expand All @@ -92,7 +89,7 @@ get_vpts <- function(
## the enumeration in the function definition.
if (length(source) > 1) {
cli::cli_abort(
"Only one source can be queried at a time.",
"{.arg source} must be a single character value.",
class = "getRad_error_multiple_sources"
)
}
Expand All @@ -101,17 +98,11 @@ get_vpts <- function(

# Get the default value of the source arg, even if the user provided
# a different value.
supported_sources <- eval(formals()$source)
if (!source %in% supported_sources) {
cli::cli_abort(
glue::glue(
"Invalid source {glue::backtick(source)} provided. Possible values are:
{possible_sources}.",
possible_sources = glue::glue_collapse(
glue::backtick(supported_sources),
sep = ", ",
last = " or "
)
c(
"{.arg source} {.val {source}} is invalid.",
"i" = "Supported sources: {.val {supported_sources}}."
),
class = "getRad_error_source_invalid"
)
Expand All @@ -120,7 +111,7 @@ get_vpts <- function(
# Check that the provided radar argument is a character vector
if (!is.character(radar)) {
cli::cli_abort(
"Radar argument must be a character vector.",
"{.arg radar} must be a character vector.",
class = "getRad_error_radar_not_character"
)
}
Expand All @@ -132,7 +123,8 @@ get_vpts <- function(
!lubridate::is.interval(datetime)
) {
cli::cli_abort(
"{.arg datetime} argument must be a {.cls character}, {.cls POSIXct}, {.cls Date}, or {.cls Interval} object.",
"{.arg datetime} must be a {.cls character}, {.cls POSIXct}, {.cls Date},
or {.cls Interval} object.",
class = "getRad_error_date_parsable"
)
}
Expand Down
11 changes: 5 additions & 6 deletions R/get_vpts_aloft.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ get_vpts_aloft <- function(
if (!all(radar_odim_code %in% coverage$radar)) {
missing_radar <- radar_odim_code[!radar_odim_code %in% coverage$radar]
cli::cli_abort(
"Radar not found in ALOFT coverage:
{missing_radar}.",
"Can't find radar {.val {missing_radar}} in the coverage file (see
{.fun get_vpts_coverage}).",
missing_radar = missing_radar,
class = "getRad_error_aloft_radar_not_found"
)
Expand All @@ -60,7 +60,7 @@ get_vpts_aloft <- function(

if (!at_least_one_radar_date_combination_exists) {
cli::cli_abort(
"No data found for the requested radar(s) and date(s).",
"Can't find any data for the requested radar(s) and date(s).",
class = "getRad_error_date_not_found"
)
}
Expand All @@ -77,9 +77,8 @@ get_vpts_aloft <- function(

if (!all(radar_odim_code %in% coverage$radar)) {
cli::cli_abort(
"{length(missing_radars)} Radar{?s} not found in {source} coverage:
{glue::backtick(missing_radars)}",
missing_radars = missing_radars,
"Can't find radar{?s} {.val {missing_radars}} in the coverage file (see
{.fun get_vpts_coverage}).",
class = "getRad_error_radar_not_found"
)
}
Expand Down
Loading
Loading