luv_finder.plotting

Diagnostic figures shared by the CLI, the run products and the test suite.

Every function returns its Figure and writes <plots_dir>/<name>.png only when plots_dir is given, so a notebook shows the figure and a script or pytest --plots saves the same plot. Figures are built without pyplot (nothing to close, never shown twice in a notebook) and inside style(), the package’s matplotlib style, which leaves the caller’s rcParams alone.

Module Attributes

STYLE

The package's matplotlib style file.

FRAMES

Gallery frame of a line that passes only the likelihood ratio, or only the fidelity; both: the plain frame.

Functions

amp_phase_check(data, positions[, ...])

Amplitude and phase of the vector-averaged visibility against frequency.

continuum_spectra_check(cat[, plots_dir, name])

Each continuum source's flux density per window with flux (nu / freq_ghz)^alpha over it.

dirty_maps_check(dra, ddec, moment8, ...[, ...])

Moment-8 (S/N), continuum (mJy/beam), and the moment-8 with continuum contours.

erf_curve(snr, fidelity)

(centre, width) of F = (1 + erf((S/N - centre) / sqrt(2) width)) / 2 fitted to fidelity points.

filter_responses(freqs, snr, widths, labels)

The matched-filter response of every group: S/N against frequency for each template, one panel each.

line_maps_check(maps, cat[, plots_dir, name])

Moment-0 map of every fitted line (luv_finder.imaging.line_maps()), the fitted position marked.

line_spectra_check(cat[, span, plots_dir, name])

Each fitted line's spectrum and best fit within span FWHM of its centre, both over the fitted peak.

mosaic_layout(offsets, primary_beam[, ...])

Pointing centres and half-power primary beams in the dataset's sky frame.

noise_check(mf[, plots_dir, name])

Response statistics of the data against its jackknife and a unit Gaussian.

passes(cat)

Which reliability test each row passes: both, likelihood, fidelity or none.

peak_snr_map(maps[, marks, plots_dir, name])

Peak S/N on the sky from saved maps (dra, ddec, peak) (one or several), their maximum.

pointings_check(freqs_ghz, pointings, ...[, ...])

One position seen through several pointings of a mosaic, and the combination.

reliability_check(cat[, plots_dir, name])

Counts, likelihood ratio and fidelity of a catalogue against its noise model.

response_check(mf[, plots_dir, name, line_ghz])

Matched-filter response of the best grid point, with the jackknife overlaid.

response_shape_check(nc, result[, peaks, ...])

The null correlation rho of the response against what bright lines actually look like.

responses_check(freqs, curves, title[, ...])

Several S/N spectra on one axis, e.g. the phase centre against the source positions.

snr_map(mf[, plots_dir, name, marks])

Peak S/N over channels, widths and sizes at every (dra, ddec) of the grid.

spectrum_check(data, dra, ddec[, model, ...])

Real and imaginary visibility spectra: data, jackknife and model.

style()

The Luv_finder figure style as a context manager: with style(): ....

weights_check(chunks, labels[, plots_dir, ...])

Do the weights predict the scatter? Re V at the phase centre per channel, its spread and <1/w>^1/2.

luv_finder.plotting.FRAMES = {'fidelity': '0.8', 'likelihood': 'k'}

Gallery frame of a line that passes only the likelihood ratio, or only the fidelity; both: the plain frame.

luv_finder.plotting.STYLE = PosixPath('/home/runner/work/Luv_finder/Luv_finder/luv_finder/luv.mplstyle')

The package’s matplotlib style file.

luv_finder.plotting.amp_phase_check(data, positions, plots_dir=None, name='amp_phase', line_ghz=None)[source]

Amplitude and phase of the vector-averaged visibility against frequency.

positions maps a label to a (dra, ddec) the visibilities are phase-shifted onto first. On a source the phase stays near zero across its line and the amplitude rises; elsewhere the phase wanders and the amplitude is the noise floor.

luv_finder.plotting.continuum_spectra_check(cat, plots_dir=None, name='continuum_spectra')[source]

Each continuum source’s flux density per window with flux (nu / freq_ghz)^alpha over it.

luv_finder.plotting.dirty_maps_check(dra, ddec, moment8, continuum, sigma, plots_dir=None, name='dirty_maps', marks=None)[source]

Moment-8 (S/N), continuum (mJy/beam), and the moment-8 with continuum contours.

Takes the output of luv_finder.imaging.dirty_maps() on the dra x ddec grid. Contours are at -3 (dashed) and 3, 5, 10, 20, 50 times the continuum noise sigma, a scalar or a per-pixel map shaped like continuum (a mosaic’s noise varies across the field). NaN pixels, outside every primary beam, are left blank. The colour scales are robust to a few extreme pixels: continuum 1st to 99th percentile of the well-covered area (noise within twice its minimum), moment-8 0 to 99.9th percentile.

luv_finder.plotting.erf_curve(snr, fidelity) → tuple[float, float][source]

(centre, width) of F = (1 + erf((S/N - centre) / sqrt(2) width)) / 2 fitted to fidelity points.

For display only: it smooths the tail model’s binned fidelity; the thresholds come from the bins. NaN when fewer than three points are finite or the fit fails.

luv_finder.plotting.filter_responses(freqs, snr, widths, labels, jk=None, at=None, passed=None, span=3000.0, plots_dir=None, name='filter_responses')[source]

The matched-filter response of every group: S/N against frequency for each template, one panel each.

freqs[g] (Hz), widths[g] (km/s) and snr[g], jk[g] (templates x frequencies) per group, as saved by a run (groups of different units have different frequencies); one shared array is accepted for each too. at[g] (Hz) is the group’s own frequency, marked: another line at the same position can be brighter (default: the peak). The best template there is drawn thick, the jackknife’s response to it in grey, the group’s S/N dotted; each panel spans span km/s around it (None: everything). passed[g] (see passes()) frames a group that passes only one reliability test.

luv_finder.plotting.line_maps_check(maps, cat, plots_dir=None, name='line_maps')[source]

Moment-0 map of every fitted line (luv_finder.imaging.line_maps()), the fitted position marked.

luv_finder.plotting.line_spectra_check(cat, span=3.0, plots_dir=None, name='line_spectra')[source]

Each fitted line’s spectrum and best fit within span FWHM of its centre, both over the fitted peak.

luv_finder.plotting.mosaic_layout(offsets, primary_beam, plots_dir=None, name='mosaic', marks=None)[source]

Pointing centres and half-power primary beams in the dataset’s sky frame.

offsets maps a field id to its phase centre (dra, ddec) in arcsec; primary_beam is the beam FWHM in arcsec.

luv_finder.plotting.noise_check(mf, plots_dir=None, name='noise')[source]

Response statistics of the data against its jackknife and a unit Gaussian.

Left: the distribution of the response over all grid points and channels. Right: how many of them exceed a threshold, which is what a detection threshold has to be calibrated on. Neighbouring grid points and channels are correlated, so the counts are not independent. NaN entries (positions outside every primary beam of a mosaic) are dropped.

luv_finder.plotting.passes(cat) → ndarray[source]

Which reliability test each row passes: both, likelihood, fidelity or none.

luv_finder.plotting.peak_snr_map(maps, marks=None, plots_dir=None, name='peak_snr')[source]

Peak S/N on the sky from saved maps (dra, ddec, peak) (one or several), their maximum.

The units of one band are searched on lattices of different steps (half each one’s resolution), so every map is put onto the finest by nearest neighbour; positions no map covers stay blank. Drawn interpolated between the lattice points (Gouraud shading; display only). marks maps a label to a (dra, ddec), or is a catalogue whose rows are marked #id at dra, ddec.

luv_finder.plotting.pointings_check(freqs_ghz, pointings, combined, beam, plots_dir=None, name='pointings', line_ghz=None)[source]

One position seen through several pointings of a mosaic, and the combination.

pointings maps a label to a dict with distance (arcsec from that pointing’s centre), pb (primary beam at the line) and flux [Jy, primary-beam corrected], error [Jy] and snr over freqs_ghz (NaN where the pointing does not cover the position); combined has flux, error and snr; beam is (offsets, response) of the primary beam at the line. Left: where each pointing sits on the beam, hollow if it never covers the position. Middle: flux density with the combined +- 1 sigma band. Right: S/N, which the beam correction leaves unchanged. Pointings that never cover are left out of both.

luv_finder.plotting.reliability_check(cat, plots_dir=None, name='reliability')[source]

Counts, likelihood ratio and fidelity of a catalogue against its noise model.

cat is the output of luv_finder.catalogue.catalogue() (its meta holds what is plotted, so a subset of its rows works too). Left: cumulative group counts N(>= S/N) of the data, the jackknife and the negated data (a diagnostic only) from the noise floor, with the detected rows on the data curve, and the noise model: the peak counts of every kernel summed. Middle: the likelihood ratio of every row against its kernel’s model, against the threshold k and the lowest S/N above it. Right: the binned fidelity 1 - N_jackknife / N_data, the model’s fidelity with an erf through it (erf_curve(), display only) and the lowest S/N reaching fidelity_min, and the binned fidelity against the negated data (as ASPECS measures it) for comparison. The model and the thresholds are left out where they are NaN.

luv_finder.plotting.response_check(mf, plots_dir=None, name='filter_response', line_ghz=None)[source]

Matched-filter response of the best grid point, with the jackknife overlaid.

The y axis is signal-to-noise, so the peak height is the line’s S/N.

luv_finder.plotting.response_shape_check(nc, result, peaks=(), plots_dir=None, name='response_shape')[source]

The null correlation rho of the response against what bright lines actually look like.

nc is a ResponseCorrelation measured on result, peaks a sequence of (i, j, t, k) indices into result.snr. Top row: rho over position lags for the first template with its half-power ellipse and rho = 0 contour; rho over channel lags per template (solid) against the white-channel analytic exp(-k^2 / 4 s^2) of a Gaussian template (dashed); rho between templates with, for templates differing only in width, the analytic sqrt(2 W1 W2 / (W1^2 + W2^2)) in parentheses. Bottom row (if peaks): cuts of snr / snr_peak through each peak along dra, ddec and channels, against the expectation E[snr(p)] = (S/N)_peak rho(p - p_peak) (thick, per template), within the lags of nc.

luv_finder.plotting.responses_check(freqs, curves, title, plots_dir=None, name='responses', line_ghz=None)[source]

Several S/N spectra on one axis, e.g. the phase centre against the source positions.

curves maps a legend label to a response with one value per frequency in freqs (GHz).

luv_finder.plotting.snr_map(mf, plots_dir=None, name='snr_map', marks=None)[source]

Peak S/N over channels, widths and sizes at every (dra, ddec) of the grid.

The data and, when it was run, the jackknife are shown side by side on one colour scale. marks maps a label to a (dra, ddec) position to circle, e.g. an injected source. Positions where the response is NaN (outside every primary beam of a mosaic) are left blank.

luv_finder.plotting.spectrum_check(data, dra, ddec, model=None, plots_dir=None, name='spectrum', line_ghz=None)[source]

Real and imaginary visibility spectra: data, jackknife and model.

The data are shown at the reference direction and phase-shifted onto (dra, ddec); the jackknife and the model (a source component) only shifted. A real source is flat at the reference and peaks once shifted; the jackknife should stay consistent with zero.

luv_finder.plotting.style()[source]

The Luv_finder figure style as a context manager: with style(): ....

luv_finder.plotting.weights_check(chunks, labels, plots_dir=None, name='weights', n_points=200000, seed=0, pooled=())[source]

Do the weights predict the scatter? Re V at the phase centre per channel, its spread and <1/w>^1/2.

One panel per chunk (one field and window, e.g. with the measurement set’s weights and reweighted), each with a random n_points of the visibilities, the measured spread (median and robust sigma per channel) and the spread the weights predict; below, the measured over the predicted spread per channel, from Re V sqrt(w), which is 1 where the weights hold. The sky is in V too, which is fine for a faint field. The ratio scatters by 1.166 / sqrt(N) per channel (shaded), so one field ripples; pooled, the window’s chunks of every field, tests the reweighting, which is fitted per scan over them all.