Skip to content

fix(data.atmosphere): use .data$sitename in download_NOAA_GEFS_EFI filter#3992

Open
anshul23102 wants to merge 1 commit into
PecanProject:developfrom
anshul23102:fix/noaa-gefs-sitename-filter
Open

fix(data.atmosphere): use .data$sitename in download_NOAA_GEFS_EFI filter#3992
anshul23102 wants to merge 1 commit into
PecanProject:developfrom
anshul23102:fix/noaa-gefs-sitename-filter

Conversation

@anshul23102
Copy link
Copy Markdown
Contributor

Bug

download_NOAA_GEFS_EFI filters the downloaded met tibble to the requested NEON site with:

dplyr::filter(.data$reference_datetime == ..., sitename == sitename)

sitename == sitename compares the function argument to itself, which is always TRUE. The site filter has no effect, so the function returns met data for every NEON site merged together instead of only the requested one. Any model run using this function receives mixed multi-site meteorology.

Fix

# Before
dplyr::filter(.data$reference_datetime == as.POSIXct(start_date, tz = "UTC"), sitename == sitename)

# After
dplyr::filter(.data$reference_datetime == as.POSIXct(start_date, tz = "UTC"), .data$sitename == sitename)

Adding the .data$ prefix makes dplyr compare the sitename column against the sitename argument, as intended.

The dplyr::filter() call used `sitename == sitename`, comparing the
function argument to itself. This is always TRUE, so the filter had no
effect and returned met data for every NEON site instead of only the
requested one. Any downstream model run using this function received
mixed multi-site meteorology.

Fix: use `.data$sitename == sitename` to compare the column against the
argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant