spotter.core#

Core utilities for spherical maps, geometry, and flux calculations.

This module provides functions for working with HEALPix maps, including coordinate transformations, limb darkening, spot generation, and flux integration for stellar surfaces.

Functions#

distance(X, x)

Compute the great-circle distance between vectors X and x.

npix(N)

Return the number of HEALPix pixels for a given nside.

equator_coords([phi, inc, obl])

Compute the coordinates of the stellar equator for given orientation.

mask_projected_limb(N_or_y[, phase, inc, u, obl])

Compute mask, projected area, and limb darkening for visible pixels.

vec(N_or_y)

Return xyz coordinates for all pixels of a HEALPix map.

design_matrix(N_or_y[, phase, inc, u, obl, normalize])

Compute the flux design matrix for a HEALPix map.

flux(y[, inc, u, phase, obl])

Compute the flux for a given map and orientation.

spherical_to_cartesian(theta, phi)

Convert spherical coordinates to cartesian.

spot(N, latitude, longitude, radius[, sharpness])

Generate a HEALPix map with a circular spot.

soft_spot(N, latitude, longitude, radius)

Generate a HEALPix map with a soft-edged spot.

render(y[, inc, u, phase, obl, xsize, period, radius])

Render a HEALPix map as an orthographic projection.

amplitude(→ callable)

Return a function to compute the amplitude of flux variations.

transit_chord(N, x, r[, inc])

Compute mask for a transit chord across the stellar disk.

radial_velocity(theta, phi, period, radius, phase[, inc])

Compute the radial velocity at each pixel.

doppler_shift(theta, phi, period, radius, phase[, inc])

Compute the Doppler shift at each pixel.

shifted_spectra(spectra, shift)

Apply a Doppler shift to spectra.

integrated_spectrum(design_matrix, theta, phi, period, ...)

Compute the integrated spectrum of a rotating star.

Module Contents#

spotter.core.distance(X, x)[source]#

Compute the great-circle distance between vectors X and x.

Parameters:
  • X (array_like, shape (..., 3)) – Array of 3D vectors.

  • x (array_like, shape (3,)) – Single 3D vector.

Returns:

d – Great-circle distance(s) in radians.

Return type:

array_like

spotter.core.npix(N)[source]#

Return the number of HEALPix pixels for a given nside.

Parameters:

N (int) – HEALPix nside parameter.

Returns:

n – Number of pixels.

Return type:

int

spotter.core.equator_coords(phi=None, inc=None, obl=None)[source]#

Compute the coordinates of the stellar equator for given orientation.

Parameters:
  • phi (float or None, optional) – Rotation phase in radians.

  • inc (float or None, optional) – Inclination in radians.

  • obl (float or None, optional) – Obliquity in radians.

Returns:

coords – Cartesian coordinates.

Return type:

ndarray, shape (3,)

spotter.core.mask_projected_limb(N_or_y, phase=None, inc=None, u=None, obl=None)[source]#

Compute mask, projected area, and limb darkening for visible pixels.

Parameters:
  • X (array_like, shape (..., 3)) – Cartesian coordinates of pixels.

  • phase (float, optional) – Rotation phase in radians.

  • inc (float, optional) – Inclination in radians.

  • u (array_like or None, optional) – Limb darkening coefficients.

  • obl (float, optional) – Obliquity in radians.

Returns:

  • mask (ndarray) – Boolean mask for visible pixels.

  • projected_area (ndarray) – Projected area for each pixel.

  • limb_darkening (ndarray) – Limb darkening factor for each pixel.

spotter.core.vec(N_or_y)[source]#

Return xyz coordinates for all pixels of a HEALPix map.

Parameters:

N_or_y (int or array_like) – HEALPix nside or map.

Returns:

xyz – Cartesian coordinates of pixels.

Return type:

ndarray, shape (npix, 3)

spotter.core.design_matrix(N_or_y, phase=None, inc=None, u=None, obl=None, normalize=True)[source]#

Compute the flux design matrix for a HEALPix map.

Parameters:
  • N_or_y (int or array_like) – HEALPix nside or map.

  • phase (float, optional) – Rotation phase in radians.

  • inc (float, optional) – Inclination in radians.

  • u (array_like or None, optional) – Limb darkening coefficients.

  • obl (float, optional) – Obliquity in radians.

Returns:

matrix – Design matrix.

Return type:

ndarray

spotter.core.flux(y, inc=None, u=None, phase=None, obl=None)[source]#

Compute the flux for a given map and orientation.

Parameters:
  • y (array_like) – HEALPix map.

  • inc (float, optional) – Inclination in radians.

  • u (array_like or None, optional) – Limb darkening coefficients.

  • phase (float, optional) – Rotation phase in radians.

  • obl (float, optional) – Obliquity in radians.

Returns:

flux – Integrated flux.

Return type:

float

spotter.core.spherical_to_cartesian(theta, phi)[source]#

Convert spherical coordinates to cartesian.

Parameters:
  • theta (float or array_like) – Colatitude in radians.

  • phi (float or array_like) – Longitude in radians.

Returns:

xyz – Cartesian coordinates.

Return type:

ndarray, shape (3,) or (…, 3)

spotter.core.spot(N, latitude, longitude, radius, sharpness=1000)[source]#

Generate a HEALPix map with a circular spot.

Parameters:
  • N (int) – HEALPix nside.

  • latitude (float) – Latitude of the spot center in radians.

  • longitude (float) – Longitude of the spot center in radians.

  • radius (float) – Spot radius in radians.

  • sharpness (float, optional) – Sharpness of the spot edge.

Returns:

spot_map – HEALPix map with spot.

Return type:

ndarray

spotter.core.soft_spot(N, latitude, longitude, radius)[source]#

Generate a HEALPix map with a soft-edged spot.

Parameters:
  • N (int) – HEALPix nside.

  • latitude (float) – Latitude of the spot center in radians.

  • longitude (float) – Longitude of the spot center in radians.

  • radius (float) – Spot radius in radians.

Returns:

spot_map – HEALPix map with soft-edged spot.

Return type:

ndarray

spotter.core.render(y, inc=None, u=None, phase=0.0, obl=0.0, xsize=800, period=None, radius=None)[source]#

Render a HEALPix map as an orthographic projection.

Parameters:
  • y (array_like) – HEALPix map.

  • inc (float, optional) – Inclination in radians.

  • u (array_like or None, optional) – Limb darkening coefficients.

  • phase (float, optional) – Rotation phase in radians.

  • obl (float, optional) – Obliquity in radians.

  • xsize (int, optional) – Output image size.

Returns:

img – Rendered image.

Return type:

ndarray

spotter.core.amplitude(N_or_y, inc=None, u=None, undersampling: int = 3) callable[source]#

Return a function to compute the amplitude of flux variations.

Parameters:
  • N_or_y (int or array_like) – HEALPix nside or map.

  • inc (float, optional) – Inclination in radians.

  • u (array_like or None, optional) – Limb darkening coefficients.

  • undersampling (int, optional) – Undersampling factor for phase grid.

Returns:

fun – Function that computes amplitude for a given map.

Return type:

callable

spotter.core.transit_chord(N, x, r, inc=None)[source]#

Compute mask for a transit chord across the stellar disk.

Parameters:
  • N (int) – HEALPix nside.

  • x (float) – Chord center position.

  • r (float) – Chord radius.

  • inc (float, optional) – Inclination in radians.

Returns:

mask – Boolean mask for pixels inside the chord.

Return type:

ndarray

spotter.core.radial_velocity(theta, phi, period, radius, phase, inc=None)[source]#

Compute the radial velocity at each pixel.

Parameters:
  • theta (array_like) – Colatitude in radians.

  • phi (array_like) – Longitude in radians.

  • period (float) – Rotation period in days.

  • radius (float) – Stellar radius in solar radii.

  • phase (float) – Rotation phase in radians.

  • inc (float, optional) – Inclination in radians.

Returns:

rv – Radial velocity at each pixel (m/s).

Return type:

ndarray

spotter.core.doppler_shift(theta, phi, period, radius, phase, inc=None)[source]#

Compute the Doppler shift at each pixel.

Parameters:
  • theta (array_like) – Colatitude in radians.

  • phi (array_like) – Longitude in radians.

  • period (float) – Rotation period in days.

  • radius (float) – Stellar radius in solar radii.

  • phase (float) – Rotation phase in radians.

  • inc (float, optional) – Inclination in radians.

Returns:

shift – Doppler shift at each pixel (fractional).

Return type:

ndarray

spotter.core.shifted_spectra(spectra, shift)[source]#

Apply a Doppler shift to spectra.

Parameters:
  • spectra (ndarray, shape (n_pixels, n_wavelength)) – Input spectra.

  • shift (ndarray, shape (n_pixels, n_wavelength)) – Doppler shift for each pixel and wavelength.

Returns:

shifted – Shifted spectra.

Return type:

ndarray

spotter.core.integrated_spectrum(design_matrix, theta, phi, period, radius, wv, spectra, phase, normalize=True)[source]#

Compute the integrated spectrum of a rotating star.

Parameters:
  • design_matrix (array_like) – Flux design matrix for a HEALPix map.

  • theta (array_like) – Colatitude in radians.

  • phi (array_like) – Longitude in radians.

  • period (float) – Rotation period in days.

  • radius (float) – Stellar radius in solar radii.

  • wv (array_like) – Wavelength grid.

  • spectra (ndarray) – Spectra at each pixel.

  • phase (float) – Rotation phase in radians.

  • inc (float) – Inclination in radians.

Returns:

integrated – Integrated spectrum.

Return type:

ndarray