luv_finder.data¶
Measurement-set I/O and visibility-domain operations.
Visibilities are held per (field, spectral window) in a Chunk: the weighted
visibilities X = w * V and the weight of every visibility w (0 where flagged) as
(n_chan, n_row) arrays, and what is constant along an axis (u, v, time, baseline and
scan per row, frequency per channel) once. The weights are corrected on reading, per scan and
channel, by the noise measured in the data (reweighted()).
Positions are offsets in one sky frame per dataset: arcsec east and north of
Metadata.ref, the model’s (dra, ddec) convention. Each chunk carries its field’s phase
centre in that frame, so the same (dra, ddec) means the same sky position in every pointing.
CASA (casatools) is imported lazily inside the functions that read a measurement set, so
the NPZ path (DataHandler.from_npz()) works in an environment without CASA.
Module Attributes
Arrays stored per chunk in an NPZ, under |
|
Target size of one block of rows read from a measurement set, in visibility-channels. |
|
Largest time between two integrations of a baseline that measure the weights' noise together, s. |
|
Channels handled at once when the weights are measured. |
|
Longest channel lag |
|
Longest channel lag |
|
casacore's MFrequency reference codes ( |
Functions
|
Of one window's jackknife ( |
|
Warn unless every window is in LSRK: the search, the catalogue and the fit keep the MS's frame. |
|
Target fields of a measurement set, an NPZ or a list of NPZs, sorted; an NPZ is not read beyond its index. |
|
Read target visibilities one spw at a time over all |
|
The visibilities of |
|
Inverse variance of |
|
A field's dataset metadata, phase centre (arcsec, the data's sky frame) and lowest frequency (Hz), from a measurement set, an NPZ or a list of NPZs, without reading its visibilities. |
|
The chunks of one window, weights divided by |
|
(RA, Dec) in rad of the (east, north) |
|
(east, north) offset in arcsec of |
|
Average the parallel hands |
|
Field and spectral-window ids observed with the target intent. |
|
|
|
Write an NPZ one array at a time, so |
Classes
|
Noise of each channel over its weights, |
|
Visibilities of one (field, spectral window), channel-major. |
|
Visibilities of a measurement set, one |
|
Quantities of the whole dataset, the same whichever fields or windows are loaded. |
|
Noise power over the weights per scan and channel, |
- luv_finder.data.CHANNEL_BLOCK = 16¶
Channels handled at once when the weights are measured.
- luv_finder.data.CHUNK_ARRAYS = ('offset', 'freq', 'u', 'v', 'time', 'baseline', 'scan', 'X', 'w')¶
Arrays stored per chunk in an NPZ, under
{field}_{spw}_{name}.
- class luv_finder.data.ChannelNoise(scale: np.ndarray, rho: np.ndarray)[source]¶
Noise of each channel over its weights,
scale(1 where they hold), and between channels,rho.
- class luv_finder.data.Chunk(field: int, spw: int, offset: ndarray, freq: ndarray, u: ndarray, v: ndarray, time: ndarray, baseline: ndarray, scan: ndarray, X: ndarray, w: ndarray)[source]¶
Visibilities of one (field, spectral window), channel-major.
X = w * Vis zero wherewis (flagged), so a weighted sum over visibilities is a plain sum overX.- Attributes:
- offset(2,) arcsec, the field’s phase centre in the dataset’s sky frame
- freq(n_chan,) Hz, ascending
- u, v(n_row,) m
- time(n_row,) s
- baseline(n_row,) int, identifies the antenna pair
- scan(n_row,) int64, the scan,
OBSERVATION_ID << 32 | SCAN_NUMBER - X(n_chan, n_row) complex, weighted visibilities
- w(n_chan, n_row) float32, inverse variance of each visibility, 0 where flagged
- binned(n: int, rho=None) tuple[Chunk, ndarray][source]¶
The channels averaged in runs of
n(the last shorter unlessndivides them) and the binned channels’ correlation.Xandwadd, an inverse-variance average at each run’s mean frequency. Under the channels’ correlationrho((1, rho_1, ...)) a run’s variance issum_kl rho_|k-l|times the independent one: the weights are divided by it, and neighbouring runs correlate by therhospanning them.
- jackknife() Chunk[source]¶
A signal-free noise realisation: consecutive integrations of every baseline differenced and halved.
Each baseline’s integrations are paired in time order, its first with its second, third with fourth, …, whatever the other baselines do, so a mosaic field seen once per visit (or a baseline missing from some integrations) still pairs nearly every row; an odd last integration is left out. A signal constant over a pair cancels; the noise stays, with weight
pair_weight(2w for equal weights).The split is by integration, never random: a random sign flip of individual visibilities destroys the baseline structure and does not give the observation’s white-noise level.
- phase(dra: float, ddec: float) ndarray[source]¶
exp(-2 pi i (u dra + v ddec)): moves the phase centre to (dra, ddec) arcsec in the sky frame.
- class luv_finder.data.DataHandler(msfile: str | None = None, chunks: list[Chunk] | None = None, metadata: Metadata | None = None, fields=None, reweight: bool = True)[source]¶
Visibilities of a measurement set, one
Chunkper (field, spectral window).- Parameters:
- msfilestr, optional
Measurement set to read;
fieldsselects a subset of its target fields, andreweight=Falsekeeps its weights (a noiseless simulation; seeiter_chunks()).- chunks, metadataoptional
Ready-made data, e.g. from
from_npz()or a test.
- channel_noise(jackknife: DataHandler | None = None) dict[int, ChannelNoise][source]¶
channel_noise()per spectral window, pooled over its fields:{spw: ChannelNoise}; onjackknifeif already made (default:jackknife(), a chunk at a time).
- classmethod from_npz(path: str, fields=None) DataHandler[source]¶
Load an NPZ written by
to_npz()orluv-export;fieldsloads only those.
- jackknife() DataHandler[source]¶
Signal-free noise realisation of every chunk (see
Chunk.jackknife()).
- luv_finder.data.FREQUENCY_FRAMES = ('REST', 'LSRK', 'LSRD', 'BARY', 'GEO', 'TOPO', 'GALACTO', 'LGROUP', 'CMB')¶
casacore’s MFrequency reference codes (
MEAS_FREQ_REFof an MS’s SPECTRAL_WINDOW).
- luv_finder.data.LAG_SIGNIFICANCE = 5.0¶
Longest channel lag
channel_noise()measures, and the significance a lag’s correlation needs to count.
- luv_finder.data.MAX_GAP = 450.0¶
Largest time between two integrations of a baseline that measure the weights’ noise together, s.
- luv_finder.data.MAX_LAG = 8¶
Longest channel lag
channel_noise()measures, and the significance a lag’s correlation needs to count.
- class luv_finder.data.Metadata(dish_diameter: float, ref: tuple[float, float], central_frequency: float, max_uvwave: float)[source]¶
Quantities of the whole dataset, the same whichever fields or windows are loaded.
- Attributes:
- dish_diameterm
- ref(RA, Dec) in rad that sky offsets are measured from (the first target field)
- central_frequencyHz
- max_uvwavelongest baseline in wavelengths
- luv_finder.data.READ_BLOCK = 25000000¶
Target size of one block of rows read from a measurement set, in visibility-channels.
- class luv_finder.data.WeightScale(scans: np.ndarray, scale: np.ndarray, check: np.ndarray, error: np.ndarray)[source]¶
Noise power over the weights per scan and channel,
scale, its robustcheckand that one’serror.
- luv_finder.data.channel_noise(jackknife: Iterable[Chunk]) ChannelNoise[source]¶
Of one window’s jackknife (
Chunk.jackknife()): the noise power per channel over the weights,sum |X|^2 / 2 sum w, and the channels’ correlation(1, rho_1, ...)up to the first lag consistent with 0.
- luv_finder.data.check_frame(msfile: str, codes) None[source]¶
Warn unless every window is in LSRK: the search, the catalogue and the fit keep the MS’s frame.
- luv_finder.data.fields_in(path) list[int][source]¶
Target fields of a measurement set, an NPZ or a list of NPZs, sorted; an NPZ is not read beyond its index.
- luv_finder.data.iter_chunks(msfile: str, ref, fields=None, spws=None, reweight: bool = True, scales: dict | None = None) Iterator[Chunk][source]¶
Read target visibilities one spw at a time over all
fields, weights corrected, offsets fromref.Autocorrelations, flagged rows and rows with no unflagged channel are dropped. Every window’s weights are divided by the noise measured in it (
weight_scale()), so the peak memory is one window over all its fields;reweight=Falsekeeps the measurement set’s weights, for a noiseless simulation, which has no noise to measure. Ascalesdict receives each window’sWeightScaleby spw.
- luv_finder.data.load(path, fields=None) DataHandler[source]¶
The visibilities of
fields(default: all) from a measurement set, an NPZ or a list of one dataset’s NPZs.
- luv_finder.data.pair_weight(a, b) ndarray[source]¶
Inverse variance of
(x_a +- x_b) / 2from the weights ofx_aandx_b; 0 if either is.
- luv_finder.data.pointing(path, field: int) tuple[Metadata, ndarray, float][source]¶
A field’s dataset metadata, phase centre (arcsec, the data’s sky frame) and lowest frequency (Hz), from a measurement set, an NPZ or a list of NPZs, without reading its visibilities.
- luv_finder.data.reweighted(chunks: Sequence[Chunk], ws: WeightScale | None = None) list[Chunk][source]¶
The chunks of one window, weights divided by
ws(defaultweight_scale()) per scan and channel.
- luv_finder.data.sky_direction(offset, ref) ndarray[source]¶
(RA, Dec) in rad of the (east, north)
offsetin arcsec fromref, the inverse ofsky_offset().
- luv_finder.data.sky_offset(direction, ref) ndarray[source]¶
(east, north) offset in arcsec of
directionon the tangent plane atref, both (RA, Dec) in rad.
- luv_finder.data.stokes_i(data: ndarray, weight: ndarray, flag: ndarray)[source]¶
Average the parallel hands
[0, -1]into (vis, w);weightper row or per channel,w0 if flagged.
- luv_finder.data.target_selection(msfile: str)[source]¶
Field and spectral-window ids observed with the target intent.
- luv_finder.data.weight_scale(chunks: Sequence[Chunk]) WeightScale[source]¶
sum w z^2 / 2 sum wper (scan, channel) over a window’s integrations of a baseline <=MAX_GAPapart.The integrations pair in their own field, so a pair sees one sky; a (scan, channel) with no such pair (a mosaic field seen once per visit) pairs across fields. A pair that spans two scans counts in both, so a scan of one integration is measured too.