Skip to content

HITS-AIN/DelayCorrectedPFVG.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DelayCorrectedPFVG.jl

ℹ What is this?

This is a Julia implementation of a delayed corrected probabilistic flux variation gradient. Advantages over the PVFG include:

  • It can deal with the presence of delays in the light curves.
  • It can deal with irregularly sampled light curves.

🚴 Quick start

After installing the package, see here, you can proceed to the example below.

💾 Installation

Apart from cloning, an easy way of using the package is the following:

1 - Add the registry AINJuliaRegistry

2 - Switch into "package mode" with ] and add the package with

add DelayCorrectedPFVG

🚀 An important note about performance

The present code relies in the background on the Gaussian Process cross-correlation model in order to obtain the most likely delays. As it is a computationally intensive method, we recommend running it using multiple threads. We provide information here on how to do this.

▶ How to simulate data

Method simulatetwolightcurves can be used to simulate data in 2 arbitrary (non-physical) bands:

using DelayCorrectedPFVG
tobs, yobs, σobs, truedelays = simulatetwolightcurves() # output omitted

For more details, please refer to the following section in package GPCC for the simulation of data.

▶ Posterior of scaling and shifting parameters and density of intersection

The following script provides a complete receipe on how to infer the posterior of the scaling and shifting parameters and the density of the intersection point. Start Julia with multiple threads, e.g. julia -t8 starts Julia with 8 threads. Then use the following:

using DelayCorrectedPFVG

# Execute the following for better performance with multiple threads
using LinearAlgebra
BLAS.set_num_threads(1) # Set the number of BLAS threads to 1

using ThreadPinning # must be indepedently installed
pinthreads(:cores) # allows you to pin Julia threads to specific CPU-threads

warmup() # run this for Julia to precompile code

# Simulate some data
tobs, yobs, σobs, truedelays = simulatetwolightcurves()

# Define candidate delays
candidatedelays = collect(0.0:0.1:5.0)

# Get posterior of scaling and shifting parameters
# logl is the returned log-likelihood, i.e. the "quality of the posterior"
# q is the posterior of the scaling and shifting parameters
# delay is the most likely vector of delays
logl, q, delay = posteriors_a_b(tobs, yobs, σobs, candidatedelays, kernel=rbf, iterations = 10_000)

# We assume that the galaxy vector is given by `u`.
u = [6.0; 15.0] # this the shift vector that was used to shift the synthetic data.

# define candidate intersection points u/norm(u)⋅t
t = 0:0.1:60

# obtain probabilities for each candidate insersection point implied by u⋅t
pmf = intersectionprobabilities(q, u/norm(u), t); # note that the galaxy vector is normalised

using PyPlot # needs to be independently installed (or other plotting package)
figure("probability of intersection points implied by u⋅t")
plot(t, pmf)

# The peak of the plot above should be at around:
norm(u)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages