GithubHelp home page GithubHelp logo

untrendy's Introduction

Untrendy

In an age where studying exoplanets is just the hippest thing ever, sometimes it's good to step out of line and be a little untrendy! This library is a set of hacks that can robustly remove the out-of-transit trends in light curve data.

Installation

Untrendy depends on numpy and scipy so make sure that you install those first. Then, you can install using pip:

pip install untrendy

Usage

Untrendy is really complicated. It has approximately one function and about 200 lines of code (including documentation). It mostly runs on love and magic (more complete details are given below if you want).

Let's say that you have a light curve with time samples t, flux measurements f and uncertainties sigma. You can simply run:

to find a robust estimate of the global trends of the time series and remove it. The default settings are tuned to work well for finding the "out-of-transit" trends in Kepler data but a detailed description of the options is listed below. You can also just fit for the trends and get a callable representation of the trend:

In this case, you can find the background level at some time t0 by calling the function:

Notes

  1. The spline sometimes goes to hell in regions where you don't have any samples so be careful with that.
  2. This whole procedure introduces correlated errors. You've been warned.

Command Line Untrending

There is also the option of using Untrendy from the command line if you don't want to bother with all the Python stuff. If you have a whitespace separated ASCII file containing your light curve, you can de-trend it by running:

untrend /path/to/data.txt

The code will assume that your file has 2 or 3 columns with time, flux and (optionally) uncertainties for each observation. Then, the de-trended light curve will be written to standard out in the same format. Alternatively, the same program can read the data right from standard in:

cat /path/to/data.txt | untrend

This gives you the option of doing something crazy and then piping it all UNIX-like. Personally, I would just use Python.

API

Fit the trend

untrendy.fit_trend (x, y, yerr=None, Q=12, dt=3.0, tol=0.00125, maxiter=15, fill_times=None, maxditer=4, nfill=4)

Use iteratively re-weighted least squares to fit a spline to the out-of-transit trends in a time series. The input data should be "clean". In other words, bad data should be masked and it often helps to normalize the fluxes (by the median or something).

Parameters

x

The sampled times.

y

The fluxes corresponding to the times in x.

yerr

(optional) The 1-sigma error bars on y.

Q

(optional) The parameter controlling the severity of the re-weighting.

dt

(optional) The initial spacing between time control points.

tol

(optional) The convergence criterion.

maxiter

(optional) The maximum number of re-weighting iterations to run.

fill_times

(optional) If provided, this number sets the minimum time spacing between adjacent samples that is acceptable. If the spacing is larger, knots will be added to fill in the gap.

maxditer

(optional) The maximum number of discontinuity search iterations to run.

nfill

(optional) The number of knots to use to fill in the gaps.

Returns

trend

A callable representation of the trend.

Remove the trend

untrendy.untrend (x, y, yerr=None, **kwargs)

Use iteratively re-weighted least squares to remove the out-of-transit trends in a light curve. Unlike fit_trend, this function masks bad data (NaN) and normalizes the data before fitting.

Parameters

x

The sampled times.

y

The fluxes corresponding to the times in x.

yerr

(optional) The 1-sigma error bars on y.

**kwargs

(optional) Other arguments passed to the fit_trend function.

Returns

flux

The de-trended relative fluxes.

ferr

The de-trended uncertainties on flux.

untrendy's People

Contributors

dfm avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.