BasePhotometry (photometry.BasePhotometry)

class photometry.BasePhotometry(starid, input_folder, output_folder, datasource='ffi', sector=None, camera=None, ccd=None, plot=False, cache='basic')[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:integer
input_folder

Root directory where files are loaded from.

Type:string
output_folder

Root directory where output files are saved.

Type:string
plot

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

Type:boolean
plot_folder

Directory where plots are saved to.

Type:string
sector

TESS observing sector.

Type:integer
camera

TESS camera (1-4).

Type:integer
ccd

TESS CCD (1-4).

Type:integer
n_readout

Number of frames co-added in each timestamp.

Type:integer
target_mag

TESS magnitude of the main target.

Type:float
target_pos_ra

Right ascension of the main target at time of observation.

Type:float
target_pos_dec

Declination of the main target at time of observation.

Type:float
target_pos_ra_J2000

Right ascension of the main target at J2000.

Type:float
target_pos_dec_J2000

Declination of the main target at J2000.

Type:float
target_pos_column

Main target CCD column position.

Type:flat
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 object
lightcurve

Table to be filled with an extracted lightcurve.

Type:astropy.table.Table object
pixelflags

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

Type:numpy.ndarray
final_mask

Mask indicating which pixels were used in extraction of lightcurve. 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, plot=False, cache='basic')[source]

Initialize the photometry object.

Parameters:
  • starid (int) – TIC number of star to be processed.
  • input_folder (string) – Root directory where files are loaded from.
  • output_folder (string) – Root directory where output files are saved.
  • datasource (string, optional) – Source of the data. Options are 'ffi' or 'tpf'. Default is 'ffi'.
  • plot (boolean, optional) – Create plots as part of the output. Default is False.
  • camera (integer, optional) – TESS camera (1-4) to load target from (Only used for FFIs).
  • ccd (integer, optional) – TESS CCD (1-4) to load target from (Only used for FFIs).
  • cache (string, optional) – Optional values are 'none', 'full' or 'basic' (Default).
Raises:
  • IOError – If starid could not be found in catalog.
  • 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 self.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)[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.
Returns:

True if the stamp could be resized, False otherwise.

Return type:

bool

save_lightcurve(output_folder=None, version=4)[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.
  • data_rel (integer, optional) – Data release number to put in FITS header.
Returns:

Path to the generated file.

Return type:

string

MovementKernel

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

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
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)
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)
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()

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)
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)
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)
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)
pixelflags

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)
pixelflags_cube

Cube containing all the 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.backgrounds_cube.shape):
>>>   (10, 10, 1399)
stamp

Tuple indicating the stamps position within the larger image.

Returns:Tuple of (row_min, row_max, col_min, col_max).
Return type:tuple
status

The status of the photometry. From STATUS.

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[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?