KASOC Filter (corrections.KASOCFilterCorrector)

Lightcurve correction using the KASOC Filter (Handberg et al. 2015).

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

class corrections.KASOCFilterCorrector(*args, **kwargs)[source]

Bases: corrections.BaseCorrector.BaseCorrector

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

Initialize the corrector.

Parameters
  • input_folder (string) –

  • plot (boolean, optional) –

Raises

FileNotFoundError – TODO-file not found in directory.

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

close()

Close correction object.

correct(task, output_folder=None)

Run correction.

Parameters
  • task (dict) – Dictionary defining a task/lightcurve to process.

  • output_folder (string, optional) – Path to directory where lightcurve should be saved.

Returns

Result dictionary containing information about the processing.

Return type

dict

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

do_correction(lc)[source]

Apply corrections to target lightcurve.

Parameters

lightcurve (lightkurve.TessLightCurve object) – Lightcurve of the target star to be corrected.

Returns

The status of the corrections and the corrected lightcurve object.

Raises

NotImplementedError

load_lightcurve(task)

Load lightcurve from task ID or full task dictionary.

Parameters

task (integer or dict) –

Returns

Lightcurve for the star in question.

Return type

lightkurve.TessLightCurve

Raises

ValueError – On invalid file format.

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

plot_folder(lc)

Return folder path where plots for a given lightcurve should be saved.

Parameters

lc (lightkurve.TessLightCurve) – Lightcurve to return plot path for.

Returns

Path to directory where plots should be saved.

Return type

string

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

save_lightcurve(lc, output_folder=None)

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.

Returns

Path to the generated file.

Return type

string

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

Code author: Mikkel N. Lund <mikkelnl@phys.au.dk>

search_database(select=None, join=None, search=None, order_by=None, limit=None, distinct=False)

Search list of lightcurves and return a list of tasks/stars matching the given criteria.

Returned rows are restricted to things not marked as STATUS.SKIPPED, since these have been deemed too bad to not require corrections, they are definitely also too bad to use in any kind of correction.

Parameters
  • search (list of strings or None) – Conditions to apply to the selection of stars from the database

  • order_by (list, string or None) – Column to order the database output by.

  • limit (int or None) – Maximum number of rows to retrieve from the database. If limit is None, all the rows are retrieved.

  • distinct (boolean) – Boolean indicating if the query should return unique elements only.

Returns

Returns all stars retrieved by the call to the database as dicts/tasks that can be consumed directly by load_lightcurve

Return type

list of dicts

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

KASOC Filter

KASOC Filter for Asteroseismic Data Preparation

Corrects Kepler/K2/TESS data for instrumental effects and planetary signals to create new datasets optimized for asteroseismic analysis.

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

Code author: Mikkel N. Lund

exception corrections.kasoc_filter.kasoc_filter.InvalidSigmasWarning[source]

Bases: UserWarning

corrections.kasoc_filter.kasoc_filter.extract_star_movement_1d(time, flux, position, dt=None, rapid_movement_sigma_clip=5.0, pixel_off_clip=15.0)[source]

Extract information about star movement on CCD to be used later.

Parameters
  • time – Vector of timestamps.

  • flux – Vector of flux values.

  • position – Nx2 matrix of (x,y) positions of star on CCD.

  • dt – Mean distance between points in the time vector.

Returns

Flags indicating bad data points. star_movement: Object containing info to be passed to @filter_position_1d.

Return type

flags

corrections.kasoc_filter.kasoc_filter.filter(t, x, quality=None, position=None, P=None, jumps=None, timescale_long=3.0, timescale_short=0.041666666666666664, sigma_clip=4.5, scale_clip=5.0, scale_width=1.0, phase_smooth_factor=1000, transit_model=None, it=3)[source]

Main filter function.

Parameters
  • t (ndarray) – Time vector (days).

  • x (ndarray) – Flux vector.

  • quality (ndarray, None) – Quality vector (bit-flags); default=None.

  • position (ndarray, None) – Centroid positions of star on CCD as two column list; default=None.

  • P (ndarray) – Known planetary period (days); default=None.

  • jumps (list) – List of known jumps in the flux (timestamp in days); default=None.

  • timescale_long (float) – Timescale of long filter in days; default=3.

  • timescale_short (float) – Timescale of short filter in days; default=1/24.

  • sigma_clip (float) – Sigma-clip threshold; default=4.5.

  • scale_clip (float) – Scale at which to switch between long and short filters; default=5.

  • scale_width (float) – Width of transition region between filters; default=1.

  • phase_smooth_factor (float) – Fraction of period to smooth phase curce with; default=1000.

  • transit_model (ndarray) – Full transit model to be used instead of smoothed phase curve; default=None.

  • it (integer) – Number of iterations between different filters. Default=3.

Returns

tnew - New time vector with the same length as the input vectors. xnew - New flux vector with the same length as the input vectors. sigma - Vector of estmated errors on measurements. flags - Vector of KASOC flags. filt - Vector with the final filter applied (after jump removal). turnover - Turnover function with weights to long and short filter.

corrections.kasoc_filter.kasoc_filter.filter_flags(t, x, quality, quality_remove=4335, return_flags=False)[source]

Filter out flagged data from quality column.

Returns new flux vector with bad datapoints removed (set to NaN) and a vector with flagged jump time postions. This vector can later be passed into filter_jumps().

Parameters
  • t (ndarray) – Time vector (days).

  • x (ndarray) – Flux vector.

  • quality (ndarray) – Quality flags (integers).

  • quality_remove (integer, optional) – Flags that corresponds to bad data points.

  • return_flags (boolean) – Also return flags of removed points.

Returns

  • ndarray: Flux vector filterd for bad data points.

  • list: jumps

  • ndarray: flag_removed

Return type

tuple

corrections.kasoc_filter.kasoc_filter.filter_phase(t, x, Plist, smooth_factor=1000)[source]

Filter out specific periods by smoothing the phase-curve.

Parameters
  • t (ndarray) – Time vector (days).

  • x (ndarray) – Flux vector.

  • P (list) – List of periods to remove.

  • smooth_factor (float, optional) – Factor of phase to use as smooth width.

Returns

Filter flux vector that can be removed from timeseries.

Note

Does not require time to be sorted. Can handle NaN in flux vector.

corrections.kasoc_filter.kasoc_filter.filter_position_1d(time, flux, star_movement, timescale_position_smooth=None, dt=None)[source]

Filter the lightcurve for correlations in the stars position on the CCD.

corrections.kasoc_filter.kasoc_filter.remove_jumps(t, x, jumps, width=3, return_flags=False)[source]

Remove jumps from timeseries.

Parameters
  • t (ndarray) – Time vector (days). Must be sorted in time.

  • x (ndarray) – Flux vector. Can contain invalid points (NaN).

  • jumps (list) – Vector of timestamps where jumps are to be corrected.

  • width (float) – Width of the region on each side of jumps to compare (default=3 days).

  • return_flags (boolean) – Return two additional arrays with location of corrected jumps.

corrections.kasoc_filter.kasoc_filter.scale_timescales(numax, min_value_long=30.0)[source]

Scale the filter timescales with estimated nu_max of the star in question to avoid disturbing oscillation signals for low-numax stars.

Parameters
  • numax (float) – nu_max in microHz.

  • min_value_long (float, optional) – The shortest filter width to return in days. Default=30.

Returns

New timescale which will avoid the specified nu_max region.

Return type

float

corrections.kasoc_filter.kasoc_filter.set_output(folder=None, prefix='', fmt='png', native=False)[source]

Change the output settings for the plots generated by the filter.

corrections.kasoc_filter.kasoc_filter.spline_set_knots(x, num_knots, min_points_per_knot=3)[source]