Segmentation Map Cutouts
euclidkit provides a two-step workflow for going from MER crossmatch rows to
local MER segmentation-map FITS cutouts:
query-segmapresolves the segmentation-map tile metadata from the archive.compile-segmapopens the local tile FITS files and writes one cutout per source row.
This workflow is local-file oriented after query-segmap: compile-segmap
does not query TAP or use Datalink.
Workflow
Start from a MER crossmatch table. The table must contain SEGMENTATION_MAP_ID;
if it does not, rerun euclidkit crossmatch first.
euclidkit query-segmap \
--input crossmatch_results.fits \
--output segmentation_maps.fits \
--environment IDR
Then create cutouts from the local segmentation-map FITS files:
euclidkit compile-segmap \
--input segmentation_maps.fits \
--output-dir ./segmap_cutouts \
--size-arcsec 10
compile-segmap groups rows by datalabs_path + file_name and opens
each large segmentation-map tile once with FITS memmap.
Required columns
query-segmap input columns are matched case-insensitively:
SEGMENTATION_MAP_IDobject_idsource coordinates:
ra/dec, ormer_ra/mer_decifra/decare absent
compile-segmap input is normally the output of query-segmap and requires:
datalabs_pathfile_namesegmentation_map_idobject_idsource coordinates:
ra/dec, ormer_ra/mer_decifra/decare absent
Segmentation tile lookup
query-segmap computes the segmentation tile locally using the authoritative
formula:
tile_index = floor(SEGMENTATION_MAP_ID / 1_000_000)
It then joins the uploaded tile indices to the environment-specific
mer_segmentation_map table:
PDR:q1.mer_segmentation_mapIDR:dr1.mer_segmentation_mapOTFandREG:sedm.mer_segmentation_map
--idr-field and --idr-deep-partition are not used here because
mer_segmentation_map is not split by those MER catalogue partitions.
Cutout output
By default, compile-segmap writes one 10 arcsec x 10 arcsec FITS file per
source row. The output filename pattern is:
segmap_cutout_row######_obj*_seg*.fits
The output FITS primary HDU contains raw segmentation-label pixels from the MER segmentation map. Pixels are not converted into a source-only binary mask, and neighboring object labels inside the cutout are preserved.
Boundary sources use partial cutouts with zero-valued padding. Existing output
files are skipped by default; pass --overwrite to replace them. Use
--on-error skip to continue past missing files or bad rows, otherwise the
command fails on the first error.
Useful options
euclidkit compile-segmap \
--input segmentation_maps.fits \
--output-dir ./segmap_cutouts \
--size-arcsec 10 \
--overwrite \
--on-error skip \
--no-progress
--size-arcsecsets the square cutout size; default is10.0.--overwritereplaces existing cutout FITS files.--on-error fail|skipcontrols whether missing files or bad rows abort the run.--progress/--no-progresscontrols tile-processing progress output.
Python API
from euclidkit.core.segmap import compile_segmap_cutouts
stats = compile_segmap_cutouts(
input_table="segmentation_maps.fits",
output_dir="./segmap_cutouts",
size_arcsec=10.0,
on_error="skip",
show_progress=True,
)
print(stats.written_rows, stats.failed_rows)
compile_segmap_cutouts returns SegmapCutoutStats with requested, written,
failed, skipped-existing, and output-file counts.