Code Monkey home page Code Monkey logo

weirddetector's Introduction

This code implements the algorithm in Wheeler & Kipping 201?. Find posterior samples from the paper at github.com/ajwheeler/WDdata.

This code is tested with Julia 1.0, but it should be compatible with 0.6 as well. It requires the Interpolations, DataFrames, and FITSIO packages. To install them run these commands on the Julia REPL

Pkg.add("Interpolations")
Pkg.add("DataFrames")
Pkg.add("FITSIO")

Here is a brief usage example

push!(LOAD_PATH, "/directory/containing/this/code")
using WeirdDetector

#here's how you can get a Kepler light curve detrended like we did in the paper
getFITS(8462852, fitsdir="./") #download FITS files for Boyajian's star to the current directory
df = loadFITS(8462852, fitsdir="./") #load all quarters into single data frame, perform ourlier rejection and detrending
data = pointsify(df) #convert to data type taken by periodogram()

#Here's how to prep arbitary data
t = ...      # array of epochs
F = ...      # array of flux values
sigmaF = ... # array of 1-sigma uncertainties
data = Point.(t, F, sigmaF) #this constructs an array of Points with Julia's broadcast syntax

periods = optimal_periods(pmin=0.25, pmax=50) #construct array of periods used in paper.  Any array of Float32's will do.
output = periodogram(data, periods, parallel=true) #construct a DataFrame containing the chi-squared and kurtosis values for each period
                                                   #if you want to parallelize, start Julia with "julia -n <number of cores>"

#do some postprocessing 
output[:delt_chi2] = flatten(output[:chi2], periods) #calculate \Delta \chi^2 (see equation N)

null_output = scrambled_periodogram(data, periods)
null_output[:delt_chi2] = flatten(null_output[:chi2], periods)
sigma = movingstd((null_output[:kurtosis] .- 3) .* (null_output[:delt_chi2])

output[:zeta] = (output[:kurtosis] .- 3) .* output[:delt_chi2] ./ sigma

#plot the periodogram
using PyPlot
plot(periods, output[:zeta])

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.