pyssaBSS.spatial

Functions

generate_coordinates(num_data_points[, hi])

Generates uniformly random 2-D coordinates from [0, hi) x [0, hi)

generate_spatial_data(covariance_matrix[, mean])

Generate spatial data from covariance matrix using the Cholesky decomposition.

is_in_rectangle_mask(points, corner, height, ...)

Vectorized check of which points are contains in the box outlined by corner, height, and width

matern_covariance(points[, nu, phi])

Computes the covariance matrix of a set of points using sklearn Matern kernel.

params_to_block_vector(params, segments)

Computes a vector where the indices of segments[i] has the value params[i]

partition_coordinates(coordinates, ...[, ...])

Grid partition of coordinates.

partition_points_by_polygons(points, polygons)

Partition of coordinates based on the first polygon which contains them.

points_in_polygon(points, polygon)

Vectorized check of which points are contained in the given polygon

spatial_data_from_cholesky(cholesky)

Spatial data via the Cholesky method.

ssa_matern_covariance(points[, nu, phi, sigma])

Computes the usual Matern covariance matrix of a set of points using sklearn Matern kernel.

pyssaBSS.spatial.generate_coordinates(num_data_points, hi=1.0)[source]

Generates uniformly random 2-D coordinates from [0, hi) x [0, hi)

Parameters:
  • num_data_points (int) – Number of data points to generate

  • hi (float) – Upper bound for the sampling area.

Returns:

coordinate

Return type:

ndarray of shape (num_data_points, 2)

pyssaBSS.spatial.generate_spatial_data(covariance_matrix, mean=None)[source]

Generate spatial data from covariance matrix using the Cholesky decomposition.

Parameters:
  • covariance_matrix (ndarray of shape (n, n)) – a positive-semidefinite covariance matrix (must be cholesky decomposable)

  • mean (ndarray of shape (n, 1), optional)

Returns:

spatial_data – spatial data with mean ‘mean’ and covariance ‘covariance_matrix’

Return type:

ndarray of shape (n, 1)

pyssaBSS.spatial.is_in_rectangle_mask(points, corner, height, width)[source]

Vectorized check of which points are contains in the box outlined by corner, height, and width

Parameters:
  • points (ndarray of shape (n, 2))

  • corner (tuple(float, float)) – indicates the bottom left corner of a rectangle

  • height (float) – indicates the height of the rectangle

  • width (float) – indicates the width of the rectangle

Returns:

mask

Return type:

ndarray of booleans of shape (num_data_points, 2)

pyssaBSS.spatial.matern_covariance(points, nu=1.5, phi=1.0)[source]

Computes the covariance matrix of a set of points using sklearn Matern kernel. This differs from the usual Matern Kernel by a constant.

Parameters:
  • points (ndarray of shape (n, 2))

  • nu (float) – smoothness parameter

  • phi (float) – range parameter

Returns:

mat – spatial covariance matrix

Return type:

ndarray of shape (n, n)

pyssaBSS.spatial.params_to_block_vector(params, segments)[source]

Computes a vector where the indices of segments[i] has the value params[i]

Parameters:
  • params (list of values)

  • segments (list of list of indices)

Returns:

result

Return type:

ndarray of shape (n, 1)

pyssaBSS.spatial.partition_coordinates(coordinates, num_x_segments, num_y_segments, side_length=1.0)[source]

Grid partition of coordinates. Coordinates lying in a box [0, side_length) x [0, side_lenght) are partitioned by a grid given by the number of of cuts in x and y direnctions

Parameters:
  • coordinates (ndarray of shape (n, 2)) – spatial coordinates in [0, side_length) x [0, side_lenght)

  • num_x_segments (int) – number of cuts on along the x-axis

  • num_y_segments (int) – number of cuts on along the y-axis

  • side_length (float) – Length of the sides of the bounding square

Returns:

partition – A list of lists of indices. Each list is a part. Each part is a list of indices of coordinates lying inside that rectangle.

Return type:

list(list(int))

pyssaBSS.spatial.partition_points_by_polygons(points, polygons)[source]

Partition of coordinates based on the first polygon which contains them.

Parameters:
  • coordinates (ndarray of shape (n, 2))

  • polygons (list of ndarrays of shape (num_vertices, 2))

Returns:

  • partition (list(list(int))) – A list of lists of indices. Each list is a part. Each part is a list of indices of coordinates lying inside that rectangle.

  • unassigned (list(int)) – list of coordinates that were in no polygon

pyssaBSS.spatial.points_in_polygon(points, polygon)[source]

Vectorized check of which points are contained in the given polygon

Parameters:
  • points (ndarray of shape (n, 2))

  • polygon (ndarray of shape (p, 2)) – a polygon is represented by the coordinates of its vertices in a fixed order

Returns:

mask

Return type:

ndarray of booleans of shape (num_data_points, 2)

pyssaBSS.spatial.spatial_data_from_cholesky(cholesky)[source]

Spatial data via the Cholesky method.

Parameters:

cholesky (ndarray of shape (n, n))

Returns:

spatial_data – zero-mean spatial data with covariance L^T L

Return type:

ndarray of shape (n, 1)

pyssaBSS.spatial.ssa_matern_covariance(points, nu=0.5, phi=1.0, sigma=1.0)[source]

Computes the usual Matern covariance matrix of a set of points using sklearn Matern kernel.

Parameters:
  • points (ndarray of shape (n, 2))

  • nu (float) – smoothness parameter

  • phi (float) – range parameter

  • sigma (float) – variance parameter

Returns:

mat – spatial covariance matrix

Return type:

ndarray of shape (n, n)