This function converts between volume and mass concentration by standard conditions. The constants used are equivalent to the one used in AIRMO for sites below 1500m a.s.l:
R = 8.314151 [kg * m2 / (s2 * mol * K)]
T = 20.00 [°C]
p = 1013.00 [hPa]
mol masses:
CO = 28.01 [g / mol]
NO = 30.01 [g / mol]
NO2 = 46.01 [g / mol]
O3 = 48.00 [g / mol]
SO2 = 64.06 [g / mol]
It is possible to change this constants via functions during run time for a session. See convert_set_R()
,
convert_set_mol_masses()
, convert_set_conc_lookup()
Usage
convert_conc(data, parameter, from, to, method = "return", ...)
convert_conc_multiple(data, conversions, method = "return", ...)
Arguments
- data
containing the parameter to convert
- parameter
to convert
- from
start unit
- to
target unit
- method
one of "return", "append", "replace". "return" only returns the converted data, "append" appends the converted data at the end, "replace" replaces the original data for the parameter with the converted
- ...
addional parameters passed to conversion function. see
purrr::partial()
,parts_to_mass()
,mass_to_parts()
- conversions
tibble with columns paramter, from, to. each row is a conversion
Examples
min30 <- system.file("extdata", "Zch_Stampfenbachstrasse_min30_2013_Jan.csv",
package = "rOstluft.data", mustWork = TRUE)
airmo_min30 <- read_airmo_csv(min30)
convert_conc(airmo_min30, "NO", "\u00b5g/m3", "ppb", method = "return")
#> # A tibble: 1,484 × 6
#> starttime site parameter interval unit value
#> <dttm> <fct> <fct> <fct> <fct> <dbl>
#> 1 2013-01-01 00:00:00 Zch_Stampfenbachstrasse NO min30 ppb 63.6
#> 2 2013-01-01 00:30:00 Zch_Stampfenbachstrasse NO min30 ppb 65.6
#> 3 2013-01-01 01:00:00 Zch_Stampfenbachstrasse NO min30 ppb 60.6
#> 4 2013-01-01 01:30:00 Zch_Stampfenbachstrasse NO min30 ppb 65.1
#> 5 2013-01-01 02:00:00 Zch_Stampfenbachstrasse NO min30 ppb 81.1
#> 6 2013-01-01 02:30:00 Zch_Stampfenbachstrasse NO min30 ppb 49.3
#> 7 2013-01-01 03:00:00 Zch_Stampfenbachstrasse NO min30 ppb 51.0
#> 8 2013-01-01 03:30:00 Zch_Stampfenbachstrasse NO min30 ppb 48.9
#> 9 2013-01-01 04:00:00 Zch_Stampfenbachstrasse NO min30 ppb 51.0
#> 10 2013-01-01 04:30:00 Zch_Stampfenbachstrasse NO min30 ppb 56.7
#> # ℹ 1,474 more rows
conversions <- tibble::tribble(
~parameter, ~from, ~to,
"CO", "ppm", "mg/m3",
"NO", "ppb", "\u00b5g/m3",
"O3", "ppb", "\u00b5g/m3",
"NO2", "ppb", "\u00b5g/m3",
"SO2", "ppb", "\u00b5g/m3"
)
min30 <- system.file("extdata", "Zch_Stampfenbachstrasse_min30_2013_Jan.csv",
package = "rOstluft.data", mustWork = TRUE)
airmo_min30 <- read_airmo_csv(min30)
airmo_min30_parts <- dplyr::filter(airmo_min30, .data$unit == "ppb" | .data$unit == "ppm")
convert_conc_multiple(airmo_min30_parts, conversions, method = "return")
#> # A tibble: 7,424 × 6
#> starttime site parameter interval unit value
#> <dttm> <fct> <fct> <fct> <fct> <dbl>
#> 1 2013-01-01 00:00:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.782
#> 2 2013-01-01 00:30:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.828
#> 3 2013-01-01 01:00:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.771
#> 4 2013-01-01 01:30:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.894
#> 5 2013-01-01 02:00:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.966
#> 6 2013-01-01 02:30:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.782
#> 7 2013-01-01 03:00:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.774
#> 8 2013-01-01 03:30:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.736
#> 9 2013-01-01 04:00:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.749
#> 10 2013-01-01 04:30:00 Zch_Stampfenbachstrasse CO min30 mg/m3 0.785
#> # ℹ 7,414 more rows