pitchscapes.util.coords_from_times

pitchscapes.util.coords_from_times(times, start_end_idx=False, start_end_time=False, center_width=False, coords=False, remove_offset=True, unit_times=True)[source]
Generate various coordinate information from a given list of times. Given N points in time, the returned arrays will
contain N(N-1)/2 items, corresponding to all ordered non-zero time intervals. The ordering corresponds constructing

a list by iterating over start points in the outer loop and end points in the inner loop.

Parameters:
  • times – An iterable of N points in time (has to be ordered).

  • start_end_idx – (default False) Whether to return an array of shape Nx2 with integer (start_idx, end_idx)

pairs. :type start_end_time: :param start_end_time: (default False) Whether to return an array of shape Nx2 with (start_time, end_time) pairs according to the values in times. :type center_width: :param center_width: (default False) Whether to return an array of shape Nx2 with (center, width) time coordinate, related to (start_time, end_time) via start_end_to_center_width. :type coords: :param coords: (default False) Whether to return an array of shape Nx4x2 with four points in center-width coordinates, describing the rhomboid region in a scape plot that corresponds to the respective time interval. The top-point of the rhombus corresponds to the respective center_width coordinate, the other three points are obtained by moving the start and/or end point one time step forward and/or backward, respectively. The coordinates are ordered clock-wise starting at 9 (left, top, right, bottom), corresponding to the indices [(start, end - 1), (start, end), (start + 1, end), (start + 1, end - 1)]. For the bottom row of a scape plot (adjacent points in time), the last (bottom) coordinate will be a pair of np.nan. :type remove_offset: :param remove_offset: (default True) Whether the minimum time is subtracted to have time start at zero. :type unit_times: :param unit_times: (default True) Whether to normalise times to be in [0, 1]. :return: If only one of [start_end_idx, start_end_time, center_width, coords] is true, return the corresponding array, otherwise return a tuple of the requested arrays (in this order).