potpyri.primitives.absphot
Absolute photometry zeropoint calibration using catalog magnitudes.
Queries VizieR (PS1, SDSS, 2MASS, UKIRT, SkyMapper, DES) or DECaLS / Legacy
Surveys Tractor PSF photometry via NOIRLab Data Lab TAP
(potpyri.utils.catalogs), applies point-source cuts, matches sources,
and fits zeropoint via iterative ODR. Writes ZPTMAG and related keywords to
the stack header.
All zeropoints and limiting magnitudes are reported in the AB system.
Native-Vega catalogs (notably 2MASS) are converted to AB before the fit; see
TWOMASS_VEGA_TO_AB and header keyword MAGSYS.
Authors: Kerry Paterson, Charlie Kilpatrick.
Functions
|
Convert catalog magnitudes in-place to AB if they are native Vega. |
|
Return the native magnitude system of a photometric reference catalog. |
|
Compute and write zeropoint to stack FITS using instrument catalog (e.g. PS1). |
Classes
|
Zeropoint fitter using catalog magnitudes and iterative sigma clipping. |
- class potpyri.primitives.absphot.absphot(iterations=5, sigma=5)[source]
Bases:
objectZeropoint fitter using catalog magnitudes and iterative sigma clipping.
- Y_band(J, J_err, K, K_err)[source]
Compute Y-band mag and error from J and K (2MASS relation).
- Parameters:
J (
array-likeorfloat) – J magnitude(s) and error(s).J_err (
array-likeorfloat) – J magnitude(s) and error(s).K (
array-likeorfloat) – K magnitude(s) and error(s).K_err (
array-likeorfloat) – K magnitude(s) and error(s).
- Returns:
(Y_mag, Y_err).
- Return type:
tuple
- convert_filter_name(filt)[source]
Map instrument filter names to catalog filter names (e.g. PS1).
- Parameters:
filt (
str) – Instrument filter keyword (e.g. ‘gG0301’, ‘RG850’).- Returns:
Catalog filter name (‘u’, ‘g’, ‘r’, ‘i’, ‘z’, ‘J’, etc.).
- Return type:
str
- find_zeropoint(cmpfile, tel, match_radius=<Quantity 2.5 arcsec>, phottable='APPPHOT', input_catalog=None, log=None)[source]
Compute zeropoint from cmpfile photometry and catalog; write to FITS header.
Matches sources to catalog (e.g. PS1, 2MASS), runs iterative ODR fit, and updates ZPTMAG, ZPTNSTAR, ZPTCAT, MAGSYS, etc. in the stack FITS. Magnitudes are always stored in the AB system (
MAGSYS='AB'); 2MASS Vega values are converted before the fit.- Parameters:
cmpfile (
str) – Path to stacked/comparison FITS with SCI and phottable extensions.tel (
Instrument) – Instrument instance (for get_catalog).match_radius (
astropy.units.Quantity, optional) – Matching radius for catalog. Default is 2.5 arcsec.phottable (
str, optional) – FITS extension with photometry table. Default is ‘APPPHOT’.input_catalog (
astropy.table.Table, optional) – Pre-loaded catalog; if None, catalog is queried via get_catalog.log (
ColoredLogger, optional) – Logger for progress.
- Returns:
True if ZPT keywords were written; False if photometry or catalog step did not complete (cmpfile may be unchanged).
- Return type:
bool
- get_catalog(coords, catalog, filt, log=None)[source]
Query a reference catalog for magnitudes around given coordinates.
Supports VizieR catalogs (PS1, SDSS, 2MASS, UKIRT, SkyMapper, DES) and DECaLS / Legacy Surveys Tractor PSF photometry via NOIRLab Data Lab TAP. Applies catalog-specific point-source cuts and returns a uniform product with columns
ra,dec,mag,mag_err.- Parameters:
coords (
astropy.coordinates.SkyCoord) – Target coordinates (used for region size).catalog (
str) – Catalog name (e.g. ‘PS1’, ‘2MASS’, ‘DECALS’).filt (
str) – Filter name (e.g. ‘g’, ‘r’, ‘J’).log (
ColoredLogger, optional) – Logger for progress.
- Returns:
(astropy.table.Table, catalog_name, catalog_ID) or (None, None, None) if query fails.
- Return type:
tupleor(None,None,None)
- get_minmag(filt)[source]
Return minimum catalog magnitude to use for zeropoint (bright limit).
- Parameters:
filt (
str) – Filter name.- Returns:
Minimum magnitude (brighter limit).
- Return type:
float
- get_zeropoint(flux, fluxerr, mag, magerr)[source]
Fit zeropoint (and error) from flux/mag arrays using ODR.
- Parameters:
flux (
array-like) – Object fluxes (e.g. from aperture photometry).fluxerr (
array-like) – Flux errors.mag (
array-like) – Catalog magnitudes.magerr (
array-like) – Catalog magnitude errors.
- Returns:
(zeropoint, zeropoint_error).
- Return type:
tupleoffloat
- zpt_iteration(flux, fluxerr, mag, magerr, log=None)[source]
Iteratively sigma-clip and fit zeropoint via ODR.
- Parameters:
flux (
array-like) – Object fluxes.fluxerr (
array-like) – Flux errors.mag (
array-like) – Catalog magnitudes.magerr (
array-like) – Catalog magnitude errors.log (
ColoredLogger, optional) – Logger for progress.
- Returns:
(zeropoint, zeropoint_error, master_mask). master_mask is boolean array of sources used in final fit.
- Return type:
tuple
- potpyri.primitives.absphot.apply_catalog_to_ab(cat, catalog, filt, log=None)[source]
Convert catalog magnitudes in-place to AB if they are native Vega.
- Parameters:
cat (
astropy.table.Table) – Table with amagcolumn (modified in place).catalog (
str) – Catalog name.filt (
str) – Catalog filter (J,H,K,Ks, …).log (
ColoredLogger, optional) – Logger.
- Returns:
Magnitude system of the returned photometry (
'AB').- Return type:
str
- potpyri.primitives.absphot.catalog_native_magsys(catalog)[source]
Return the native magnitude system of a photometric reference catalog.
- Parameters:
catalog (
str) – Catalog name (e.g.'PS1','2MASS').- Returns:
'VEGA'for 2MASS;'AB'for PS1 / SDSS / SkyMapper and others treated as AB in this pipeline.- Return type:
str
- potpyri.primitives.absphot.find_zeropoint(stack, tel, log=None)[source]
Compute and write zeropoint to stack FITS using instrument catalog (e.g. PS1).
- Parameters:
stack (
str) – Path to stacked science FITS file (SCI + APPPHOT extensions).tel (
Instrument) – Instrument instance (for catalog and filter).log (
ColoredLogger, optional) – Logger for progress and errors.
- Returns:
True if ZPT keywords were written; False otherwise (see log).
- Return type:
bool