BasePhotometry (photometry.BasePhotometry)

class photometry.BasePhotometry(starid, input_folder, output_folder, datasource='ffi', sector=None, camera=None, ccd=None, cadence=None, plot=False, cache='basic', version=6)[source]

The basic photometry class for the TASOC Photometry pipeline. All other specific photometric algorithms will inherit from this.

starid

TIC number of star being processed.

Type:

int

input_folder

Root directory where files are loaded from.

Type:

str

output_folder

Root directory where output files are saved.

Type:

str

plot

Indicates wheter plots should be created as part of the output.

Type:

bool

plot_folder

Directory where plots are saved to.

Type:

str

method

String indication the method of photometry.

Type:

str

sector

TESS observing sector.

Type:

int

camera

TESS camera (1-4).

Type:

int

ccd

TESS CCD (1-4).

Type:

int

data_rel

Data release number.

Type:

int

n_readout

Number of frames co-added in each timestamp.

Type:

int

header

Primary header, either from TPF or HDF5 files.

Type:

dict-like

target

Catalog information about the main target.

Type:

dict

target_pos_column

Main target CCD column position.

Type:

float

target_pos_row

Main target CCD row position.

Type:

float

target_pos_column_stamp

Main target CCD column position in stamp.

Type:

float

target_pos_row_stamp

Main target CCD row position in stamp.

Type:

float

wcs

World Coordinate system solution.

Type:

astropy.wcs.WCS

lightcurve

Table to be filled with an extracted lightcurve.

Type:

astropy.table.Table

final_phot_mask

Mask indicating which pixels were used in extraction of lightcurve. True if used, False otherwise.

Type:

numpy.ndarray

final_position_mask

Mask indicating which pixels were used in extraction of positions. True if used, False otherwise.

Type:

numpy.ndarray

additional_headers

Additional headers to be included in FITS files.

Type:

dict

Code author: Rasmus Handberg <rasmush@phys.au.dk>

__init__(starid, input_folder, output_folder, datasource='ffi', sector=None, camera=None, ccd=None, cadence=None, plot=False, cache='basic', version=6)[source]

Initialize the photometry object.

Parameters:
  • starid (int) – TIC number of star to be processed.

  • input_folder (str) – Root directory where files are loaded from.

  • output_folder (str) – Root directory where output files are saved.

  • datasource (str) – Source of the data. Options are 'ffi' or 'tpf'. Default is 'ffi'.

  • plot (bool) – Create plots as part of the output. Default is False.

  • camera (int) – TESS camera (1-4) to load target from (Only used for FFIs).

  • ccd (int) – TESS CCD (1-4) to load target from (Only used for FFIs).

  • cadence (int, optional) – Not used for datasource='ffi'.

  • cache (str) – Optional values are 'none', 'full' or 'basic' (Default).

  • version (int) – Data release number to be added to headers. Default=6.

Raises:
  • Exception – If starid could not be found in catalog.

  • FileNotFoundError – If input file (HDF5, TPF, Catalog) could not be found.

  • ValueError – On invalid datasource.

  • ValueError – If camera and ccd is not provided together with datasource='ffi'.

catalog_attime(time)[source]

Catalog of stars, calculated at a given time-stamp, so CCD positions are modified according to the measured spacecraft jitter.

Parameters:

time (float) – Time in MJD when to calculate catalog.

Returns:

Table with the same columns as catalog(),

but with column, row, column_stamp and row_stamp calculated at the given timestamp.

Return type:

astropy.table.Table

See also

catalog()

clear_cache()[source]

Clear internal cache

close()[source]

Close photometry object and close all associated open file handles.

default_stamp()[source]

The default size of the stamp to use.

The stamp will be centered on the target star position, with a width and height specified by this function. The stamp can later be resized using resize_stamp().

Returns:

Number of rows int: Number of columns

Return type:

int

Note

This function is only used for FFIs. For postage stamps the default stamp is the entire available postage stamp.

See also

resize_stamp()

delete_plots()[source]

Delete all files in plot_folder.

If plotting is not enabled, this method does nothing and will therefore leave any existing files in the plot folder, should it already exists.

do_photometry()[source]

Run photometry algorithm.

This should fill the lightcurve table with all relevant parameters.

Returns:

The status of the photometry.

Raises:

NotImplementedError

get_pixel_grid()[source]

Returns mesh-grid of the pixels (1-based) in the stamp.

Returns:

Meshgrid of pixel coordinates in the current stamp.

Return type:

tuple(cols, rows)

photometry(*args, **kwargs)[source]

Run photometry.

Will run the do_photometry() method and check some of the output and calculate various performance metrics.

See also

do_photometry()

report_details(error=None, skip_targets=None)[source]

Report details of the processing back to the overlying scheduler system.

Parameters:
  • error (string) – Error message the be logged with the results.

  • skip_targets (list) – List of starids that can be safely skipped.

resize_stamp(down=None, up=None, left=None, right=None, width=None, height=None)[source]

Resize the stamp in a given direction.

Parameters:
  • down (int, optional) – Number of pixels to extend downwards.

  • up (int, optional) – Number of pixels to extend upwards.

  • left (int, optional) – Number of pixels to extend left.

  • right (int, optional) – Number of pixels to extend right.

  • width (int, optional) – Set the width of the stamp to this number of pixels. This takes presendence over left and right if they are also provided.

  • height (int, optional) – Set the height of the stamp to this number of pixels. This takes presendence over up and down if they are also provided.

Returns:

True if the stamp could be resized, False otherwise.

Return type:

bool

save_lightcurve(output_folder=None, version=None)[source]

Save generated lightcurve to file.

Parameters:
  • output_folder (string, optional) – Path to directory where to save lightcurve. If None the directory specified in the attribute output_folder is used.

  • version (integer, optional) – Version number to add to the FITS header and file name. If not set, the version is used.

Returns:

Path to the generated file.

Return type:

string

property MovementKernel

Movement Kernel which allows calculation of positions on the focal plane as a function of time. Instance of image_motion.ImageMovementKernel.

property aperture

Flags for each pixel, as defined by the TESS data product manual.

Returns:

2D array of flags for each pixel.

Return type:

numpy.array

property backgrounds

Iterator that will loop through the background-image stamps.

Returns:

Iterator which can be used to loop through the background-image stamps.

Return type:

iterator

Note

For each image, this function will actually load the necessary data from disk, so don’t loop through it more than you absolutely have to to save I/O.

Example

>>> pho = BasePhotometry(starid)
>>> for img in pho.backgrounds:
>>>     print(img)
property backgrounds_cube

Image cube containing all the background images as a function of time.

Returns:

Three dimentional array with shape (rows, cols, times), where

rows is the number of rows in the image, cols is the number of columns and times is the number of timestamps.

Return type:

ndarray

Example

>>> pho = BasePhotometry(starid)
>>> print(pho.backgrounds_cube.shape):
>>>   (10, 10, 1399)
property catalog

Catalog of stars in the current stamp.

The table contains the following columns: * starid: TIC identifier. * tmag: TESS magnitude. * ra: Right ascension in degrees at time of observation. * dec: Declination in degrees at time of observation. * row: Pixel row on CCD. * column: Pixel column on CCD. * row_stamp: Pixel row relative to the stamp. * column_stamp: Pixel column relative to the stamp.

Returns:

Table with all known stars falling within the current stamp.

Return type:

astropy.table.Table

Example

If pho is an instance of BasePhotometry:

>>> pho.catalog['tmag']
>>> pho.catalog[('starid', 'tmag', 'row', 'column')]

See also

catalog_attime()

property images

Iterator that will loop through the image stamps.

Returns:

Iterator which can be used to loop through the image stamps.

Return type:

iterator

Note

The images has had the large-scale background subtracted. If needed the backgrounds can be added again from backgrounds().

Note

For each image, this function will actually load the necessary data from disk, so don’t loop through it more than you absolutely have to to save I/O.

Example

>>> pho = BasePhotometry(starid)
>>> for img in pho.images:
>>>     print(img)
property images_cube

Image cube containing all the images as a function of time.

Returns:

Three dimentional array with shape (rows, cols, times), where

rows is the number of rows in the image, cols is the number of columns and times is the number of timestamps.

Return type:

ndarray

Note

The images has had the large-scale background subtracted. If needed the backgrounds can be added again from backgrounds() or backgrounds_cube().

Example

>>> pho = BasePhotometry(starid)
>>> print(pho.images_cube.shape)
>>>   (10, 10, 1399)
property images_err

Iterator that will loop through the uncertainty image stamps.

Returns:

Iterator which can be used to loop through the uncertainty image stamps.

Return type:

iterator

Example

>>> pho = BasePhotometry(starid)
>>> for imgerr in pho.images_err:
>>>     print(imgerr)
property images_err_cube

Image cube containing all the uncertainty images as a function of time.

Returns:

Three dimentional array with shape (rows, cols, times), where

rows is the number of rows in the image, cols is the number of columns and times is the number of timestamps.

Return type:

ndarray

Example

>>> pho = BasePhotometry(starid)
>>> print(pho.images_err_cube.shape)
>>>   (10, 10, 1399)
property pixelflags

Iterator that will loop through the pixel flag images.

Returns:

Iterator which can be used to loop through the pixel flags images.

Return type:

iterator

Example

>>> pho = BasePhotometry(starid)
>>> for img in pho.pixelflags:
>>>     print(img)
property pixelflags_cube

Cube containing all pixel flag images as a function of time.

Returns:

Three dimentional array with shape (rows, cols, ffi_times), where

rows is the number of rows in the image, cols is the number of columns and ffi_times is the number of timestamps in the FFIs.

Return type:

ndarray

Note

This function will only return flags on the timestamps of the FFIs, even though an TPF is being processed.

Example

>>> pho = BasePhotometry(starid)
>>> print(pho.pixelflags_cube.shape):
>>>   (10, 10, 1399)
property psf

Point Spread Function.

Returns:

PSF object for the given target position.

Return type:

psf.PSF

See also

psf.PSF

property settings

Pipeline settings and constants.

Returns:

Pipeline settings, loaded from settings file.

Return type:

configparser.ConfigParser

See also

load_settings().

property stamp

Tuple indicating the stamps position within the larger image.

Returns:

Tuple of (row_min, row_max, col_min, col_max).

Return type:

tuple

property status

The status of the photometry. From STATUS.

property sumimage

Average image.

Calculated as the mean of all good images (quality=0) as a function of time. For FFIs this has been pre-calculated and for postage-stamps it is calculated on-the-fly when needed.

Returns:

Summed image across all valid timestamps.

Return type:

numpy.array

Photometry Status (photometry.STATUS)

class photometry.STATUS(value)[source]

Status indicator of the status of the photometry.

ABORT = 4

The calculation was aborted.

ERROR = 2

Encountered a catastrophic error that I could not recover from.

OK = 1

Everything has gone well.

SKIPPED = 5

The target was skipped because the algorithm found that to be the best solution.

STARTED = 6

The calculation has started, but not yet finished.

UNKNOWN = 0

The status is unknown. The actual calculation has not started yet.

WARNING = 3

Something is a bit fishy. Maybe we should try again with a different algorithm?