PSF Photometry (photometry.PSFPhotometry)

Created on Wed Nov 8 16:37:12 2017

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

class photometry.PSFPhotometry(*args, **kwargs)[source]

Bases: photometry.BasePhotometry.BasePhotometry

__init__(*args, **kwargs)[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)

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

Clear internal cache

close()

Close photometry object and close all associated open file handles.

default_stamp()

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

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]

PSF Photometry

get_pixel_grid()

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)

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)

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)

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)

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