This PR fixes #346 plus more. Three key changes are contained within:
When data_type is "annual", "monthly" or "daqi", pollutant and site are now respected. The default behaviour has not changed. This is important if we're trying to make {openair} more accessible to those without R skills (i.e., those who won't be able to filter it after the fact).
library(openair)
importAURN(data_type = "annual")
#> # A tibble: 129 × 38
#> uka_code code site date o3 o3_capture o3.summer_capture
#> <fct> <chr> <chr> <dttm> <dbl> <dbl> <dbl>
#> 1 UKA00399 ABD Aberde… 2009-01-01 00:00:00 42.0 0.944 0.990
#> 2 UKA00513 ABD7 Aberde… 2009-01-01 00:00:00 NA NA NA
#> 3 UKA00451 ACTH Auchen… 2009-01-01 00:00:00 55.5 0.975 0.953
#> 4 UKA00137 AH Aston … 2009-01-01 00:00:00 63.8 0.968 0.976
#> 5 UKA00541 ARM6 Armagh… 2009-01-01 00:00:00 NA NA NA
#> 6 UKA00236 BAR2 Barnsl… 2009-01-01 00:00:00 NA NA NA
#> 7 UKA00353 BAR3 Barnsl… 2009-01-01 00:00:00 43.3 0.969 0.997
#> 8 UKA00306 BATH Bath R… 2009-01-01 00:00:00 NA NA NA
#> 9 UKA00212 BEL2 Belfas… 2009-01-01 00:00:00 37.8 0.936 0.907
#> 10 UKA00238 BEX London… 2009-01-01 00:00:00 NA NA NA
#> # ℹ 119 more rows
#> # ℹ 31 more variables: o3.daily.max.8hour <dbl>, o3.aot40v <int>,
#> # o3.aot40f <int>, somo35 <dbl>, somo35_capture <dbl>, no <dbl>,
#> # no_capture <dbl>, no2 <dbl>, no2_capture <dbl>, nox <dbl>,
#> # nox_capture <dbl>, so2 <dbl>, so2_capture <dbl>, co <dbl>,
#> # co_capture <dbl>, pm10 <dbl>, pm10_capture <dbl>, nv10 <dbl>,
#> # nv10_capture <dbl>, v10 <dbl>, v10_capture <dbl>, pm2.5 <dbl>, …
importAURN(
data_type = "annual",
site = c("my1", "kc1"),
year = 2020,
pollutant = c("no2", "pm2.5"),
)
#> # A tibble: 2 × 8
#> uka_code code site date no2 no2_capture pm2.5 pm2.5_capture
#> <fct> <chr> <chr> <dttm> <dbl> <dbl> <dbl> <dbl>
#> 1 UKA00253 KC1 Lond… 2020-01-01 00:00:00 20.6 0.994 8.05 0.996
#> 2 UKA00315 MY1 Lond… 2020-01-01 00:00:00 43.7 0.968 9.00 0.787
importAURN(
data_type = "annual",
site = c("my1", "kc1"),
year = 2020,
pollutant = c("no2", "pm2.5"),
to_narrow = TRUE
)
#> # A tibble: 4 × 6
#> code site date species value data_capture
#> <chr> <chr> <dttm> <chr> <dbl> <dbl>
#> 1 KC1 London N. Kensington 2020-01-01 00:00:00 no2 20.6 0.994
#> 2 KC1 London N. Kensington 2020-01-01 00:00:00 pm2.5 8.05 0.996
#> 3 MY1 London Marylebone Road 2020-01-01 00:00:00 no2 43.7 0.968
#> 4 MY1 London Marylebone Road 2020-01-01 00:00:00 pm2.5 9.00 0.787
importAQE() and the other devolved networks can now access DAQI statistics. Trev's mentioned they only exist from 2022 for now, but could be back-dated to 2010 in the future.
There was a lot of repetition between importAURN(), importAQE(), importNI(), importWAQN() and importSAQN(), so much of their code has been combined into one helper function. The actual import*() functions are now just wrappers around this internal helper and live in a single R script. The key advantages of this are:
It is easier to update these functions and for them to remain consistent. Indeed, I did this refactor because of how repetitive it was to
importMeta() can import multiple networks at once, so this is a good first step to having an exported importUKAQ() function which can import sites across, e.g., AURN, AQE and LMAM in one go. When that happens, importAURN()et al. can probably be deprecated, and you'd do something like importUKAQ(source = "aurn", site = "my1", year = 2020) or importUKAQ(source = meta$source, site = meta$site, year = 2020).
Notes:
For now, importLocal() is left on its own. This is because, while it is very similar in a lot of ways, it behaves differently under the hood and has fewer stats than the other functions.
importKcl() and importEurope() are also very different and arguably legacy functions so they've been left alone too.
The non-aq import*() functions like importTraj() are untouched.
This PR fixes #346 plus more. Three key changes are contained within:
data_type
is "annual", "monthly" or "daqi",pollutant
andsite
are now respected. The default behaviour has not changed. This is important if we're trying to make{openair}
more accessible to those without R skills (i.e., those who won't be able to filter it after the fact).Created on 2023-05-26 with reprex v2.0.2
importAQE()
and the other devolved networks can now access DAQI statistics. Trev's mentioned they only exist from 2022 for now, but could be back-dated to 2010 in the future.Created on 2023-05-26 with reprex v2.0.2
importAURN()
,importAQE()
,importNI()
,importWAQN()
andimportSAQN()
, so much of their code has been combined into one helper function. The actualimport*()
functions are now just wrappers around this internal helper and live in a single R script. The key advantages of this are:importMeta()
can import multiple networks at once, so this is a good first step to having an exportedimportUKAQ()
function which can import sites across, e.g., AURN, AQE and LMAM in one go. When that happens,importAURN()
et al. can probably be deprecated, and you'd do something likeimportUKAQ(source = "aurn", site = "my1", year = 2020)
orimportUKAQ(source = meta$source, site = meta$site, year = 2020)
.Notes:
importLocal()
is left on its own. This is because, while it is very similar in a lot of ways, it behaves differently under the hood and has fewer stats than the other functions.importKcl()
andimportEurope()
are also very different and arguably legacy functions so they've been left alone too.import*()
functions likeimportTraj()
are untouched.