Skip to contents

Check if subset of data is valid (according to 2008/50/CE) for aggregated data, and calculates it.

Usage

check_aggregation_validity(time = time, value = value, aggregation = NULL)

Arguments

time

a date-time or date object of class POSIXct, POSIXlt. This has to be time-ordered otherwise the output values will not match with input parameters.

value

a numeric vector of measured data to be checked.

aggregation

A character vector with the aggregation type. One of "eighthours", "maximumdaily8hour", "24hour", "annual", "o3annual", "monthly" or "semester".

Value

A vector with valid numeric data or NA's if not valid.

Details

Proportion of valid data is generally checked according to table A in Annex XI of the 2008/50/CE directive and table A in Annex VII for Ozone. Other custom checks have been added.

Implemented aggregation requirements are:

  • Eight hours values as eighthours

  • Maximum daily 8 hour values as maximumdaily8hours averages per day)

  • 24-hour values as 24hour: checks for at least 18 valid hours per day;

  • Annual mean as annual

  • Monthly check as monthly: checks for at least the 90% of valid days;

  • Semester check as semester: checks for at least 4 valid months in each semester (winter: Oct to Dec and Jan to Mar; summer: Apr to Sep).

In the case of O3:

  • Annual mean as o3annual.

Examples

# Random data to simulate a PM10 daily values serie
pm10 <- runif(365) * 60
ts <- seq(lubridate::dmy("1/1/2019"), lubridate::dmy("31/12/2019"), by = "1 day")

check_aggregation_validity(time = ts, value = pm10, aggregation = "annual")
#>   [1] 40.9871971 29.3757420  9.5414587 22.5140128 51.7118563 43.8401771
#>   [7] 28.3115593  8.5585245 53.1018286 28.4663372  5.2372810 46.7054241
#>  [13]  0.9764813 59.9089470 57.4620837 38.1004661  8.8087201 28.6505267
#>  [19] 49.6716865 55.0873681 11.2964526 29.4299411 11.7944723 45.8082074
#>  [25]  0.4557974 25.4027971 53.7851294 28.0712732 29.2921124 33.3785940
#>  [31] 40.1415053 27.9561883 37.5666090  1.8992835 36.3231647  8.3850419
#>  [37] 58.8487445 19.3859781 33.7602392 11.8331022 43.4527836 50.6702799
#>  [43] 28.6706339 25.9780316 31.0978480 15.4581200 29.2071460 57.5204733
#>  [49] 14.9333404 15.8888318 24.5803053  9.3152657 18.1058676 54.9773044
#>  [55] 57.5164551 23.2902159 25.8104371 48.9628735  0.9260802 54.7457335
#>  [61] 40.6795329 43.6674078 24.8203910 40.2245143 49.0830609 51.6546344
#>  [67] 14.7736991 15.7642734 43.8578545 27.0423595 40.5002379 10.2905434
#>  [73] 45.2204389  9.6797878 34.8477565  8.0195335 19.4527426 59.3624125
#>  [79]  9.1081268 41.3973272 11.7384505  5.8498977  6.1881660 57.7884152
#>  [85] 46.1675276 30.0021051 57.3706455  3.6408496 15.6576280 17.6358289
#>  [91] 31.8055473  1.0074663 51.6483513 16.9299538 23.6560557 21.3410728
#>  [97]  4.2342400 27.5946140 29.4177564 32.0411387  4.3684829  9.5473173
#> [103] 15.2708722 38.1848670 43.8101007  4.6028683 23.2051572 49.7460988
#> [109] 45.0311900 55.8938297 37.4303003 56.6167164 12.7710985 51.9482517
#> [115] 50.3708580  7.1538568 22.3899204 16.9704485 30.9790006 31.5276682
#> [121] 27.9019399 23.5519911 24.8768019 31.8124480 30.9883148 42.6329285
#> [127] 27.5634370 30.3039580  1.5961405 17.4087495 26.2967693  4.9376247
#> [133] 42.3204690 34.6104286 50.4793376  9.2682165 35.0267334  9.3886709
#> [139]  8.5381936 49.8072624  2.6341833 40.6603074 43.1052635 57.9687513
#> [145]  6.3351715 54.2234504 38.4163441 28.6193598  1.8094397 29.9401660
#> [151] 27.4622550 51.6436245  4.3124637 43.8359105 37.2313104  1.4553040
#> [157] 46.4955842 17.2299720 38.6303488 10.0758246 55.2501814 34.9745965
#> [163] 24.4405235 38.8875750 45.4803827 53.2770859 15.9389332 20.7766774
#> [169] 43.1737817  8.4526032 34.5578973  4.7558701 51.7120998 53.5386459
#> [175]  1.4493234 55.4797981 37.6104814 34.0086527  1.3483469 13.8460713
#> [181] 22.4830299 52.2234875  5.2260390 57.8185695 23.0297691 15.5787243
#> [187] 39.3643768  9.4905274  4.2538992 46.3692995 26.9818248 48.6897493
#> [193] 41.8051287  8.2686870  8.5625068 41.8702640  0.3803864 48.0710441
#> [199]  5.0454341 35.5964969 47.2536995 12.0621435 23.7922516 48.0274349
#> [205] 33.3015566 25.7191934 17.6368687 14.4212168  3.2290371 48.8135573
#> [211]  3.4503906 48.3069333 55.9233520 14.6183795 38.7313478 34.4049634
#> [217] 25.1357231 59.3025131 10.5304481  4.6478599 25.4192879  7.8264939
#> [223] 58.9502404 33.3634019 11.3703498 30.6950221 45.8345502  0.2316486
#> [229] 23.2020358 59.9891197 16.8558434 26.0028739 32.8401413 22.8293667
#> [235] 55.0641594 28.8670518 23.4980896 21.5180600 42.0526953 24.8479217
#> [241] 32.3101464 36.4882303  4.5981976 48.8077126 13.5474418 31.1571474
#> [247] 18.3437070 25.8140312 32.8149878 29.1782170 20.0619092 16.1936233
#> [253] 49.6043004  0.4897488 44.3660176 44.7260176 29.1773164 40.9017052
#> [259]  8.0362663  4.8858278 34.2462741  3.6301728 31.4591187 44.9558890
#> [265] 20.2945163 53.0356205 55.7746764 25.0471114 50.2147534 37.0201821
#> [271] 24.5836391  5.9807051 43.5732671  6.5058646 27.8629688 59.3285217
#> [277] 33.4615494 17.5650928 37.6792074 35.9345698 59.1556899 58.6580958
#> [283] 37.7653383  3.6436466 32.6226810 46.5596092 21.9781888 29.5339568
#> [289] 34.5750366 12.2393170 42.2005489 31.8336633  7.8311944  1.6211799
#> [295] 15.6632010  4.6070972 20.6758240 56.2656632 22.0253347 52.4701257
#> [301] 44.5194186 40.7654180 48.0938534 48.1994548  7.0215895  5.8145151
#> [307] 30.2862600 11.6524178 37.4725112 23.5219492 51.0215167 24.6416125
#> [313] 46.9011107 50.9972590 20.7786327 51.0645417 51.6596618  3.1657856
#> [319] 20.9147340  4.1659195 49.9347125 18.1014379 30.1748153 51.0364934
#> [325] 54.0535519 58.3001820 43.8283921 24.9596786 46.8547891 18.9368851
#> [331] 58.7952799 29.1217318  7.2988116  7.2492586 51.1855359 19.0852402
#> [337]  3.0426799 20.3122270 46.0568575 34.1023918 47.8314485 48.9991482
#> [343] 12.6432152 57.4318375 50.3219104 13.9907906 11.4313163 39.5322423
#> [349] 16.5146217  9.7945113  6.8565746 46.8581358  6.4435319 11.6484653
#> [355] 25.0108219 17.2267772 51.9873274  6.1771755 17.6437214 37.9850103
#> [361]  4.7118901 55.7628751 51.3617959 39.5323560 12.6882954