eleanor.targetdata
index
/home/dinilbose/github/eleanor/eleanor/targetdata.py

 
Modules
       
astropy.coordinates
copy
eleanor
astropy.io.fits
lightkurve.lightcurve
numpy
os
pickle
matplotlib.pyplot
sys
astropy.time
astropy.units
warnings

 
Classes
       
builtins.object
TargetData

 
class TargetData(builtins.object)
    Object containing the light curve, target pixel file, and related information
for any given source.
 
Parameters
----------
source : eleanor.Source
    The source object to use.
height : int, optional
    Height in pixels of TPF to retrieve. Default value is 13 pixels. Must be an odd number,
    or else will return an aperture one pixel taller than requested so target
    falls on central pixel.
width : int, optional
    Width in pixels of TPF to retrieve. Default value is 13 pixels. Must be an odd number,
    or else will return an aperture one pixel wider than requested so target
    falls on central pixel.
bkg_size : int, optional
    Size of box to use for background estimation. If not set, will default to the width of the 
    target pixel file.
crowded_field : bool, optional
    If true, will return a light curve built using a small aperture (not more than 8 pixels in size).
do_pca : bool, optional
    If true, will return a PCA-corrected light curve.
do_psf : bool, optional
    If true, will return a light curve made with a simple PSF model.
cal_cadences : tuple, optional
    Start and end cadence numbers to use for optimal aperture selection.
try_load: bool, optional
    If true, will search hidden ~/.eleanor directory to see if TPF has already
    been created. 
 
Attributes
----------
header : dict
    FITS header for saving/loading data.
source_info : eleanor.Source
    Pointer to input source.
aperture :
    Aperture to use if overriding default. To use default, set to `None`.
tpf : np.ndarray
    Target pixel file of fluxes; array with shape `dimensions`.
time : np.ndarray
    Time series.
post_obj : eleanor.Postcard
    Pointer to Postcard objects containing this TPF.
pointing_model : astropy.table.Table
    Table of matrices describing the transformation matrix from FFI default
    WCS and eleanor's corrected pointing.
tpf_err : np.ndarray
    Errors on fluxes in `tpf`.
centroid_xs : np.ndarray
    Position of the source in `x` inferred from pointing model; has same length as `time`.
    Position is relative to the pixel coordinate system of the postcard.
centroid_ys : np.ndarray
    Position of the source in `y` inferred from pointing model; has same length as `time`.
    Position is relative to the pixel coordinate system of the postcard.
cen_x : int
    Median `x` position of the source.
    Position is relative to the pixel coordinate system of the postcard.
cen_y : int
    Median `y` position of the source.
    Position is relative to the pixel coordinate system of the postcard.
tpf_star_x : int
    `x` position of the star on the TPF.
    Position is relative to the size of the TPF.
tpf_star_y : int
    `y` position of the star on the TPF.
    Position is relative to the size of the TPF.
dimensions : tuple
    Shape of `tpf`. Should be (`time`, `height`, `width`).
all_apertures : list
    List of aperture objects.
aperture : array-like
    Chosen aperture for producing `raw_flux` lightcurve. Format is array
    with shape (`height`, `width`). All entries are floats in range [0,1].
all_flux_err : np.ndarray
    Estimated uncertainties on `all_raw_flux`.
all_raw_flux : np.ndarray
    All lightcurves extracted using `all_apertures`.
    Has shape (N_apertures, N_time).
all_corr_flux : np.ndarray
    All systematics-corrected lightcurves. See `all_raw_flux`.
best_ind : int
    Index into `all_apertures` producing the best (least noisy) lightcurve.
corr_flux : np.ndarray
    Systematics-corrected version of `raw_flux`.
flux_err : np.ndarray
    Estimated uncertainty on `raw_flux`.
raw_flux : np.ndarray
    Un-systematics-corrected lightcurve derived using `aperture` and `tpf`.
x_com : np.ndarray
    Position of the source in `x` inferred from TPF; has same length as `time`.
    Position is relative to the pixel coordinate system of the TPF.
y_com : np.ndarray
    Position of the source in `y` inferred from TPF; has same length as `time`.
    Position is relative to the pixel coordinate system of the TPF.
quality : int
    Quality flag.
 
Notes
-----
`save()` and `load()` methods write/read these data to a FITS file with format:
 
Extension[0] = header
 
Extension[1] = (N_time, height, width) TPF, where n is the number of cadences in an observing run
 
Extension[2] = (3, N_time) time, raw flux, systematics corrected flux
 
  Methods defined here:
__init__(self, source, height=13, width=13, save_postcard=True, do_pca=False, do_psf=False, bkg_size=None, crowded_field=False, cal_cadences=None, try_load=True, language='English')
Initialize self.  See help(type(self)) for accurate signature.
bkg_subtraction(self, scope='tpf', sigma=2.5)
Subtracts background flux from target pixel file.
 
Parameters
----------
scope : string, "tpf" or "postcard"
    If `tpf`, will use data from the target pixel file only to estimate and remove the background.
    If `postcard`, will use data from the entire postcard region to estimate and remove the background.
sigma : float
    The standard deviation cut used to determine which pixels are representative of the background in each cadence.
center_of_mass(self)
Calculates the position of the source across all cadences using `muchbettermoments` and `self.best_aperture`.
 
Finds the brightest pixel in a (`height`, `width`) region summed up over all cadence.
Searches a smaller (3x3) region around this pixel at each cadence and uses `muchbettermoments` to find the maximum.
corrected_flux(self, flux=None, skip=30, modes=3, pca=False, bkg=None)
Corrects for jitter in the light curve by quadratically regressing with centroid position.
Parameters
----------
skip: int
    The number of cadences at the start of each orbit to skip in determining optimal model weights.
create_apertures(self, height, width)
Creates a range of sizes and shapes of apertures to test.
custom_aperture(self, shape=None, r=0.0, h=0.0, w=0.0, theta=0.0, pos=None, method='exact')
Creates a custom circular or rectangular aperture of arbitrary size.
 
Parameters
----------
shape: str, optional
    The shape of the aperture to be used. Must be either `circle` or `rectangle.`
r: float, optional
    If shape is `circle` the radius of the circular aperture to be used.
h: float, optional
    If shape is `rectangle` the length of the rectangular aperture to be used.
w: float, optional
    If shape is `rectangle` the width of the rectangular aperture to be used.
theta: float, optional
    If shape is `rectangle` the rotation of the rectangle relative to detector coordinate.
    Uses units of radians.
pos: tuple, optional
    The center of the aperture, in TPF coordinates. If not set, defaults to the center of the TPF.
method: str, optional
    The method of producing a light curve to be used, either `exact`, `center`, or `subpixel`.
    Passed through to photutils and used as intended by that package.
fetch_dir(self)
Returns the default path to the directory where files will be saved
or loaded.
 
By default, this method will return "~/.eleanor" and create
this directory if it does not exist.  If the directory cannot be
access or created, then it returns the local directory (".").
 
Returns
-------
download_dir : str
    Path to location of `ffi_dir` where FFIs will be downloaded
find_break(self)
get_cbvs(self)
Obtains the cotrending basis vectors (CBVs) as convolved down from the short-cadence targets.
Parameters
----------
get_lightcurve(self, aperture=None)
Extracts a light curve using the given aperture and TPF.
Can pass a user-defined aperture mask, otherwise determines which of a set of pre-determined apertures
provides the lowest scatter in the light curve.
Produces a mask, a numpy.ndarray object of the same shape as the target pixel file, which every pixel assigned
a weight in the range [0, 1].
 
Parameters
----------
aperture : numpy.ndarray
    (`height`, `width`) array of floats in the range [0,1] with desired weights for each pixel to
    create a light curve. If not set, ideal aperture is inferred automatically. If set, uses this
    aperture at the expense of all other set apertures.
get_time(self, coords)
Gets time, including light travel time correction to solar system barycenter for object given location
get_tpf_from_postcard(self, pos, postcard, height, width, bkg_size, save_postcard, source)
Gets TPF from postcard.
k2_correction(self, flux)
Remove any systematics that are correlated with spacecraft pointing, as inferred through telescope
pointing model.
 
Parameters
----------
flux : numpy.ndarray
    Flux array to which detrending applied.
load(self, directory=None, fn=None)
Loads in and sets all the attributes for a pre-created TPF file.
 
Parameters
----------
directory : str, optional
    Directory to load file from.
psf_lightcurve(self, data_arr=None, err_arr=None, bkg_arr=None, nstars=1, model='gaussian', likelihood='gaussian', xc=None, yc=None, verbose=False, err_method=True, ignore_pixels=None)
Performs PSF photometry for a selection of stars on a TPF.
 
Parameters
----------
data_arr: numpy.ndarray, optional
    Data array to fit with the PSF model. If None, will default to `TargetData.tpf`.
err_arr: numpy.ndarray, optional
    Uncertainty array to fit with the PSF model. If None, will default to `TargetData.tpf_flux_err`.
bkg_arr: numpy.ndarray, optional
    List of background values to include as initial guesses for the background model. If None,
    will default to `TargetData.flux_bkg`.
nstars: int, optional
    Number of stars to be modeled on the TPF.
model: string, optional
    PSF model to be applied. Presently must be `gaussian`, which models a single Gaussian.
    Will be extended in the future once TESS PRF models are made publicly available.
likelihood: string, optinal
    The data statistics given the parameters. Options are: 'gaussian' and 'poisson'.
xc: list, optional
    The x-coordinates of stars in the zeroth cadence. Must have length `nstars`.
    While the positions of stars will be fit in all cadences, the relative positions of
    stars will be fixed following the delta values from this list.
yc: list, optional
    The y-coordinates of stars in the zeroth cadence. Must have length `nstars`.
    While the positions of stars will be fit in all cadences, the relative positions of
    stars will be fixed following the delta values from this list.
verbose: bool, optional
    If True, return information about the shape of the PSF at every cadence as well as the
    PSF-inferred centroid shape.
err_method: bool, optional
    If True, use the photometric uncertainties for each pixel in the TPF as delivered by the
    TESS team. Otherwise, each pixel takes an equal uncertainty. If `err_arr` is passed
    through instead, this setting is ignored.
ignore_pixels: int, optional
    If not None, ignore a certain percentage of the brightest pixels away from the source
    target, effectively masking other nearby, bright stars. This strategy appears to do a
    reasonable job estimating the background more accurately in relatively crowded regions.
save(self, output_fn=None, directory=None)
Saves a created TPF object to a FITS file.
 
Parameters
----------
output_fn : str, optional
    Filename to save output as. Overrides default naming.
directory : str, optional
    Directory to save file into.
set_header(self)
Defines the header for the TPF.
set_quality(self)
Reads in quality flags set in the postcard
to_lightkurve(self, flux=None, quality_mask=None)
Creates a lightkurve.lightcurve.LightCurve() object with eleanor
attributes. All inputs have been quality masked.
 
Parameters
----------
flux : np.ndarray, optional
     An array of flux. Default is 
     eleanor.TargetData.corr_flux.
 
quality_mask : np.ndarray, optional
     An array of quality flags. Default is
     eleanor.TargetData.quality.
 
Returns
-------
lightkurve.lightcurve.TessLightCurve object

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Data
        __all__ = ['TargetData']