API reference¶
Top-level API¶
- radialpaths.build_geometry(support, centres, *, centre_order='yx', validate_connected=True)[source]¶
Build support-constrained multi-centre radial geometry.
- Parameters:
support (array-like of bool, 2D) – Accepted support \(\Omega\).
Truepixels are traversable andFalsepixels—including internal holes—are excluded.centres (array-like, shape (N, 2)) – Supplied centre coordinates. Values are rounded with
numpy.rint.centre_order ({
"yx","xy"}, optional) – Coordinate ordering. The default is NumPy(row, column)order;"xy"accepts astronomy/plotting-style(x, y)positions.validate_connected (bool, optional) – Require one 8-connected support component. The mathematical construction assumes a connected support, so the default is
True.
- Returns:
Reusable float64 geometry independent of any subsequently measured tracer.
- Return type:
Notes
Distances are calculated on an 8-neighbour pixel graph with unit in-support costs. Exact distance ties are assigned to the first supplied centre, matching the validated implementation. Centre order is therefore part of the input whenever exact ties occur.
The paper’s observational products serialized normalized coordinates as float32. That reproduction-only storage setting is available from
radialpaths.reproduction.build_paper_geometry(); they are not the numerical default of this public constructor.The array should contain at least one layer of excluded pixels around its outer support if contact with the array edge is intended to be a physical boundary. This preserves the boundary expression without silently padding the input.
- radialpaths.radial_profile(data, geometry, *, coordinate='rho_D', bins=30, min_pixels=6, mask=None)[source]¶
Measure unweighted median profiles on a precomputed geometry.
- Parameters:
data (array-like, 2D) – Registered scalar field. Non-finite and masked values are excluded. An Astropy Quantity is accepted and its unit string is retained.
geometry (RadialGeometry) – Geometry returned by
radialpaths.build_geometry().coordinate ({
"rho_D","rho_X"}, optional) – Radial coordinate used for binning.bins (int or array-like, optional) – Number of equal bins on
[0, 1]or explicit edges spanning that interval. The validated default is 30 equal bins.min_pixels (int, optional) – Minimum selected pixels required for a populated bin. The validated default is six.
mask (array-like of bool, optional) – Additional exclusion mask, where
Truepixels are omitted.
- Returns:
Per-centre counts, unweighted medians, and 16th/84th percentiles.
- Return type:
Notes
Bins are lower-inclusive and upper-exclusive. Values exactly equal to one are explicitly included in the final bin, matching the observational figure estimator. No spline is fitted.
Image preparation¶
Inspectable preparation of support masks and candidate centres from images.
The functions in this module prepare the two formal inputs to the radial construction: a connected support and supplied centre coordinates. They do not infer physical nuclei, galaxies, or components.
- class radialpaths.preprocessing.BackgroundResult(background, sigma_bg, background_mask, number_of_iterations, metadata)[source]¶
Bases:
objectBackground location and scatter with the pixels used to estimate them.
- Parameters:
- class radialpaths.preprocessing.CentreCandidates(positions, peak_values, significance, rank, min_separation, selection_min_separation, detection_mask, metadata)[source]¶
Bases:
objectRanked local-intensity maxima considered as possible supplied centres.
- Parameters:
- peak_values: NDArray[float64]¶
- positions: NDArray[int64]¶
- rank: NDArray[int64]¶
- significance: NDArray[float64]¶
- class radialpaths.preprocessing.FinalSupportResult(support, component_labels, selected_component, rejected_components, number_of_pixels, all_centres_contained, touches_array_boundary)[source]¶
Bases:
objectOne connected support selected after supplied centres are known.
- Parameters:
- component_labels: NDArray[int32]¶
- class radialpaths.preprocessing.PreparedImage(image, background_result, support_result, candidates, centres, final_support)[source]¶
Bases:
objectAll decisions made by
prepare_image(), before radial geometry.- Parameters:
image (NDArray[float64])
background_result (BackgroundResult)
support_result (SupportResult)
candidates (CentreCandidates)
centres (NDArray[int64])
final_support (FinalSupportResult)
- background_result: BackgroundResult¶
- candidates: CentreCandidates¶
- centres: NDArray[int64]¶
- final_support: FinalSupportResult¶
- image: NDArray[float64]¶
- property smoothed: NDArray[float64]¶
- support_result: SupportResult¶
- class radialpaths.preprocessing.SupportResult(image, smoothed, background, sigma_bg, provisional_support, threshold, smoothing_sigma, closing_radius, dilation_radius, valid_mask, metadata)[source]¶
Bases:
objectIntermediate products from threshold-based support preparation.
- Parameters:
- image: NDArray[float64]¶
- smoothed: NDArray[float64]¶
- radialpaths.preprocessing.estimate_background(image, *, preset='generic', psf_fwhm=None, smoothing_sigma=None, morphology_radius=None, error=None, bad_pixel_mask=None, border_fraction=0.2, threshold_sigma=1.5, maximum_iterations=5, convergence_centre_sigma=0.02, convergence_scale_fraction=0.02)[source]¶
Estimate a background from the image exterior with source exclusion.
preset="paper"reproduces the finite iterative estimator used for the JADES preparation. It is a reference procedure, not a claim that this background model is appropriate for every image.- Parameters:
image (ArrayLike)
preset (str)
psf_fwhm (float | None)
smoothing_sigma (float | None)
morphology_radius (float | None)
error (ArrayLike | None)
bad_pixel_mask (ArrayLike | None)
border_fraction (float)
threshold_sigma (float)
maximum_iterations (int)
convergence_centre_sigma (float)
convergence_scale_fraction (float)
- Return type:
- radialpaths.preprocessing.finalize_support(provisional_support, centres, *, connectivity=8, bad_pixel_mask=None)[source]¶
Retain the connected provisional component containing all centres.
- Parameters:
provisional_support (ArrayLike)
centres (ArrayLike)
connectivity (int)
bad_pixel_mask (ArrayLike | None)
- Return type:
- radialpaths.preprocessing.find_centre_candidates(prepared_support, *, preset='generic', psf_fwhm=None, maximum_radius=None, threshold_sigma=5.0, selection_min_separation=None)[source]¶
Rank local maxima on the support-preparation smoothed image.
The paper preset uses a maximum-filter radius of one PSF FWHM. The separate two-FWHM admission separation is stored as the recommended selection separation and is applied only when centres are selected automatically.
- Parameters:
- Return type:
- radialpaths.preprocessing.prepare_image(image, *, preset, n_centres=None, selected_candidate_indices=None, centres=None, psf_fwhm=None, smoothing_sigma=None, closing_radius=None, dilation_radius=None, maximum_radius=None, minimum_separation=None, background=None, sigma_bg=None, error=None, bad_pixel_mask=None)[source]¶
Run the inspectable image-to-support-and-centres preparation sequence.
Exactly one of
n_centres,selected_candidate_indices, orcentresmust be provided. The returned object exposes every intermediate product; it does not build radial geometry.- Parameters:
image (ArrayLike)
preset (str)
n_centres (int | None)
centres (ArrayLike | None)
psf_fwhm (float | None)
smoothing_sigma (float | None)
closing_radius (float | None)
dilation_radius (float | None)
maximum_radius (float | None)
minimum_separation (float | None)
background (float | None)
sigma_bg (float | None)
error (ArrayLike | None)
bad_pixel_mask (ArrayLike | None)
- Return type:
- radialpaths.preprocessing.prepare_support(image, *, background, sigma_bg, preset='generic', psf_fwhm=None, smoothing_sigma=None, closing_radius=None, dilation_radius=None, threshold_sigma=1.5, bad_pixel_mask=None)[source]¶
Construct a provisional support without selecting a component.
Internal holes are never filled. Invalid and user-masked pixels remain excluded from the provisional support.
- radialpaths.preprocessing.select_centres(candidates=None, *, n_centres=None, indices=None, centres=None, min_separation=None)[source]¶
Select supplied centres by rank, candidate indices, or coordinates.
No value of
n_centresis inferred. Explicit coordinates bypass candidate detection entirely.- Parameters:
candidates (CentreCandidates | None)
n_centres (int | None)
centres (ArrayLike | None)
min_separation (float | None)
- Return type:
NDArray[int64]
Result objects¶
- class radialpaths.RadialGeometry(support, centres, distances, labels, centre_distance, boundary, boundary_distance, rho_D, rho_X, extents)[source]¶
Reusable radial geometry for a support and supplied centres.
Parameters are exposed as arrays so the construction remains inspectable. Arrays outside
supportareNaNfor continuous fields and-1forlabels.- Parameters:
- centres¶
Rounded centre positions in NumPy
(row, column)order. Here,Nis the number of supplied centres.
- distances¶
Per-centre support-constrained graph distances \(d_k(x)\).
- Type:
ndarray, shape (N, ny, nx)
- labels¶
Centre assignment \(a(x)\). Outside-support pixels are
-1.
- boundary¶
In-support pixels adjacent to excluded pixels in the 3-by-3 neighborhood.
- boundary_distance¶
Support-constrained distance \(b(x)\) to the boundary.
- Type:
ndarray, shape (ny, nx)
- rho_D, rho_X
Relative depth and normalized progression coordinates.
- Type:
ndarray, shape (ny, nx)
- coordinate(name)[source]¶
Return one radial-coordinate field.
- Parameters:
name ({
"rho_D","rho_X"}) – Coordinate name. Lower-case spellings"rho_d"and"rho_x"are accepted.- Return type:
NDArray[float64]
- class radialpaths.RadialProfile(coordinate, edges, radius, median, p16, p84, count, min_pixels, unit=None)[source]¶
Centre-conditioned binned profiles for a registered scalar field.
All two-dimensional result arrays have shape
(N, n_bins), whereNis the number of supplied centres. Omitted bins containNaNin the summary arrays while retaining their actual pixel count incount.- Parameters:
- for_centre(centre)[source]¶
Return the profile for one zero-based centre index.
- Parameters:
centre (int)
- Return type:
- property values: NDArray[float64]¶
Alias for the binned median values.
- class radialpaths.CentreProfile(centre, coordinate, edges, radius, median, p16, p84, count, unit=None)[source]¶
One centre-associated profile extracted from a
RadialProfile.- Parameters:
Synthetic examples¶
Small deterministic supports and tracers for examples and teaching.
- class radialpaths.synthetic.SyntheticScene(name, support, centres, brightness, tracer)[source]¶
A support, supplied centres, and two registered demonstration tracers.
- radialpaths.synthetic.make_scene(name='folded', size=101)[source]¶
Create a canonical deterministic demonstration scene.
- Parameters:
name ({
"compact","folded","perforated","branched",) –"capybara","trex"} Geometric example.size (int, optional) – Square array size. Values below 61 are rejected to keep structures resolved for the 30-bin demonstration.
- Return type:
Plotting¶
Optional Matplotlib helpers with manuscript-consistent semantics.
- radialpaths.plotting.plot_centre_candidates(image, candidates, *, selected=None, ax=None)[source]¶
Plot numbered centre candidates for scientific review.
Selected and unselected markers are visually distinct. Candidate numbers are zero-based and match
CentreCandidates.rank.- Parameters:
candidates (CentreCandidates)
- radialpaths.plotting.plot_geometry(geometry, *, coordinate='rho_D', ax=None, contours=True)[source]¶
Plot a radial-coordinate field, support outline, and supplied centres.
Returns the Matplotlib
Axesand image artist.- Parameters:
geometry (RadialGeometry)
coordinate (str)
contours (bool)
- radialpaths.plotting.plot_overview(data, geometry, *, coordinate='rho_D', profile=None)[source]¶
Plot tracer, coordinate geometry, and profile as a compact narrative.
- Parameters:
geometry (RadialGeometry)
coordinate (str)
profile (RadialProfile | None)
- radialpaths.plotting.plot_profile(profile, *, ax=None, uncertainty=True)[source]¶
Plot centre-conditioned profile medians with optional percentile bands.
- Parameters:
profile (RadialProfile)
uncertainty (bool)
I/O¶
Serialization helpers for reusable geometries and registered images.
- radialpaths.io.load_geometry(path)[source]¶
Load a geometry written by
save_geometry().- Parameters:
- Return type:
- radialpaths.io.read_fits(path, *, extension=0)[source]¶
Read a FITS image lazily through the optional Astropy dependency.
- radialpaths.io.read_image(path, *, channel=None, colour_mode=None)[source]¶
Read a raster image as a two-dimensional scalar array.
Grayscale PNG, JPEG, and TIFF files are returned directly. For a colour image, provide a zero-based
channelor setcolour_mode="luminance". The documented luminance conversion is Rec. 709:0.2126 R + 0.7152 G + 0.0722 B. No colour conversion is performed silently.
- radialpaths.io.save_geometry(path, geometry)[source]¶
Save a
RadialGeometryto a compressed NPZ file.- Parameters:
geometry (RadialGeometry)
- Return type:
None