irfpy.util.span

Module related to span (interval).

Code author: Yoshifumi Futaana

The code depends on sympy package. Version 1.5.1 is recommended (2020-03-27).

irfpy.util.span.array2interval(true_false_array, sorted_array=None)[source]

Two arrays are converted to interval.IntervalSet.

Parameters
  • true_false_array – An array that contains true and false.

  • sorted_array – An array that contains number. Each component should be comparable each other. The array should be sorted from small to large. In case of None, index is used.

>>> tfarr = [False, False, False, True, True, True, True, False, True, True, True]
>>> numarr = [1.5, 2.8, 2.9, 3.5, 3.8, 3.9, 5.1, 5.8, 5.9, 6.1, 6.3]

In the above case, 3.5 (index 3) to 5.1 (index 6) and 5.9 to 6.3 (last 3 elements) is true, so that

>>> intrv = array2interval(tfarr, numarr)
>>> print((3.4 in intrv), (3.5 in intrv))
False True
>>> print((5.1 in intrv), (5.2 in intrv))
True False
>>> print((5.8 in intrv), (5.9 in intrv))
False True
>>> print((6.3 in intrv), (6.4 in intrv))
True False

If only true_false_array is given, the index (3-6 and 8-10) is used.

>>> intrv = array2interval(tfarr)
>>> print((2 in intrv), (3 in intrv))
False True
>>> print((6 in intrv), (7 in intrv))
True False
>>> print((7 in intrv), (8 in intrv))
False True
>>> print((10 in intrv), (11 in intrv))
True False
irfpy.util.span.timearray2interval(true_false_array, time_array)[source]
Parameters
  • true_false_array (list of boolean) – List of “True” or “False”

  • time_array (list of datetime.datetime) – List of datetime.datetime.

Returns

The time interval corresponding to the true_false_array.

Return type

irfpy.util.timeinterval.timeinterval