This function accesses and simplifies the `history' list in a pf_archive-class object.

pf_access_history(archive, bathy = NULL)

Arguments

archive

A pf_archive-class object.

bathy

(optional) A raster that defines the grid across the area over which particle filtering was applied. If unsupplied, this is extracted from archive if available.

Value

The function returns a dataframe that defines, for each time step (`timestep'), particle samples (`cell_id'), associated probabilities (`cell_pr') and, if bathy is available, cell coordinates (`cell_x', `cell_y' and `cell_z').

Details

From the `history' element of a pf_archive-class object, this function extracts particle samples as a dataframe with columns for time steps, cell IDs, cell probabilities and coordinates (if bathy is available).

Author

Edward Lavender

Examples

pf_access_history(dat_dcpf_histories)
#>     timestep cell_id      cell_pr    cell_x    cell_y    cell_z
#> 1          1    2921 1.312336e-04 136.97954 136.97954 136.97954
#> 2          1    3159 2.364016e-04 137.04983 137.04983 137.04983
#> 3          1    3237 1.312336e-04 137.88798 137.88798 137.88798
#> 4          1    3243 2.425569e-04 133.69964 133.69964 133.69964
#> 5          1    3318 1.942855e-04 136.58845 136.58845 136.58845
#> 6          1    3320 2.525012e-04 135.27935 135.27935 135.27935
#> 7          1    3320 2.525012e-04 135.27935 135.27935 135.27935
#> 8          1    3396 3.947544e-05 137.20907 137.20907 137.20907
#> 9          1    3559 9.359471e-05 134.48285 134.48285 134.48285
#> 10         1    3722 1.808832e-05 134.01992 134.01992 134.01992
#> 11         2    3078 1.876176e-04 138.39286 138.39286 138.39286
#> 12         2    3079 1.786695e-04 137.60779 137.60779 137.60779
#> 13         2    3157 2.174004e-04 138.53295 138.53295 138.53295
#> 14         2    3243 1.663445e-05 133.69964 133.69964 133.69964
#> 15         2    3315 2.174004e-04 138.55210 138.55210 138.55210
#> 16         2    3475 1.498497e-04 137.08812 137.08812 137.08812
#> 17         2    3477 1.498497e-04 135.95305 135.95305 135.95305
#> 18         2    3478 1.114181e-04 135.38552 135.38552 135.38552
#> 19         2    3723 2.358249e-04 133.47765 133.47765 133.47765
#> 20         2    3961 3.630254e-05 136.28141 136.28141 136.28141
#> 21         3    3157 2.105803e-04 138.53295 138.53295 138.53295
#> 22         3    3166 1.569277e-04 133.69382 133.69382 133.69382
#> 23         3    3240 1.647869e-04 135.79381 135.79381 135.79381
#> 24         3    3317 1.959173e-04 137.24300 137.24300 137.24300
#> 25         3    3396 2.039494e-04 137.20907 137.20907 137.20907
#> 26         3    3402 1.909455e-04 133.54282 133.54282 133.54282
#> 27         3    3406 4.721224e-05 133.14012 133.14012 133.14012
#> 28         3    3956 4.721224e-05 139.05928 139.05928 139.05928
#> 29         3    3963 1.647869e-04 135.17026 135.17026 135.17026
#> 30         3    3963 1.647869e-04 135.17026 135.17026 135.17026
#> 31         4    3006 1.826367e-04 134.06296 134.06296 134.06296
#> 32         4    3238 1.901244e-04 137.18992 137.18992 137.18992
#> 33         4    3317 1.462901e-04 137.24300 137.24300 137.24300
#> 34         4    3398 1.605168e-04 135.98699 135.98699 135.98699
#> 35         4    3399 1.226931e-04 135.37594 135.37594 135.37594
#> 36         4    3565 1.780020e-04 131.98428 131.98428 131.98428
#> 37         4    3568 2.972360e-05 134.61187 134.61187 134.61187
#> 38         4    3641 7.047349e-05 133.98912 133.98912 133.98912
#> 39         4    3801 1.605168e-04 135.13527 135.13527 135.13527
#> 40         4    3887 9.122633e-05 134.05864 134.05864 134.05864
#> 41         5    2843 1.236215e-04 135.61930 135.61930 135.61930
#> 42         5    3005 1.945485e-04 133.75853 133.75853 133.75853
#> 43         5    3009 1.547789e-04 134.97625 134.97625 134.97625
#> 44         5    3075 1.236215e-04 140.74807 140.74807 140.74807
#> 45         5    3235 1.793489e-04 139.28409 139.28409 139.28409
#> 46         5    3400 1.945485e-04 134.76490 134.76490 134.76490
#> 47         5    3405 1.236215e-04 132.38837 132.38837 132.38837
#> 48         5    3719 9.956193e-05 135.64673 135.64673 135.64673
#> 49         5    3889 1.840187e-04 134.28312 134.28312 134.28312
#> 50         5    3963 7.100674e-05 135.17026 135.17026 135.17026
#> 51         6    3000 1.303164e-04 137.33717 137.33717 137.33717
#> 52         6    3008 2.050845e-04 134.67182 134.67182 134.67182
#> 53         6    3086 2.019373e-04 133.87839 133.87839 133.87839
#> 54         6    3317 1.890617e-04 137.24300 137.24300 137.24300
#> 55         6    3318 4.240359e-05 136.58845 136.58845 136.58845
#> 56         6    3329 1.049538e-04 135.31153 135.31153 135.31153
#> 57         6    3397 7.485220e-05 136.59803 136.59803 136.59803
#> 58         6    3637 1.890617e-04 136.14046 136.14046 136.14046
#> 59         6    3641 1.553795e-04 133.98912 133.98912 133.98912
#> 60         6    3886 1.553795e-04 133.94639 133.94639 133.94639
#> 61         7    2917 2.097557e-04 140.46788 140.46788 140.46788
#> 62         7    2921 2.726068e-04 136.97954 136.97954 136.97954
#> 63         7    3083 5.027690e-06 134.46750 134.46750 134.46750
#> 64         7    3089 2.202607e-04 135.06007 135.06007 135.06007
#> 65         7    3238 1.759216e-04 137.18992 137.18992 137.18992
#> 66         7    3247 2.097557e-04 134.08207 134.08207 134.08207
#> 67         7    3493 1.010473e-04 138.84399 138.84399 138.84399
#> 68         7    3560 2.097557e-04 133.94945 133.94945 133.94945
#> 69         7    3568 2.097557e-04 134.61187 134.61187 134.61187
#> 70         7    3635 2.618707e-04 137.21613 137.21613 137.21613
#> 71         8    3898 1.152372e-05 129.29372 129.29372 129.29372
#> 72         8    3898 1.152372e-05 129.29372 129.29372 129.29372
#> 73         8    3899 4.633050e-06 127.54158 127.54158 127.54158
#> 74         8    3977 9.706081e-06 129.34083 129.34083 129.34083
#> 75         8    3977 9.706081e-06 129.34083 129.34083 129.34083
#> 76         8    3977 9.706081e-06 129.34083 129.34083 129.34083
#> 77         8    3977 9.706081e-06 129.34083 129.34083 129.34083
#> 78         8    3977 9.706081e-06 129.34083 129.34083 129.34083
#> 79         8    3977 9.706081e-06 129.34083 129.34083 129.34083
#> 80         8    3978 4.633050e-06 127.45341 127.45341 127.45341
#> 81         9    4063 7.149016e-05 115.49957 115.49957 115.49957
#> 82         9    4142 2.310167e-04 115.14084 115.14084 115.14084
#> 83         9    4142 4.406128e-04 115.14084 115.14084 115.14084
#> 84         9    4221 2.310167e-04 115.05267 115.05267 115.05267
#> 85         9    4221 2.310167e-04 115.05267 115.05267 115.05267
#> 86         9    4300 2.310167e-04 115.23507 115.23507 115.23507
#> 87         9    4301 9.550208e-05 112.80651 112.80651 112.80651
#> 88         9    4301 1.161212e-04 112.80651 112.80651 112.80651
#> 89         9    4301 1.161212e-04 112.80651 112.80651 112.80651
#> 90         9    4380 5.380996e-05 113.12420 113.12420 113.12420
#> 91        10    4303 1.052208e-03 107.94940 107.94940 107.94940
#> 92        10    4303 1.052208e-03 107.94940 107.94940 107.94940
#> 93        10    4304 5.392584e-04 105.52084 105.52084 105.52084
#> 94        10    4462 8.647521e-04 105.61508 105.61508 105.61508
#> 95        10    4462 1.052208e-03 105.61508 105.61508 105.61508
#> 96        10    4463 7.252655e-04 102.91595 102.91595 102.91595
#> 97        10    4545 2.601637e-04  94.73041  94.73041  94.73041
#> 98        10    4622 2.359938e-04 100.85219 100.85219 100.85219
#> 99        10    4783 6.059906e-05  92.84905  92.84905  92.84905
#> 100       10    4858 1.258733e-05 107.21004 107.21004 107.21004
#> 101       11    4228 2.570111e-04  96.41540  96.41540  96.41540
#> 102       11    4387 5.872840e-04  94.50041  94.50041  94.50041
#> 103       11    4389 4.536843e-04  88.67418  88.67418  88.67418
#> 104       11    4547 2.833335e-04  89.41252  89.41252  89.41252
#> 105       11    4548 2.833335e-04  86.75919  86.75919  86.75919
#> 106       11    4783 2.570111e-04  92.84905  92.84905  92.84905
#> 107       11    4861 9.417657e-04  97.08341  97.08341  97.08341
#> 108       11    4862 2.833335e-04  93.70787  93.70787  93.70787
#> 109       11    4862 1.223956e-03  93.70787  93.70787  93.70787
#> 110       11    4864 7.898565e-04  86.95679  86.95679  86.95679
#> 111       12    4389 1.338321e-03  88.67418  88.67418  88.67418
#> 112       12    4469 1.429464e-03  86.39002  86.39002  86.39002
#> 113       12    4548 1.475939e-03  86.75919  86.75919  86.75919
#> 114       12    4705 1.663311e-04  89.15583  89.15583  89.15583
#> 115       12    4707 6.858919e-04  84.32463  84.32463  84.32463
#> 116       12    4709 5.298601e-04  79.53754  79.53754  79.53754
#> 117       12    4943 1.429464e-03  87.81561  87.81561  87.81561
#> 118       12    5104 9.224773e-04  79.67062  79.67062  79.67062
#> 119       12    5106 9.224773e-04  74.12384  74.12384  74.12384
#> 120       12    5265 1.367964e-04  72.85097  72.85097  72.85097
#> 121       13    4552 9.293680e-04  76.14586  76.14586  76.14586
#> 122       13    4867 1.509693e-03  79.23674  79.23674  79.23674
#> 123       13    4871 1.509693e-03  70.70170  70.70170  70.70170
#> 124       13    4952 8.782483e-05  66.67346  66.67346  66.67346
#> 125       13    5026 1.816027e-03  76.02283  76.02283  76.02283
#> 126       13    5029 1.375888e-03  70.40090  70.40090  70.40090
#> 127       13    5185 1.788159e-03  74.43990  74.43990  74.43990
#> 128       13    5266 1.816027e-03  71.07040  71.07040  71.07040
#> 129       13    5345 1.375888e-03  71.26204  71.26204  71.26204
#> 130       13    5429 6.628176e-04  63.38557  63.38557  63.38557
#> 131       14    4636 1.353681e-03  63.11225  63.11225  63.11225
#> 132       14    4716 6.530796e-04  61.62966  61.62966  61.62966
#> 133       14    4956 5.924068e-04  57.18188  57.18188  57.18188
#> 134       14    5034 2.641320e-03  61.03102  61.03102  61.03102
#> 135       14    5036 1.353681e-03  55.69928  55.69928  55.69928
#> 136       14    5196 6.530796e-04  53.83588  53.83588  53.83588
#> 137       14    5273 1.353681e-03  59.40138  59.40138  59.40138
#> 138       14    5513 1.353681e-03  56.11490  56.11490  56.11490
#> 139       14    5590 2.641320e-03  59.28117  59.28117  59.28117
#> 140       14    5830 5.924068e-04  55.44025  55.44025  55.44025
#> 141       15    4717 4.175310e-03  57.48378  57.48378  57.48378
#> 142       15    4798 3.471003e-03  51.78779  51.78779  51.78779
#> 143       15    4880 1.523914e-03  41.81090  41.81090  41.81090
#> 144       15    4956 4.244902e-03  57.18188  57.18188  57.18188
#> 145       15    4958 2.653108e-03  48.68758  48.68758  48.68758
#> 146       15    5200 9.517100e-04  37.95396  37.95396  37.95396
#> 147       15    5280 1.972672e-03  37.89623  37.89623  37.89623
#> 148       15    5672 3.471003e-03  55.28290  55.28290  55.28290
#> 149       15    5752 3.849103e-03  54.12580  54.12580  54.12580
#> 150       15    6069 3.163367e-03  52.65030  52.65030  52.65030
#> 151       16    4560 3.759398e-03  48.28139  48.28139  48.28139
#> 152       16    4560 4.667874e-03  48.28139  48.28139  48.28139
#> 153       16    4719 7.233304e-03  49.19202  49.19202  49.19202
#> 154       16    4959 7.346035e-03  44.44043  44.44043  44.44043
#> 155       16    5119 3.470716e-03  42.17400  42.17400  42.17400
#> 156       16    5279 3.470716e-03  41.67489  41.67489  41.67489
#> 157       16    5360 1.130838e-03  37.83849  37.83849  37.83849
#> 158       16    5835 4.667874e-03  49.26139  49.26139  49.26139
#> 159       16    6314 1.225586e-04  44.29383  44.29383  44.29383
#> 160       16    6389 3.759398e-03  47.28266  47.28266  47.28266
#> 161       17    4880 9.615385e-03  41.81090  41.81090  41.81090
#> 162       17    5119 1.777196e-02  42.17400  42.17400  42.17400
#> 163       17    5279 1.910206e-02  41.67489  41.67489  41.67489
#> 164       17    5280 1.878890e-02  37.89623  37.89623  37.89623
#> 165       17    5360 1.850057e-02  37.83849  37.83849  37.83849
#> 166       17    5440 1.732096e-02  37.78075  37.78075  37.78075
#> 167       17    5519 1.732096e-02  40.92623  40.92623  40.92623
#> 168       17    6237 2.892335e-03  41.63400  41.63400  41.63400
#> 169       17    6240 1.325318e-03  37.20337  37.20337  37.20337
#> 170       17    6396 1.732096e-02  41.46088  41.46088  41.46088
#> 171       18    5200 2.466742e-02  37.95396  37.95396  37.95396
#> 172       18    5360 2.505186e-02  37.83849  37.83849  37.83849
#> 173       18    5439 2.369594e-02  41.17578  41.17578  41.17578
#> 174       18    5520 2.369594e-02  37.72301  37.72301  37.72301
#> 175       18    5599 2.309462e-02  40.67668  40.67668  40.67668
#> 176       18    6159 2.309462e-02  38.92980  38.92980  38.92980
#> 177       18    6238 2.505186e-02  40.15712  40.15712  40.15712
#> 178       18    6318 2.466742e-02  39.71575  39.71575  39.71575
#> 179       18    6319 2.309462e-02  38.43069  38.43069  38.43069
#> 180       18    6320 2.505186e-02  37.14563  37.14563  37.14563