pycwb.modules.xtalk package¶
Submodules¶
pycwb.modules.xtalk.monster module¶
- pycwb.modules.xtalk.monster.getXTalk(nLayer1, indx1, nLayer2, indx2, layers, xtalk_coeff, xtalk_lookup_table)[source]¶
- pycwb.modules.xtalk.monster.getXTalk_pixels_fast(pixels, check, layers, xtalk_coeff, xtalk_lookup_table)[source]¶
O(N·K_catalog) replacement for getXTalk_pixels_numba.
The original function evaluates all N² pixel pairs to find which ones have non-zero XTalk coefficients. For a cluster with N=52 905 pixels that is ~2.8 billion pair evaluations per pass (two passes total).
This implementation inverts the lookup: for each pixel i (acting as the higher-resolution pixel in the pair) we iterate directly over its catalog entries and resolve the candidate pixel j via a hash map keyed on (nLayer, time). Only truly adjacent pixels — those whose relative time offset appears in the catalog — are evaluated.
Complexity¶
O(N · nRes · K) where K is the average number of catalog entries per (freq, odd) bucket (typically O(BetaOrder) ≈ 6–8 for standard WDM). For N=52 905, nRes=7, K≈6 this is ~2.2 M operations vs ~5.6 B for N².
Column layout of the output
clusterCC(same as getXTalk_pixels_numba)¶col 0 : neighbour pixel index j (float32 cast of int) col 1 : tmpOvlp[0]² + tmpOvlp[1]² col 2 : tmpOvlp[2]² + tmpOvlp[3]² col 3 : col[1] + col[2] col 4 : tmpOvlp[0] (= c1 always) col 5 : tmpOvlp[2] (= c3 no-swap, c2 swap) col 6 : tmpOvlp[1] (= c2 no-swap, c3 swap) col 7 : tmpOvlp[3] (= c4 always)
where (c1, c2, c3, c4) are the raw catalog coefficients and “swap” means getXTalk would have swapped ret[1]↔ret[2] because r_j < r_i.
- pycwb.modules.xtalk.monster.getXTalk_pixels_numba(pixels, check, layers, xtalk_coeff, xtalk_lookup_table)[source]¶
- pycwb.modules.xtalk.monster.load_catalog(fn, dump=True)[source]¶
Load the crosstalk catalog file, if the file is in .npz format, then load the file as npz, otherwise load the bin file and parse it. If parameter dump is True, then save the parsed data into a .npz file with the same name as the input file in current working directory.
- Parameters:
fn (str or Path) – The file name of the crosstalk catalog file
dump (bool) – If True, save the parsed data into a .npz file with the same name as the input file in current working directory
- Returns:
xtalk_coeff (np.ndarray) – The crosstalk coefficients
xtalk_lookup_table (np.ndarray) – The lookup table for crosstalk coefficients
layers (np.ndarray) – The number of layers for each resolution
nRes (int) – The number of resolutions
pycwb.modules.xtalk.type module¶
- class pycwb.modules.xtalk.type.XTalk(coeff: ndarray, lookup_table: ndarray, layers: ndarray, nRes: int)[source]¶
Bases:
objectlookup_table: np.ndarray # shape: (n_layers, n_pixels, n_times), stores lookup indices for crosstalk coefficients
- Variables:
coeff (np.ndarray) – 1D array of arrays, where each element is an array of crosstalk coefficients for a layer.
lookup_table (np.ndarray) – Lookup table for crosstalk.
layers (np.ndarray) – Array of layer indices.
nRes (int) – Number of resolutions; indicates how many distinct resolution levels are present in the crosstalk data.
- get_xtalk(pix1, pix2)[source]¶
Get the crosstalk coefficients for the given pixel pair.
pix1/pix2can bePixelobjects or plain(layers, time)tuples / named objects with those attributes.
- get_xtalk_pixels(pixels, check=True)[source]¶
Get the crosstalk coefficients for the given pixels.
Accepts either a
list[Pixel](legacy) or aPixelArraysinstance. Returns a(cluster_xtalk_lookup, cluster_xtalk)tuple.
- get_xtalk_pixels_from_arrays(layers, times, check=True)[source]¶
Get crosstalk coefficients from
layersandtimearrays.
- classmethod load(fn, dump=True)[source]¶
Load the crosstalk catalog file, if the file is in .npz format, then load the file as npz, otherwise load the bin file and parse it. If parameter dump is True, then save the parsed data into a .npz file with the same name as the input file in current working directory.
- nRes: int¶
pycwb.modules.xtalk.xtalk_data module¶
Module contents¶
pycwb.modules.xtalk — Cross-talk coefficient management.
Manages cross-talk (XTalk) catalogs: loads pre-computed crosstalk coefficient files (binary or .npz) and provides fast Numba-accelerated lookup of crosstalk coefficients for pixel pairs.