Skip to contents

Discretizes two angular variables into sectors and estimates joint or conditional mass flows between sectors.

Usage

toroidal_flow_data(
  theta,
  phi,
  n_sectors = 32,
  min_mass = 0.002,
  mass_type = c("joint", "conditional")
)

Arguments

theta

First angle in radians.

phi

Second angle in radians.

n_sectors

Number of sectors for both angles.

min_mass

Minimum mass to retain.

mass_type

Either "joint" for joint masses or "conditional" for masses normalized within each theta sector.

Value

A data frame with sector identifiers, endpoints and mass values.

See also

Examples

dat <- simulate_toroidal(n = 80, seed = 1)
toroidal_flow_data(dat$theta, dat$phi, n_sectors = 12)
#>    theta_sector phi_sector count joint_mass conditional_mass   mass
#> 1             5          6    10     0.1250       0.83333333 0.1250
#> 2             8          8     7     0.0875       1.00000000 0.0875
#> 3             6          7     5     0.0625       0.55555556 0.0625
#> 4            10          7     4     0.0500       0.44444444 0.0500
#> 5            10          8     4     0.0500       0.44444444 0.0500
#> 6            11          9     4     0.0500       0.44444444 0.0500
#> 7             1          2     3     0.0375       0.75000000 0.0375
#> 8             2          3     3     0.0375       0.75000000 0.0375
#> 9             3          4     3     0.0375       0.50000000 0.0375
#> 10            6          8     3     0.0375       0.33333333 0.0375
#> 11           11          8     3     0.0375       0.33333333 0.0375
#> 12            4          4     2     0.0250       0.33333333 0.0250
#> 13            3          5     2     0.0250       0.33333333 0.0250
#> 14            4          5     2     0.0250       0.33333333 0.0250
#> 15            4          6     2     0.0250       0.33333333 0.0250
#> 16            7          7     2     0.0250       0.50000000 0.0250
#> 17            9          7     2     0.0250       0.33333333 0.0250
#> 18            7          8     2     0.0250       0.50000000 0.0250
#> 19            9          8     2     0.0250       0.33333333 0.0250
#> 20           12         11     2     0.0250       0.50000000 0.0250
#> 21            2          2     1     0.0125       0.25000000 0.0125
#> 22            3          3     1     0.0125       0.16666667 0.0125
#> 23            5          5     1     0.0125       0.08333333 0.0125
#> 24            9          6     1     0.0125       0.16666667 0.0125
#> 25           10          6     1     0.0125       0.11111111 0.0125
#> 26            5          7     1     0.0125       0.08333333 0.0125
#> 27           11          7     1     0.0125       0.11111111 0.0125
#> 28            6          9     1     0.0125       0.11111111 0.0125
#> 29            9          9     1     0.0125       0.16666667 0.0125
#> 30           11         10     1     0.0125       0.11111111 0.0125
#> 31           12         10     1     0.0125       0.25000000 0.0125
#> 32            1         12     1     0.0125       0.25000000 0.0125
#> 33           12         12     1     0.0125       0.25000000 0.0125
#>    theta_center phi_center theta_plot   phi_plot  source_y   target_y
#> 1     2.3561945  2.8797933  2.3561945  2.8797933 -3.141593  2.8797933
#> 2     3.9269908  3.9269908 -2.3561945 -2.3561945 -3.141593 -2.3561945
#> 3     2.8797933  3.4033920  2.8797933 -2.8797933 -3.141593 -2.8797933
#> 4     4.9741884  3.4033920 -1.3089969 -2.8797933 -3.141593 -2.8797933
#> 5     4.9741884  3.9269908 -1.3089969 -2.3561945 -3.141593 -2.3561945
#> 6     5.4977871  4.4505896 -0.7853982 -1.8325957 -3.141593 -1.8325957
#> 7     0.2617994  0.7853982  0.2617994  0.7853982 -3.141593  0.7853982
#> 8     0.7853982  1.3089969  0.7853982  1.3089969 -3.141593  1.3089969
#> 9     1.3089969  1.8325957  1.3089969  1.8325957 -3.141593  1.8325957
#> 10    2.8797933  3.9269908  2.8797933 -2.3561945 -3.141593 -2.3561945
#> 11    5.4977871  3.9269908 -0.7853982 -2.3561945 -3.141593 -2.3561945
#> 12    1.8325957  1.8325957  1.8325957  1.8325957 -3.141593  1.8325957
#> 13    1.3089969  2.3561945  1.3089969  2.3561945 -3.141593  2.3561945
#> 14    1.8325957  2.3561945  1.8325957  2.3561945 -3.141593  2.3561945
#> 15    1.8325957  2.8797933  1.8325957  2.8797933 -3.141593  2.8797933
#> 16    3.4033920  3.4033920 -2.8797933 -2.8797933 -3.141593 -2.8797933
#> 17    4.4505896  3.4033920 -1.8325957 -2.8797933 -3.141593 -2.8797933
#> 18    3.4033920  3.9269908 -2.8797933 -2.3561945 -3.141593 -2.3561945
#> 19    4.4505896  3.9269908 -1.8325957 -2.3561945 -3.141593 -2.3561945
#> 20    6.0213859  5.4977871 -0.2617994 -0.7853982 -3.141593 -0.7853982
#> 21    0.7853982  0.7853982  0.7853982  0.7853982 -3.141593  0.7853982
#> 22    1.3089969  1.3089969  1.3089969  1.3089969 -3.141593  1.3089969
#> 23    2.3561945  2.3561945  2.3561945  2.3561945 -3.141593  2.3561945
#> 24    4.4505896  2.8797933 -1.8325957  2.8797933 -3.141593  2.8797933
#> 25    4.9741884  2.8797933 -1.3089969  2.8797933 -3.141593  2.8797933
#> 26    2.3561945  3.4033920  2.3561945 -2.8797933 -3.141593 -2.8797933
#> 27    5.4977871  3.4033920 -0.7853982 -2.8797933 -3.141593 -2.8797933
#> 28    2.8797933  4.4505896  2.8797933 -1.8325957 -3.141593 -1.8325957
#> 29    4.4505896  4.4505896 -1.8325957 -1.8325957 -3.141593 -1.8325957
#> 30    5.4977871  4.9741884 -0.7853982 -1.3089969 -3.141593 -1.3089969
#> 31    6.0213859  4.9741884 -0.2617994 -1.3089969 -3.141593 -1.3089969
#> 32    0.2617994  6.0213859  0.2617994 -0.2617994 -3.141593 -0.2617994
#> 33    6.0213859  6.0213859 -0.2617994 -0.2617994 -3.141593 -0.2617994
#>            x0         y0         x1         y1
#> 1  -0.7071068  0.7071068 -0.5602370  0.1501150
#> 2  -0.7071068 -0.7071068 -0.4101219 -0.4101219
#> 3  -0.9659258  0.2588190 -0.5602370 -0.1501150
#> 4   0.2588190 -0.9659258 -0.5602370 -0.1501150
#> 5   0.2588190 -0.9659258 -0.4101219 -0.4101219
#> 6   0.7071068 -0.7071068 -0.1501150 -0.5602370
#> 7   0.9659258  0.2588190  0.4101219  0.4101219
#> 8   0.7071068  0.7071068  0.1501150  0.5602370
#> 9   0.2588190  0.9659258 -0.1501150  0.5602370
#> 10 -0.9659258  0.2588190 -0.4101219 -0.4101219
#> 11  0.7071068 -0.7071068 -0.4101219 -0.4101219
#> 12 -0.2588190  0.9659258 -0.1501150  0.5602370
#> 13  0.2588190  0.9659258 -0.4101219  0.4101219
#> 14 -0.2588190  0.9659258 -0.4101219  0.4101219
#> 15 -0.2588190  0.9659258 -0.5602370  0.1501150
#> 16 -0.9659258 -0.2588190 -0.5602370 -0.1501150
#> 17 -0.2588190 -0.9659258 -0.5602370 -0.1501150
#> 18 -0.9659258 -0.2588190 -0.4101219 -0.4101219
#> 19 -0.2588190 -0.9659258 -0.4101219 -0.4101219
#> 20  0.9659258 -0.2588190  0.4101219 -0.4101219
#> 21  0.7071068  0.7071068  0.4101219  0.4101219
#> 22  0.2588190  0.9659258  0.1501150  0.5602370
#> 23 -0.7071068  0.7071068 -0.4101219  0.4101219
#> 24 -0.2588190 -0.9659258 -0.5602370  0.1501150
#> 25  0.2588190 -0.9659258 -0.5602370  0.1501150
#> 26 -0.7071068  0.7071068 -0.5602370 -0.1501150
#> 27  0.7071068 -0.7071068 -0.5602370 -0.1501150
#> 28 -0.9659258  0.2588190 -0.1501150 -0.5602370
#> 29 -0.2588190 -0.9659258 -0.1501150 -0.5602370
#> 30  0.7071068 -0.7071068  0.1501150 -0.5602370
#> 31  0.9659258 -0.2588190  0.1501150 -0.5602370
#> 32  0.9659258  0.2588190  0.5602370 -0.1501150
#> 33  0.9659258 -0.2588190  0.5602370 -0.1501150