tesscube API#

class tesscube.cube.TESSCube(sector: int, camera: int, ccd: int)[source]#

A class to obtain portions of TESS data cubes from MAST’s AWS bucket.

This class provides methods to efficiently retrieve specific portions of TESS (Transiting Exoplanet Survey Satellite) FFI data cubes, enabling users to extract and analyze the desired segments of data.

Parameters:
  • sector (int) – The TESS observation sector number.

  • camera (int) – The camera number (1-4).

  • ccd (int) – The CCD number (1-4).

property cadence_number#

Cadence number for each frame. Note this is not the same as the SPOC provided cadence numbers.

property exposure_time#

Exposure time in days

property ffi_names#

The FFI names used to make the cube.

static from_skycoord(coord: SkyCoord, sector: int)[source]#

Create a TESSCube object from a SkyCoord object.

This method identifies the appropriate TESS cube that contains the given SkyCoord and returns a TESSCube object.

Parameters:
  • coord (SkyCoord) – The celestial coordinates of the target.

  • sector (int) – The TESS observation sector number.

Returns:

The TESSCube object containing the specified coordinates.

Return type:

TESSCube

get_ffi(index: int | None = None, time: Time | None = None, ffi_name: str | None = None, raw: bool = False) HDUList[source]#

Retrieve a Full-Frame Image (FFI) from the data cube.

One of time, index, or ffi_name must be provided to identify the FFI. This method caches up to 4 FFIs for efficient reuse.

Parameters:
  • index (int, optional) – The index of the FFI to retrieve.

  • time (astropy.time.Time, optional) – The time at which the FFI was captured.

  • ffi_name (str, optional) – The name of the FFI file.

  • raw (bool, optional) – Whether to retrieve the raw FFI (default is False).

Returns:

The HDUList containing the FFI data.

Return type:

astropy.io.fits.HDUList

get_tpf(target: tuple | SkyCoord = (1014, 1014), shape: tuple = (20, 21), frame_range: tuple | None = None, frame_bin: int = 1, calculate_poscorr=True) HDUList[source]#

Retrieve a Target Pixel File (TPF) from the data cube.

The TPF contains the flux data for a specific target region, defined by either pixel coordinates or a SkyCoord object. The data can be binned over multiple frames (cadences) using frame_bin.

Parameters:
  • target (tuple or SkyCoord, optional) – The (row, column) coordinates or a SkyCoord object for the target region.

  • shape (tuple of int, optional) – The (number of rows, number of columns) shape of the target region.

  • frame_range (tuple of int, optional) – The (start, end) frame range to retrieve the data.

  • frame_bin (int, optional) – The number of frames to bin together (default is 1, i.e. no binning).

  • calculate_poscorr (bool) – Whether to calculate the POS_CORR columns. These are present in SPOC data but not present in some HLSPs. This takes extra time to calculate, but provides extra position information. Setting to False will result in POS_CORR1 and POS_CORR2 being set to zero.

Returns:

The HDUList containing the TPF data.

Return type:

astropy.io.fits.HDUList

property header_dict: Dict#

Get the header keywords from the MAST cube.

Returns:

A dictionary of header keywords from the MAST cube.

Return type:

dict

property last_hdu#

The last HDU of the cube file.

property primary_hdu#

The primary HDU of the cube file.

property quality#

SPOC provided quality flags for each cadence.

property time#

Time of the frames in BTJD. Note this is the time at the center of the FFI.

property timecorr#

Barycentric time correction for the center of the FFI.

Mixin class to enable queries. This is in a separate class for readability.

async tesscube.query.async_get_ffi(ffi_name: str) HDUList[source]#

Asynchronously retrieves a full-frame image (FFI) FITS file.

Parameters:

ffi_name (str) – The name of the full-frame image (FFI) as stored in s3.

Returns:

The HDU list of the retrieved FFI FITS file.

Return type:

astropy.io.fits.HDUList

async tesscube.query.async_get_last_hdu(object_key: str, end: int) PrimaryHDU[source]#

Asynchronously retrieves the last HDU of a cube FITS file.

Parameters:
  • object_key (str) – The S3 object key of the FITS file (i.e. the file name)

  • end (int) – The byte position to start retrieving data from.

Returns:

The last HDU of the FITS file.

Return type:

astropy.io.fits.PrimaryHDU

async tesscube.query.async_get_primary_hdu(object_key: str) PrimaryHDU[source]#

Asynchronously retrieves the primary HDU of a cube FITS file.

Parameters:

object_key (str) – The S3 object key of the FITS file (i.e. the file name)

Returns:

The primary HDU of the FITS file, with corrected headers.

Return type:

astropy.io.fits.PrimaryHDU

Utilities to help work with cube data

tesscube.utils.convert_coordinates_to_runs(coordinates: List[Tuple[int, int]]) List[Tuple[int, int, int]][source]#

Converts a list of (row, column) coordinates to a list of (start_row, end_row, column) coordinates.

tesscube.utils.convert_to_native_types(obj)[source]#

Recursively convert objects in a data structure to native Python types. Handles dictionaries, lists, and NumPy data types.