partition

Map and point partitioning related functions.

skysegmentor.get_partition_IDs(partition)[source]

Returns the total weights of each partition.

Parameters:

partition (array) – Partition IDs on a map. Unfilled partitions are assigned partition 0.

Returns:

partition_IDs – Unique partition IDs, including zero.

Return type:

array

skysegmentor.total_partition_weights(partition, weights)[source]

Returns the total weights of each partition.

Parameters:
  • partition (array) – Partition IDs on a map. Unfilled partitions are assigned partition 0.

  • weights (array) – A weight assigned to each element of the partition array.

Returns:

  • partition_IDs (array) – Unique partition IDs, including zero.

  • partition_weights (array) – The total weight for each partition.

skysegmentor.remove_val4array(array, val)[source]

Removes a given value from an array.

Parameters:
  • array (array) – Data vector.

  • val (float) – Value to be removed from an array.

skysegmentor.fill_map(pixID, nside, val=1.0)[source]

Fill a Healpix map with a given value val at given pixel locations.

Parameters:
  • pixID (int array) – Pixel index.

  • nside (int) – HEalpix map nside.

  • val (float, optional) – Value to fill certain pixels with.

skysegmentor.find_map_barycenter(bnmap, wmap=None)[source]

Determines the barycenter of center of mass direction of the input binary map.

Parameters:
  • bnmap (array) – binary map.

  • wmap (array, optional) – The weights.

Returns:

phic, thec – The center

Return type:

float

skysegmentor.find_points_barycenter(phi, the, weights=None)[source]

Determines the barycenter of center of mass direction of the input point dataset.

Parameters:
  • phi (array) – Angular coordinates.

  • the (array) – Angular coordinates.

  • weights (array, optional) – Weights for points.

Returns:

phic, thec – The center

Return type:

float

skysegmentor.get_map_border(bnmap, wmap=None, res=[200, 100])[source]

Determines the outer border of binary map region.

Parameters:
  • bnmap (array) – binary map.

  • wmap (array, optional) – The weights.

  • res (list, optional) – Resolution of spherical cap grid where [phiresolution, thetaresolution] to find region border.

Returns:

phi_border, the_border – Approximate border region.

Return type:

array

skysegmentor.get_points_border(phi, the, weights=None, res=100)[source]

Determines the outer border of binary map region.

Parameters:
  • phi (array) – Angular coordinates.

  • the (array) – Angular coordinates.

  • weights (array, optional) – Weights for points.

  • res (int, optional) – Resolution of spherical cap grid for phiresolution to find region border.

Returns:

phi_border, the_border – Approximate border region.

Return type:

array

skysegmentor.get_map_most_dist_points(bnmap, wmap=None, res=[100, 50])[source]

Returns the most distant points on a binary map.

Parameters:
  • bnmap (int array) – Binary healpix map.

  • wmap (array, optional) – The weights.

  • res (list, optional) – Resolution of spherical cap grid where [phiresolution, thetaresolution] to find region border.

Returns:

p1, t1, p2, t2 – Angular coordinates (phi, theta) for the most distant points (1 and 2) on the binary map.

Return type:

float

skysegmentor.get_points_most_dist_points(phi, the, weights=None, res=100)[source]

Returns the most distant points from a set of points.

Parameters:
  • phi (array) – Angular coordinates.

  • the (array) – Angular coordinates.

  • weights (array, optional) – Weights for points.

  • res (int, optional) – Resolution of spherical cap grid for phiresolution to find region border.

Returns:

p1, t1, p2, t2 – Angular coordinates (phi, theta) for the most distant points (1 and 2) on the binary map.

Return type:

float

skysegmentor.weight_dif(phi_split, phi, weights, balance=1)[source]

Compute the difference between the weights on either side of phi_split.

Parameters:
  • phi_split (float) – Longitude split.

  • phi (array) – Longitude coordinates.

  • weights (array) – Weights corresponding to each longitude coordinates.

  • balance (float, optional) – A multiplication factor assigned to weights below phi_split.

skysegmentor.find_dphi(phi, weights, balance=1)[source]

Determines the splitting longitude required for partitioning, either with 1-to-1 weights on either side or unbalanced weighting if balance != 1.

Parameters:
  • phi (array) – Longitude coordinates.

  • weights (array) – Weights corresponding to each longitude coordinates.

Returns:

dphi – Splitting longitude.

Return type:

float

skysegmentor.segmentmap2(weightmap, balance=1, partitionmap=None, partition=None, res=[100, 50])[source]

Segment a map with weights into 2 equal (unequal in balance != 1).

Parameters:
  • weightmap (array) – Healpix weight map.

  • balance (float, optional) – Balance of the weights for the partitioning.

  • partitionmap (int array, optional) – Partitioned map IDs.

  • partition (int, optional) – A singular partition to be partitioned in two pieces.

  • res (list, optional) – Resolution of spherical cap grid where [phiresolution, thetaresolution] to find region border.

Returns:

partitionmap – Partitioned map IDs.

Return type:

int array

skysegmentor.segmentpoints2(phi, the, weights=None, balance=1, partitionID=None, partition=None, res=100)[source]

Segments a set of points with weights into 2 equal (unequal in balance != 1).

Parameters:
  • phi (array) – Angular positions.

  • the (array) – Angular positions.

  • weights (array, optional) – Angular position weights.

  • balance (float, optional) – Balance of the weights for the partitioning.

  • partitionID (int array, optional) – Partitioned map IDs.

  • partition (int, optional) – A singular partition to be partitioned in two pieces.

  • res (float, optional) – Resolution of spherical cap phiresolution to find region border.

Returns:

partitionID – Partitioned map IDs.

Return type:

int array

skysegmentor.segmentmapN(weightmap, Npartitions, res=[100, 50])[source]

Segment a map with weights into equal Npartition sides.

Parameters:
  • weightmap (array) – Healpix weight map.

  • Npartitions (int) – Number of partitioned regions

  • res (list, optional) – Resolution of spherical cap grid where [phiresolution, thetaresolution] to find region border.

Returns:

partitionmap – Partitioned map IDs.

Return type:

int array

skysegmentor.segmentpointsN(phi, the, Npartitions, weights=None, res=100)[source]

Segments a set of points with weights into equal Npartition sides.

Parameters:
  • weightmap (array) – Healpix weight map.

  • Npartitions (int) – Number of partitioned regions

  • res (list, optional) – Resolution of spherical cap grid where [phiresolution, thetaresolution] to find region border.

Returns:

partitionmap – Partitioned map IDs.

Return type:

int array