Utilities (photometry.utilities)

Collection of utility functions that can be used throughout the photometry package.

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

photometry.utilities.add_proper_motion(ra, dec, pm_ra, pm_dec, bjd, epoch=2000.0)[source]

Project coordinates (ra,dec) with proper motions to new epoch.

Parameters:
  • ra (float) – Right ascension.
  • dec (float) – Declination.
  • pm_ra (float) – Proper motion in RA (mas/year).
  • pm_dec (float) – Proper motion in Declination (mas/year).
  • bjd (float) – Julian date to calculate coordinates for.
  • epoch (float, optional) – Epoch of ra and dec. Default=2000.
Returns:

RA and Declination at the specified date.

Return type:

(float, float)

photometry.utilities.cartesian_to_radec(xyz)[source]

Convert cartesian coordinates (x,y,z) to spherical coordinates in ra-dec form.

Parameters:radec (ndarray) – Array with ra-dec pairs.
Returns:ra-dec coordinates in degrees corresponding to input coordinates.
Return type:ndarray
photometry.utilities.find_catalog_files(rootdir, sector=None, camera=None, ccd=None)[source]

Search the input directory for CATALOG (sqlite) files matching constraints.

Parameters:
  • rootdir (string) – Directory to search for CATALOG files.
  • sector (integer, list or None, optional) – Only return files from the given sectors. If None, files from all TIC numbers are returned.
  • camera (integer, list or None, optional) – Only return files from the given camera. If None, files from all cameras are returned.
  • ccd (integer, list or None, optional) – Only return files from the given ccd. If None, files from all ccds are returned.
Returns:

List of paths to CATALOG files matching constraints.

Return type:

list

photometry.utilities.find_ffi_files(rootdir, sector=None, camera=None, ccd=None)[source]

Search directory recursively for TESS FFI images in FITS format.

Parameters:
  • rootdir (string) – Directory to search recursively for TESS FFI images.
  • sector (integer or None, optional) – Only return files from the given sector. If None, files from all sectors are returned.
  • camera (integer or None, optional) – Only return files from the given camera number (1-4). If None, files from all cameras are returned.
  • ccd (integer or None, optional) – Only return files from the given CCD number (1-4). If None, files from all CCDs are returned.
Returns:

List of full paths to FFI FITS files found in directory. The list will

be sorted accoridng to the filename of the files, e.g. primarily by time.

Return type:

list

photometry.utilities.find_hdf5_files(rootdir, sector=None, camera=None, ccd=None)[source]

Search the input directory for HDF5 files matching constraints.

Parameters:
  • rootdir (string) – Directory to search for HDF5 files.
  • sector (integer, list or None, optional) – Only return files from the given sectors. If None, files from all TIC numbers are returned.
  • camera (integer, list or None, optional) – Only return files from the given camera. If None, files from all cameras are returned.
  • ccd (integer, list or None, optional) – Only return files from the given ccd. If None, files from all ccds are returned.
Returns:

List of paths to HDF5 files matching constraints.

Return type:

list

photometry.utilities.find_nearest(array, value)[source]

Search array for value and return the index where the value is closest.

Parameters:
  • array (ndarray) – Array to search.
  • value – Value to search array for.
Returns:

Index of array closest to value.

Return type:

int

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

photometry.utilities.find_tpf_files(rootdir, starid=None, sector=None)[source]

Search directory recursively for TESS Target Pixel Files.

Parameters:
  • rootdir (string) – Directory to search recursively for TESS TPF files.
  • starid (integer or None, optional) – Only return files from the given TIC number. If None, files from all TIC numbers are returned.
  • sector (integer or None, optional) – Only return files from the given sector. If None, files from all sectors are returned.
Returns:

List of full paths to TPF FITS files found in directory. The list will

be sorted accoriding to the filename of the files, e.g. primarily by time.

Return type:

list

photometry.utilities.integratedGaussian(x, y, flux, x_0, y_0, sigma=1)[source]

Evaluate a 2D symmetrical Gaussian integrated in pixels.

Parameters:
  • x (numpy array) – x coordinates at which to evaluate the PSF.
  • y (numpy array) – y coordinates at which to evaluate the PSF.
  • flux (float) – Integrated value.
  • x_0 (float) – Centroid position.
  • y_0 (float) – Centroid position.
  • sigma (float, optional) – Standard deviation of Gaussian. Default=1.
Returns:

2D Gaussian integrated pixel values at (x,y).

Return type:

numpy array

Example:

>>> import numpy as np
>>> X, Y = np.meshgrid(np.arange(-1,2), np.arange(-1,2))
>>> integratedGaussian(X, Y, 10, 0, 0)
array([[ 0.58433556,  0.92564571,  0.58433556],
        [ 0.92564571,  1.46631496,  0.92564571],
        [ 0.58433556,  0.92564571,  0.58433556]])
photometry.utilities.load_ffi_fits(path, return_header=False, return_uncert=False)[source]

Load FFI FITS file.

Calibrations columns and rows are trimmed from the image.

Parameters:
  • path (str) – Path to FITS file.
  • return_header (boolean, optional) – Return FITS headers as well. Default is False.
Returns:

Full Frame Image. list: If return_header is enabled, will return a dict of the FITS headers.

Return type:

numpy.ndarray

photometry.utilities.load_settings(sector=None)[source]
photometry.utilities.mag2flux(mag)[source]

Convert from magnitude to flux using scaling relation from aperture photometry. This is an estimate.

The scaling is based on fast-track TESS data from sectors 1 and 2.

Parameters:mag (float) – Magnitude in TESS band.
Returns:Corresponding flux value
Return type:float
photometry.utilities.move_median_central(x, width_points, axis=0)[source]
photometry.utilities.radec_to_cartesian(radec)[source]

Convert spherical coordinates as (ra, dec) pairs to cartesian coordinates (x,y,z).

Parameters:radec (ndarray) – Array with ra-dec pairs in degrees.
Returns:(x,y,z) coordinates corresponding to input coordinates.
Return type:ndarray
photometry.utilities.rms_timescale(time, flux, timescale=0.041666666666666664)[source]

Compute robust RMS on specified timescale. Using MAD scaled to RMS.

Parameters:
  • time (ndarray) – Timestamps in days.
  • flux (ndarray) – Flux to calculate RMS for.
  • timescale (float, optional) – Timescale to bin timeseries before calculating RMS. Default=1 hour.
Returns:

Robust RMS on specified timescale.

Return type:

float

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

photometry.utilities.sphere_distance(ra1, dec1, ra2, dec2)[source]

Calculate the great circle distance between two points using the Vincenty formulae.

Parameters:
  • ra1 (float or ndarray) – Longitude of first point in degrees.
  • dec1 (float or ndarray) – Lattitude of first point in degrees.
  • ra2 (float or ndarray) – Longitude of second point in degrees.
  • dec2 (float or ndarray) – Lattitude of second point in degrees.
Returns:

Distance between points in degrees.

Return type:

ndarray

photometry.utilities.mad_to_sigma = 1.482602218505602

Constant for converting from MAD to SIGMA. Constant is 1/norm.ppf(3/4)