Giter Club home page Giter Club logo

python-bls's Introduction

Box Least Squares

These are Python bindings for the original Fortran implementation of Box Least Squares (BLS) algorithm from Kovács et al. (2002).

Installation

Clone the source code from the GitHub repository and install using the standard python tools:

git clone https://github.com/dfm/python-bls.git
cd python-bls
python setup.py install

For testing in development, you can use

python setup.py build_ext --inplace

to build the bindings directly in the bls directory.

Authors

These Python bindings were developed—building directly on the code released by Kovács—at the SAMSI workshop Modern Statistical and Computational Methods for Analysis of Kepler by

License

The Python bindings are licensed under the MIT License.

Basic Usage

TODO: describe Pythonic binding.

Advanced Usage

You can get direct access to the Fortran subroutine provided by Kovács through the eebls() function:

import bls
results = bls.eebls(time, flux, u, v, nf, fmin, df, nb, qmi, qma)

where

  • time is an N-dimensional array of timestamps for the light curve,
  • flux is the N-dimensional light curve array,
  • u and v are N-dimensional empty work arrays,
  • nf is the number of frequency bins to test,
  • fmin is the minimum frequency to test,
  • df is the frequency grid spacing,
  • nb is the number of bins to use in the folded light curve,
  • qmi is the minimum transit duration to test, and
  • qma is the maximum transit duration to test.

The returned values are

power, best_period, best_power, depth, q, in1, in2 = results

where

  • power is the nf-dimensional power spectrum array at frequencies f = fmin + arange(nf) * df,
  • best_period is the best-fit period in the same units as time,
  • best_power is the power at best_period,
  • depth is the depth of the transit at best_period,
  • q is the fractional transit duration,
  • in1 is the bin index at the start of transit, and
  • in2 is the bin index at the end of transit.

python-bls's People

Contributors

dfm avatar ruthangus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-bls's Issues

Python Package

Hello,

do you want to put this package on PyPI so that people can install it with

pip install python-bls

It is unfortunate that there is another package called bls (A library to access Bureau of Labor Statistics data). Eventually renaming this to pybls or something similar might make sense, so that people can install it with pip install pybls and import it as import pybls.

Segmentation fault (core dumped)

Hey, I keep getting this "Segmentation fault (core dumped)" when I try to run the BLS on a lightcurve, and I've never used Fortran before so I'm not sure what it means. I attached an example lightcurve I was trying to fit as a csv, and here are the arguments I was using for eebls:

u = np.empty(len(lcf))         # Is this correct, what is the required dtype for the u, v work arrays?
v = np.empty(len(lcf))

nf = 500
fmin = 1/8.
fmax = 39.443686562975699
df = int((fmax-fmin)//nf)
qmi = 0.5/24
qma = 1.

nb = 1772

power, best_period, best_power, depth, _, _, _ = bls.eebls(lcf['t'], lcf['f_detrended'], u, v, nf, fmin, df, nb, qmi, qma)

Also, for nb I'm not sure what to put, since apparently the max is 2000. Does nb have to be a factor of the number of cadences or lightcurve points? In this case, I cut out one cadence from lcf to make it even i.e:

lcf = lcf.loc[:(nb*2-1)]

so that

len(lcf) = 3544 = 1772 * 2

and same with len(u) = 3544 and v.

lightcurve:
lc_example.txt

Issue installing to Windows Computer

Hello,

I am running Windows 10 and am having trouble with the installation. I installed gfortran to help with the compiling of fortran but am still getting an error. The error reads "unable to find vcvarsall.bat". Do you have an advise on how to install bls on windows?

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.