potpyri.primitives.solve_wcs
WCS solution using astrometry.net and Gaia DR3 alignment.
Provides coarse solution via solve-field and fine alignment by matching detected sources to Gaia. Writes RADISP/DEDISP and updated WCS to FITS. Authors: Kerry Paterson, Charlie Kilpatrick.
Functions
|
Remove astrometry.net temporary files (.axy, .corr, .solved, .wcs, etc.). |
|
Refine WCS by matching detections to a reference catalog (fine alignment). |
|
Query the configured reference catalog for fine WCS alignment. |
|
Run astrometry.net (solve-field) to get coarse WCS; optionally use custom index. |
|
Check that a FITS header already defines a usable celestial WCS. |
- potpyri.primitives.solve_wcs.clean_up_astrometry(directory, file, exten)[source]
Remove astrometry.net temporary files (.axy, .corr, .solved, .wcs, etc.).
- Parameters:
directory (
str) – Directory containing the files.file (
str) – Base filename (with extension); exten is replaced to form temp names.exten (
str) – File extension (e.g. ‘.fits’) to replace with .axy, .corr, etc.
- Return type:
None
- potpyri.primitives.solve_wcs.fine_align_wcs(file, tel, catalog='gaia', radius=0.5, max_search_radius=<Quantity 5. arcsec>, save_centroids=False, min_cat_match=7, log=None)[source]
Refine WCS by matching detections to a reference catalog (fine alignment).
- Parameters:
file (
str) – Path to FITS file with WCS (e.g. after solve_astrometry).tel (
Instrument) – Instrument instance.catalog (
str, optional) – Reference catalog:gaia(default),panstarrs,sdss,legacy,twomass, orskymapper. Seepotpyri.utils.catalogs.FINE_ALIGN_CATALOG_CHOICES.radius (
float, optional) – Catalog query half-width in degrees. Default is 0.5.max_search_radius (
astropy.units.Quantity, optional) – Match radius between detections and catalog positions. Default is 5 arcsec.save_centroids (
bool, optional) – If True, save centroid table. Default is False.min_cat_match (
int, optional) – Minimum number of in-frame catalog sources required before matching. Default is 7.log (
ColoredLogger, optional) – Logger for progress.
- Returns:
True if alignment succeeded and WCS was updated, False otherwise.
- Return type:
bool
- potpyri.primitives.solve_wcs.get_fine_align_reference_catalog(input_file, catalog='gaia', radius_deg=0.5, log=None)[source]
Query the configured reference catalog for fine WCS alignment.
- Parameters:
input_file (
str) – Path to FITS file; primary header used for field center.catalog (
str, optional) – Catalog key (seepotpyri.utils.catalogs.FINE_ALIGN_CATALOG_CHOICES). Default is'gaia'.radius_deg (
float, optional) – Half-width of the VizieR query box in degrees. Default 0.5.log (
ColoredLogger, optional) – Logger.
- Returns:
Table with
RA_ICRS,DE_ICRSin degrees, None if empty or query failed, False if field center could not be parsed from the header.- Return type:
astropy.table.TableorNoneorFalse
- potpyri.primitives.solve_wcs.solve_astrometry(file, tel, binn, paths, radius=0.5, replace=True, shift_only=False, index=None, log=None)[source]
Run astrometry.net (solve-field) to get coarse WCS; optionally use custom index.
- Parameters:
file (
str) – Path to FITS file to solve.tel (
Instrument) – Instrument instance (name, get_pixscale).binn (
str) – Binning string (e.g. ‘22’) for pixel scale.paths (
dict) – Paths dict (source_extractor key for solve-field).radius (
float, optional) – Search radius in degrees. Default is 0.5.replace (
bool, optional) – If True, write WCS into original file; else write .solved.fits.shift_only (
bool, optional) – If True, only update CRPIX/CRVAL. Default is False.index (
str, optional) – Path to custom index file or directory for solve-field.log (
ColoredLogger, optional) – Logger for progress.
- Returns:
True if solve succeeded, False otherwise.
- Return type:
bool
- potpyri.primitives.solve_wcs.validate_existing_wcs_header(header)[source]
Check that a FITS header already defines a usable celestial WCS.
Requires CTYPE1, CTYPE2, CRVAL1, CRVAL2, CRPIX1, CRPIX2, and a linear celestial transform via either the CD matrix (CD1_1..CD2_2) or CDELT1 and CDELT2 (optionally with PC matrix). Confirms
astropy.wcs.WCScan parse the header and evaluate pixel-to-world for one point.- Parameters:
header (
astropy.io.fits.Header) – Header to validate (typically primary HDU).- Returns:
(ok, reason) where ok is True if validation passed; reason is an empty string on success, or a short message on failure.
- Return type:
tuple