Skip to content

RomanCuts

RomanMachine

Bases: Machine

Subclass of Machine for working with Roman data.

__init__

__init__(
    time: ndarray,
    flux: ndarray,
    flux_err: ndarray,
    ra: ndarray,
    dec: ndarray,
    sources: DataFrame,
    column: ndarray,
    row: ndarray,
    cadenceno: Optional[ndarray] = None,
    wcs: Optional[Any] = None,
    n_r_knots: int = 9,
    n_phi_knots: int = 15,
    cut_r: float = 0.15,
    rmin: float = 0.02,
    rmax: float = 0.8,
    sparse_dist_lim: int = 4,
    quality_mask: Optional[ndarray] = None,
    sources_flux_column: str = "flux",
    sources_mag_column: str = "F146",
    meta: Optional[dict] = None,
    dithered: bool = True,
) -> None

Repeated optional parameters are described in Machine.

Parameters:

  • time (ndarray) –

    Time values in JD

  • flux (ndarray) –

    Flux values at each pixels and times in units of electrons / sec. Has shape [n_times, n_rows, n_columns]

  • flux_err (ndarray) –

    Flux error values at each pixels and times in units of electrons / sec. Has shape [n_times, n_rows, n_columns]

  • ra (ndarray) –

    Right Ascension coordinate of each pixel

  • dec (ndarray) –

    Declination coordinate of each pixel

  • sources (DataFrame) –

    DataFrame with source present in the images

  • column (ndarray) –

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

  • row (ndarray) –

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

  • wcs (wcs, default: None ) –

    World coordinates system solution for the FFI. Used for plotting.

  • quality_mask (ndarray or booleans, default: None ) –

    Boolean array of shape time indicating cadences with bad quality.

  • meta (dictionary, default: None ) –

    Meta data information related to the FFI

Attributes:

  • meta (dictionary) –

    Meta data information related to the FFI

  • wcs (wcs) –

    World coordinates system solution for the FFI. Used for plotting.

  • flux_3d (ndarray) –

    2D image representation of the FFI, used for plotting. Has shape [n_times, image_height, image_width]

  • image_shape (tuple) –

    Shape of 2D image

from_file staticmethod

from_file(
    fname: Union[str, List[str], ndarray],
    cutout_size: int = 32,
    cutout_center: Union[
        Tuple[float, float], Tuple[int, int]
    ] = (0, 0),
    sources: Optional[DataFrame] = None,
    **kwargs,
) -> RomanMachine

Reads data from files and initiates a new object of RomanMachine class. Two options are available: 1. If providing pixel coordinates with cutout_origin, the data will be fixed tothe pixel grid, no dithering correctin will be applied and the star field will move across the image. 2. When providing cutout_center in RA, Dec coordinates, the data will be cetered in the target coordinate and account for dithering. The star field will be fixed, but the pixel grid will change.

Parameters:

  • fname (str or list of strings) –

    File name or list of file names of the FFI files.

  • cutout_size (int, default: 32 ) –

    Size of the cutout in , assumed to be squared

  • cutout_origin (tuple of ints) –

    Origin pixel coordinates where to start the cut out. The cutout will be centered in cutout_origin + cutout_size / 2. Follows matrix indexing.

  • cutout_center (tuple of floats, default: (0, 0) ) –

    Center of the cutout in RA, Dec coordinates. If provided, the cutout will be centered on this position and the pixel grid will be adjusted to account for dithering.

  • sources (DataFrame, default: None ) –

    Catalog with sources to be extracted by PSFMachine

  • **kwargs (dictionary, default: {} ) –

    Keyword arguments that defines shape model in a Machine class object. See psfmachine.Machine for details.

Returns:

  • RomanMachine ( Machine object ) –

    A Machine class object built from the FFI.

build_shape_model

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

Adapted version of machine.build_shape_model() that masks out saturated and bright halo pixels in FFIs. See parameter descriptions in Machine.

save_shape_model

save_shape_model(
    output: Optional[str] = None, save: bool = True
) -> None

Saves the weights of a PRF fit to disk.

Parameters:

  • output ((str, None), default: None ) –

    Output file name. If None, one will be generated.

load_shape_model

load_shape_model(
    input: Optional[str] = None,
    plot: bool = False,
    source_flux_limit: float = 20,
    flux_cut_off: float = 0.01,
) -> Optional[Figure]

Load and process a shape model for the sources.

This method reads a shape model from the specified input source, applies any necessary processing, and optionally generates a diagnostic plot of the shape model. The function may also filter out low-flux pixels based on the provided cutoff value.

Parameters:

  • input (str, default: None ) –

    The path to the shape model file or other input source. If None, defaults to a predefined shape model location.

  • plot (bool, default: False ) –

    Whether to display a diagnostic plot of the loaded shape model. If set to True, the plot will be shown upon loading the model.

  • flux_cut_off (float, default: 0.01 ) –

    The minimum flux value below which sources will be excluded from the model. This can help remove noise or irrelevant data during processing.

Returns:

  • None

    This function does not return any value. It modifies the internal state of the object by loading the shape model and potentially creating plots.

plot_image

plot_image(
    ax: Optional[Axes] = None,
    sources: bool = False,
    frame_index: int = 0,
) -> Axes

Function to plot the Full Frame Image and Gaia sources.

Parameters:

  • ax (axes, default: None ) –

    Matlotlib axis can be provided, if not one will be created and returned.

  • sources (boolean, default: False ) –

    Whether to overplot or not the source catalog.

  • frame_index (int, default: 0 ) –

    Time index used to plot the image data.

Returns:

  • ax ( axes ) –

    Matlotlib axis with the figure.

plot_prf_model

plot_prf_model(
    ax: Optional[Axes] = None, hires: bool = False
) -> Axes

Plot the Point Response Function (PRF) model for the current RomanMachine instance.

This function visualizes the PRF either at high resolution (supersampled) or at the native pixel sampling, depending on the hires flag. The PRF is computed using the spline basis and current PSF weights, and displayed as a color mesh or scatter plot.

Parameters:

  • ax (Optional[Axes], default: None ) –

    Matplotlib axis to plot on. If None, a new figure and axis will be created.

  • hires (bool, default: False ) –

    If True, plot a supersampled PRF model. If False, plot at the native pixel sampling.

Returns:

  • ax ( Axes ) –

    The matplotlib axis containing the PRF plot.

fit_prf_photometry

fit_prf_photometry(
    targets: List[int] = [], model_bkg: bool = True
) -> None

Fits PRF photometry the given targets in the image accounting for backgronund stars and signal.

Parameters:

  • targets (list of int, default: [] ) –

    List of target names to fit PRF photometry for. If None, all sources in

get_lightcurves

get_lightcurves(mode: str = 'lk') -> None

Bundle light curves as lightkurve objects is mode=="lk" or as a DataFrame if `mode=="table"'.

Parameters:

  • mode (str, default: 'lk' ) –

    What type of light curve wil be created