lunar_toolkit.selection
¶
Illumination-diverse image selection for shape-from-shading.
KMedoidsSelection(chosen, stage, medoids, labels, directions, uncovered, poorly_lit, history=list())
dataclass
¶
Result of select_kmedoids (indices refer to the input
rows).
| Attributes: |
|
|---|
sort_by_sun_azimuth(obs_df, start=0.0, column='sub_solar_azimuth')
¶
Sort rows by Sun azimuth, measured clockwise from start degrees.
Rows with an unknown azimuth go last. The index is preserved.
aoi_coverage(obs_df, aoi)
¶
Fraction (0–1) of the AOI covered by each row's footprint.
aoi is {"point": (lat, lon), "radius_km": r},
{"lat": (s, n), "lon": (w, e)} or anything
lunar_toolkit.geometry.load_aoi accepts.
select_illumination_diverse(obs_df, azimuth_bin_deg=30.0, incidence=None, per_bin=1, max_images=None, prefer='balanced', aoi=None, min_aoi_coverage=0.0, incidence_bin_deg=None, max_emission=None, method='bins', azimuth_origin=0.0)
¶
Choose images spanning diverse Sun azimuths (for SfS / PSR mapping).
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
This uses each image's single scene-centre Sun azimuth; for a large AOI
where per-pixel diversity matters, use
select_for_coverage.
select_for_coverage(obs_df, aoi, azimuth_sep_deg=30.0, views_per_cell=3, incidence=None, max_images=None, prefer='balanced', max_emission=None, grid_km=None, min_gain=1)
¶
Greedy, per-location illumination-diverse selection over an AOI.
The AOI is sampled on a grid (grid_km spacing; default ~100 cells
across). Each grid cell keeps the Sun azimuths of the selected images
covering it. A candidate helps a cell if it covers the cell, the cell
has fewer than views_per_cell views and the candidate's azimuth is at
least azimuth_sep_deg from every azimuth already there. At each step
the image maximising helped_cells * (0.5 + 0.5 * score) is taken
(score as in select_illumination_diverse,
normalised to 0–1), until no image helps min_gain cells or max_images is reached.
| Returns: |
|
|---|
selection_distances(coverage, azimuth, weights=(1.0, 1.0), chunk=256)
¶
Image-to-image distance of Bertone et al. (2026, sec. 2) for k-medoids selection.
d_ij = sqrt((w_a * a_ij)**2 + (w_c * c_ij)**2) with a_ij the
circular Sun azimuth (sub-solar longitude) difference and c_ij the
fraction of grid cells covered by exactly one of the two images, each
divided by its largest value over all pairs (so both span 0-1).
| Parameters: |
|
|---|
| Returns: |
|
|---|
kmedoids(dist, k, init='build', seed=0, n_init=1, max_iter=100)
¶
Alternating k-medoids (Park & Jun 2009) on a precomputed distance matrix.
Assign every object to its nearest medoid, move each medoid to the member with the smallest total distance to its cluster, repeat until the medoids stop changing.
| Parameters: |
|
|---|
| Returns: |
|
|---|
select_kmedoids(lit, azimuth, n_clusters=30, *, coverage=None, views=3, azimuth_sep=30.0, max_uncovered=0.005, max_poorly_lit=0.01, max_images=None, weights=(1.0, 1.0), init='build', seed=0, n_init=1)
¶
k-medoids image selection with coverage and illumination refinement (Bertone et al. 2026, sec. 2).
- Cluster the images with
kmedoidsonselection_distances(Sun azimuth and coverage differences) and take the n_clusters medoids. - Add the image lighting the most still-uncovered cells until fewer than max_uncovered of the potentially lit cells (lit in any image) are uncovered.
- Add the image giving the most cells a new direction (Sun azimuth at least azimuth_sep from the cell's directions so far, up to views) until fewer than max_poorly_lit of the potentially lit cells have fewer than views directions.
Steps 2-3 stop early when no image helps or max_images is reached;
ties go to the lowest index, so the result is deterministic (for
init="random" given seed).
| Parameters: |
|
|---|
coverage_matrix(obs_df, aoi, grid_km=None)
¶
Footprint coverage of the AOI grid cells: (cover[n_images, n_cells], x, y).
The grid is the one select_for_coverage uses (cell
centres in the AOI's tangent plane, km).
select_kmedoids_footprints(obs_df, aoi, n_clusters=30, incidence=None, max_emission=None, grid_km=None, **options)
¶
select_kmedoids on catalogue footprints over an AOI
(footprint = lit, no shadows).
options go to select_kmedoids. Returns the selected rows
sorted by sub_solar_azimuth with selection_order,
selection_stage and cluster columns; attrs holds
uncovered, poorly_lit and n_cells.