Offline utilities

These examples use bundled data or small arrays. They need no JPL request, SPICE kernel, or kete installation.

pqfilt>=0.4.0 is installed with Skyloc and provides expression filtering.

1. Sample the solar spectrum

from astropy import units as u

import skyloc as sloc

solar = sloc.get_solspect([600, 1000] * u.nm)
solar
QTable length=2
wlflamdflamfnuABmag
umW / (um m2)W / (um m2)MJymag
float64float64float64float64float64
0.61778.63347959610545.335900699719788213583776.2318217-26.923855029501027
1.0730.74790960639552.192243817262351243751265.28579834-27.06730157459512

wl carries wavelength units; flam is spectral irradiance per wavelength at 1 au. The default reference is the full TSIS extension, stored as 1 nm bin averages. Interpolation samples flam at points; it does not integrate a bandpass. See solar spectra before choosing a grid.

2. Compare phase magnitudes

import numpy as np
import pandas as pd

phase = np.array([0.0, 30.0, 60.0])
magnitude = sloc.iau_hg_mag(hmag=12.0, alpha__deg=phase, gpar=0.15, robs=1.0, rhel=1.0)
np.testing.assert_allclose(magnitude[0], 12.0)
pd.DataFrame({"phase [deg]": phase, "apparent magnitude": magnitude})
phase [deg] apparent magnitude
0 0.0 12.000000
1 30.0 13.299251
2 60.0 14.147344

Assumptions: this example uses the IAU H–G model, unit observer and heliocentric distances in au, and phase angles in degrees. At zero phase and both distances equal to 1 au, the apparent magnitude equals hmag.

3. Transform a synthetic field

header = {
    "CTYPE1": "RA---TAN-SIP", "CTYPE2": "DEC--TAN-SIP",
    "CRVAL1": 180.0, "CRVAL2": 30.0,
    "CRPIX1": 51.0, "CRPIX2": 51.0,
    "CDELT1": -1.0 / 3600, "CDELT2": 1.0 / 3600,
    "A_ORDER": 2, "B_ORDER": 2,
    "NAXIS1": 101, "NAXIS2": 101,
}
wcs = sloc.FastTanSipWCS(header)
x = np.array([50.0, 60.0])
y = np.array([50.0, 55.0])
ra, dec = wcs.all_pix2world(x, y, 0)
recovered_x, recovered_y = wcs.all_world2pix(ra, dec, 0)
np.testing.assert_allclose([ra[0], dec[0]], [180.0, 30.0])
np.testing.assert_allclose(recovered_x, x, atol=1e-3, rtol=0)
np.testing.assert_allclose(recovered_y, y, atol=1e-3, rtol=0)
pd.DataFrame({"x": x, "y": y, "RA [deg]": ra, "Dec [deg]": dec})
x y RA [deg] Dec [deg]
0 50.0 50.0 180.000000 30.000000
1 60.0 55.0 179.996792 30.001389

origin=0 means Python pixel indexing, so FITS reference pixel (51, 51) is Python pixel (50, 50). This header has zero SIP distortion.

Scope: sloc.FastTanSipWCS supports TAN/SIP with the documented projection and pole assumptions; it is not a general FITS WCS interpreter. The first call also includes Numba compilation. Check the API reference before using survey headers.