Code Monkey home page Code Monkey logo

eztao's Introduction

tests Binder Documentation Status ascl:2201.001

EzTao (易道)

EzTao is a toolkit for conducting AGN time-series/variability analysis, mainly utilizing the continuous-time auto-regressive moving average model (CARMA)

Installation

pip install git+https://github.com/ywx649999311/EzTao.git

Dependencies

python = ">=3.8,<3.12"
celerite = ">= 0.3.0"
scipy = "> 1.5.0"
numba = ">= 0.57.0"
matplotlib = ">=3.3.3"
emcee = ">=0.3.0"

Quick Examples

Let's first simulate a DRW/CARMA(1,0) process with a variance of 0.3^2 and a relaxation timescale of 100 days. This time series will have a total of 200 data points and span 10 years.

import numpy as np
import matplotlib.pyplot as plt
from eztao.carma import DRW_term
from eztao.ts import gpSimRand

# define a DRW kernel & and simulate a process
amp = 0.2
tau = 100
DRW_kernel = DRW_term(np.log(amp), np.log(tau))
t, y, yerr = gpSimRand(DRW_kernel, 10, 365*10, 200)

# now, plot it
fig, ax = plt.subplots(1,1, dpi=150, figsize=(8,3))
ax.errorbar(t, y, yerr, fmt='.')
...

drw_sim

We can fit the simulated time series to the DRW model and see how well we can recover the input parameters.

from eztao.ts import drw_fit

best_fit = drw_fit(t, y, yerr)
print(f'Best-fit DRW parameters: {best_fit}')
Best-fit DRW parameters: [0.17356983 88.36262467]

How does the power spectrum density (PSD) compare?

from eztao.carma import gp_psd

# get psd functions
true_psd = gp_psd(DRW_kernel)
best_psd = gp_psd(DRW_term(*np.log(best_fit)))

# plot
fig, ax = plt.subplots(1,1, dpi=150, figsize=(6,3))
freq = np.logspace(-5, 2)
ax.plot(freq, true_psd(freq), label='Input PSD')
ax.plot(freq, best_psd(freq), label='Best-fit PSD')
...

drw_psd

Note: How well the input and best-fit PSD match is up to how good the best-fit parameters are, which is highly influenced by the quality of the input time series.

For more examples, please check out the online documentation or run the tutorial notebooks at -> Binder.

Development

poetry is used to solve dependencies and to build/publish this package. Below shows how setup the environment for development (assuming you already have poetry installed on your machine). Warning: poetry is having issue installing llvmlite = 0.34.0 (used for eztao = ^0.4.0) under Python 3.9. The issue disappears for Python 3.8.

  1. Clone this repository, and enter the repository folder.
  2. Create a python virtual environment and activate it (the virtual environment name must be '.venv').
    python -m venv .venv
    source .venv/bin/activate
    
  3. Install dependencies and EzTao in editable mode.
    poetry install
    

Now you should be ready to start adding new features. Be sure to checkout the normal practice regarding how to use poetry on its website. When you are ready to push, also make sure the poetry.lock file is checked-in if any dependency has changed.

Citation

We are working on a paper to describe the full implementation of EzTao. In the meantime, if you find EzTao useful for your research, please consider acknowledging EzTao using the following:

@MISC{Yu2022,
       author = {{Yu}, Weixiang and {Richards}, Gordon T.},
        title = "{EzTao: Easier CARMA Modeling}",
     keywords = {Software},
 howpublished = {Astrophysics Source Code Library, record ascl:2201.001},
         year = 2022,
        month = jan,
          eid = {ascl:2201.001},
        pages = {ascl:2201.001},
archivePrefix = {ascl},
       eprint = {2201.001},
       adsurl = {https://ui.adsabs.harvard.edu/abs/2022ascl.soft01001Y},
      adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

eztao's People

Contributors

dependabot[bot] avatar drewoldag avatar gtrichards avatar ywx649999311 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

eztao's Issues

Viz with bokeh

Interactive viz using bokeh

  • Interactive likelihood surface viz (update while changing zoom level?)

Add citation file

@misc{Yu2022,
author = {{Yu}, Weixiang and {Richards}, Gordon T.},
title = "{EzTao: Easier CARMA Modeling}",
keywords = {Software},
year = 2022,
month = jan,
eid = {ascl:2201.001},
pages = {ascl:2201.001},
archivePrefix = {ascl},
eprint = {2201.001},
adsurl = {https://ui.adsabs.harvard.edu/abs/2022ascl.soft01001Y},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

'[7] 76360 bus error python3' on import

I have a Mac M1 so I suspect that is the issue? No problems with the installation~

import eztao ### works fine
from eztao.carma import DRW_term
[7] 76360 bus error python3

receiving the same error from: eztao.ts import gpSimRand

with:
python==3.9.0
scipy==1.9.0
numba==0.56.0
celerite==0.4.2
emcee==3.1.2
matplotlib==3.5.2

Update doc notebook 05_OtherUtils

## plot predicted time series
t_pred = np.linspace(0, 365*6, 2000)

# get best-fit in CARMA space
best_fit_kernel = DRW_term(*np.log(best_fit))
best_fit_arma = np.exp(best_fit_kernel.get_carma_parameter())

plot_pred_lc(t, y, yerr, best_fit_arma, 1, t_pred)

Remove np.exp from best_fit_arma = np.exp(best_fit_kernel.get_carma_parameter())

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.