hpmcm.utils module

hpmcm.utils.associateSourcesToFootprints(data, cluster_key, pixel_match_scale=1)[source]

Loop through data and associate sources to clusters

Return type:

list[ndarray]

Parameters:
  • data (list[DataFrame]) – Input DataFrames

  • cluster_key (ndarray) – 2D-map of cluster Ids by pixel position

  • pixel_match_scale (int) – Scale-factor used in making cluster map

Returns:

  • Lists of clusters associated to each source

  • output[i][j] will give the id of the cluster associated

  • to source j in input catalog i.

hpmcm.utils.fillCountsMapFromArrays(x_locals, y_locals, n_pix, weights=None)[source]

Fill a source counts map

Return type:

ndarray

Parameters:
  • x_locals (ndarray) – Local pixel x-positions

  • y_locals (ndarray) – Local pixel y-positions

  • n_pix (ndarray) – Number of pixels in x,y for counts map

  • weights (ndarray | None) – If provided, weights to apply for each entry in counts map

Return type:

Counts map of source in cell, projected into n_pix,n_pix grid

hpmcm.utils.fillCountsMapFromDf(df, n_pix, weight_name=None, pixel_match_scale=1)[source]

Fill a source counts map from a reduced dataframe for one input catalog

Return type:

ndarray

Parameters:
  • df (DataFrame) – DataFrame with local pixel positions (x_cell, y_cell)

  • n_pix (ndarray) – Number of pixels in x,y for counts map

  • weight_name (str | None) – If provided column to use for weights

  • pixel_match_scale (int) – Scale-factor to use in making cluster map

Return type:

Counts map of source in cell, projected into n_pix,n_pix grid

hpmcm.utils.findClusterIds(df, cluster_key, pixel_match_scale=1)[source]

Associate sources to clusters using clusterkey which is a map where any pixel associated to a cluster has the cluster index as its value

Return type:

ndarray

Parameters:
  • df (DataFrame) – DataFrame with local pixel positions (x_cell, y_cell)

  • cluster_key (ndarray) – 2D-map of cluster Ids by pixel position

  • pixel_match_scale (int) – Scale-factor to use in making cluster map

Return type:

Ids of associated clusters

hpmcm.utils.findClusterIdsFromArrays(x_locals, y_locals, cluster_key)[source]

Associate sources to clusters using clusterkey which is a map where any pixel associated to a cluster has the cluster index as its value

Return type:

ndarray

Parameters:
  • x_locals (ndarray) – Local pixel x-positions

  • y_locals (ndarray) – Local pixel y-positions

  • cluster_key (ndarray) – 2D-map of cluster Ids by pixel position

Return type:

Ids of associated clusters

hpmcm.utils.getFootprints(counts_map, buf, pixel_match_scale=1)[source]

Take a source counts map and do clustering using Footprint detection

Return type:

dict

Parameters:
  • counts_map (ndarray) – Map of source counts

  • buf (int) – Number of pixels in cell-edge buffer

  • pixel_match_scale (int) – Scale-factor used in making cluster map

Returns:

  • Footprint data

  • +—————+——————+———————————+

  • | Key | Type | Description |

  • +===============+==================+=================================+

  • | image | np.ndarray | Counts map of sources |

  • +—————+——————+———————————+

  • | footprints | FootprintSet | Clustering footprints |

  • +—————+——————+———————————+

  • | footprint_key | np.ndarray | Array with cluster associations |

  • +—————+——————+———————————+

hpmcm.utils.reduceObjectTable(basefile, outfile, extra_cols=None)[source]

Reduce an object table to just the colums needed for matching

Return type:

None

Parameters:
  • basefile (str) – Original file name

  • outfile (str) – Output file name

  • extra_cols (list[str] | None) – Extra columns to copy

Notes

This will produce a DataFrame with at least these columns:

Column name

Description

id

source ID

tract

Tract source was found in

patch

Patch source was found in

ra

RA in degrees

dec

DEC in degress

snr

Signal-to-Noise of source, used for filtering and centroiding

{band}_gaapPsfFlux

Flux, for band in u,g,r,i,z,y

{band}_gaapPsfFluxErr

Flux error, for band in u,g,r,i,z,y