Skip to content

RomanCuts

Machine

Bases: object

Class for calculating fast PRF photometry on a collection of images and a list of in image sources.

This method is discussed in detail in Hedges et al. 2021.

This method solves a linear model to assuming Gaussian priors on the weight of each linear components as explained by Luger, Foreman-Mackey & Hogg, 2017

__init__

__init__(
    time: ArrayLike,
    flux: ArrayLike,
    flux_err: ArrayLike,
    ra: ArrayLike,
    dec: ArrayLike,
    sources: DataFrame,
    column: ArrayLike,
    row: ArrayLike,
    time_mask: Optional[ArrayLike] = None,
    n_r_knots: int = 10,
    n_phi_knots: int = 15,
    rmin: float = 0.1,
    rmax: float = 2,
    cut_r: float = 0.2,
    sparse_dist_lim: float = 4,
    sources_flux_column: str = "flux",
) -> None

Parameters:

  • time (ArrayLike) –

    Time values in JD

  • flux (ArrayLike) –

    Flux values at each pixels and times in units of electrons / sec

  • flux_err (ArrayLike) –

    Flux error values at each pixels and times in units of electrons / sec

  • ra (ArrayLike) –

    Right Ascension coordinate of each pixel

  • dec (ArrayLike) –

    Declination coordinate of each pixel

  • sources (DataFrame) –

    DataFrame with source present in the images

  • column (ArrayLike) –

    Data array containing the "columns" of the detector that each pixel is on.

  • row (ArrayLike) –

    Data array containing the "rows" of the detector that each pixel is on.

  • time_mask (Optional[ArrayLike], default: None ) –

    A boolean array of shape time. Only values where this mask is True will be used to calculate the average image for fitting the PSF. Use this to e.g. select frames with low VA, or no focus change

  • n_r_knots (int, default: 10 ) –

    Number of radial knots in the spline model.

  • n_phi_knots (int, default: 15 ) –

    Number of azimuthal knots in the spline model.

  • time_nknots

    Number og knots for cartesian DM in time model.

  • time_resolution

    Number of time points to bin by when fitting for velocity aberration.

  • time_radius

    The radius around sources, out to which the velocity aberration model will be fit. (arcseconds)

  • rmin (float, default: 0.1 ) –

    The minimum radius for the PRF model to be fit. (arcseconds)

  • rmax (float, default: 2 ) –

    The maximum radius for the PRF model to be fit. (arcseconds)

  • cut_r (float, default: 0.2 ) –

    Radius distance whithin the shape model only depends on radius and not angle.

  • sparse_dist_lim (float, default: 4 ) –

    Radial distance used to include pixels around sources when creating delta arrays (dra, ddec, r, and phi) as sparse matrices for efficiency. Default is 40" (recommended for kepler). (arcseconds)

  • sources_flux_column (str, default: 'flux' ) –

    Column name in sources table to be used as flux estimate. For Kepler data gaia.phot_g_mean_flux is recommended, for TESS use gaia.phot_rp_mean_flux.

Attributes:

  • nsources (int) –

    Number of sources to be extracted

  • nt (int) –

    Number of onservations in the time series (aka number of cadences)

  • npixels (int) –

    Total number of pixels with flux measurements

  • source_flux_estimates (ndarray) –

    First estimation of pixel fluxes assuming values given by the sources catalog (e.g. Gaia phot_g_mean_flux)

  • dra (ndarray) –

    Distance in right ascension between pixel and source coordinates, units of degrees

  • ddec (ndarray) –

    Distance in declination between pixel and source coordinates, units of degrees

  • r (ndarray) –

    Radial distance between pixel and source coordinates (polar coordinates), in units of arcseconds

  • phi (ndarray) –

    Angle between pixel and source coordinates (polar coordinates), in units of radians

  • source_mask (csr_matrix) –

    Sparce mask matrix with pixels that contains flux from sources

  • uncontaminated_source_mask (csr_matrix) –

    Sparce mask matrix with selected uncontaminated pixels per source to be used to build the PSF model

  • mean_model (csr_matrix) –

    Mean PSF model values per pixel used for PSF photometry

  • cartesian_knot_spacing (string) –

    Defines the type of spacing between knots in cartessian space to generate the design matrix, options are "linear" or "sqrt".

  • quiet (booleans) –

    Quiets TQDM progress bars.

  • contaminant_flux_limit (float) –

    The limiting magnitude at which a sources is considered as contaminant

build_shape_model

build_shape_model(
    flux_cut_off: float = 1,
    frame_index: Union[str, int] = 0,
    bin_data: int = 0,
    plot: bool = False,
    **kwargs,
) -> Optional[Any]

Builds a sparse model matrix of shape nsources x npixels to be used when fitting each source pixels to estimate its PSF photometry

Parameters:

  • flux_cut_off (float, default: 1 ) –

    the flux in COUNTS at which to stop evaluating the model!

  • frame_index (string or int, default: 0 ) –

    The frame index used to build the shape model. If "mean" then use the mean value across time, this won't work if images are dittered

  • bin_data (boolean, default: 0 ) –

    Bin flux data spatially to increase SNR before fitting the shape model

  • plot (boolean, default: False ) –

    Make a diagnostic plot

  • **kwargs

    Keyword arguments to be passed to _get_source_mask()

plot_shape_model

plot_shape_model(
    frame_index: Union[str, int] = "mean",
    bin_data: bool = False,
    clean: bool = True,
) -> Any

Diagnostic plot of shape model.

Parameters:

  • frame_index (string or int, default: 'mean' ) –

    The frame index used to plot the shape model, if "mean" then use the mean value across time

  • bin_data (bool, default: False ) –

    Bin or not the pixel data in a 2D historgram, default is False.

Returns:

  • fig ( Figure ) –

    Figure.

get_psf_metrics

get_psf_metrics(npoints_per_pixel: int = 10) -> None

Computes three metrics for the PSF model: source_psf_fraction: the amount of PSF in the data. Tells how much of a sources is used to estimate the PSF, values are in between [0, 1]. perturbed_ratio_mean: the ratio between the mean model and perturbed model for each source. Usefull to find when the time model affects the mean value of the light curve. perturbed_std: the standard deviation of the perturbed model for each source. USeful to find when the time model introduces variability in the light curve.

If npoints_per_pixel > 0, it creates high npoints_per_pixel shape models for each source by dividing each pixels into a grid of [npoints_per_pixel x npoints_per_pixel]. This provides a better estimate of source_psf_fraction.

Parameters:

  • npoints_per_pixel (int, default: 10 ) –

    Value in which each pixel axis is split to increase npoints_per_pixel. Default is 0 for no subpixel npoints_per_pixel.

fit_model

fit_model(
    prior_mu: Optional[ndarray] = None,
    prior_sigma: Optional[ndarray] = None,
    compute_model: bool = False,
) -> None

Finds the best fitting weights for every source simultaneously