<jupyter_start><jupyter_text>Quick StartIn this section, we will walk through a few simple examples to help you get started on **EzTao**. For more in-depth tutorials, please check out the sections listed under **Tutorials** on the [main page](../index.rst) (or other notebooks if you are running this in mybinder).<jupyter_code># general packages
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
%matplotlib inline

# packages/modules from eztao and celerite
import eztao
from eztao.carma import DRW_term
from eztao.ts import gpSimRand
from eztao.ts import drw_fit
from celerite import GP

# use eztao matplotlib style
mpl.rc_file(os.path.join(eztao.__path__[0], "viz/eztao.rc"))<jupyter_output><empty_output><jupyter_text>Simulate a DRW processHere, we are simulating a DRW process with a RMS amplitude of 0.2 and a decorrelation/characteristic timescale of 100 days by first declaring a DRW GP kernel and generating the time series of a signal-to-noise ratio of 10, duration of 10 years and totally 200 data points using [gpSimRand](../python/ts.rsteztao.ts.carma_sim.gpSimRand).<jupyter_code># initialize DRW kernel, amp is RMS amplitude and tau is the decorrelation timescale
amp = 0.2
tau = 100
DRW_kernel = DRW_term(np.log(amp), np.log(tau))

# generate the time series, y-axis is linear
SNR = 10
duration = 365*10.0
npts = 200
t, y, yerr = gpSimRand(DRW_kernel, SNR, duration, npts, log_flux=False)
# plot the simulated process
fig, ax = plt.subplots(1,1, dpi=120, figsize=(8,3))
ax.errorbar(t, y, yerr, fmt='.')
ax.set_xlabel('Time (day)')
ax.set_ylabel('Flux (arb. unit)')
ax.set_title('Simulated DRW process')<jupyter_output><empty_output><jupyter_text>Fit the simulated DRW process<jupyter_code>best_fit = drw_fit(t, y, yerr)
print(f'Best-fit DRW parameter: {best_fit}')<jupyter_output>Best-fit DRW parameter: [ 0.21092082 96.47362586]<jupyter_text>Compare the True PSD with the Best-fit PSDPSD stands for power spectral density. We will use the PSD function provided the $\mathit{celerite}$.<jupyter_code># import the GP PSD function from eztao
from eztao.carma import gp_psd
# define the true/best-fit PSD functions using the input kernel 
# and a new kernel initalized with the best-fit parameters
best_fit_kernel = DRW_term(*np.log(best_fit))

true_psd = gp_psd(DRW_kernel)
best_psd = gp_psd(best_fit_kernel)
# plot and compare their PSDs
fig, ax = plt.subplots(1,1, dpi=120, figsize=(6,4))
freq = np.logspace(-5, 2)
ax.plot(freq, true_psd(freq), label='Input PSD')
ax.plot(freq, best_psd(freq), label='Best-fit PSD')
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel(r'Frequency ($\frac{1}{\mathrm{day}}$)')
ax.set_ylabel('PSD')
ax.set_title('The PSD of a DRW process', fontsize=14)
ax.legend()
fig.tight_layout()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10992148465381871, 'fraction_numerical': 0.023911491791577446, 'mean_word_length': 5.853300733496333, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '416192', 'license': 'MIT', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1005, 'n_words': 311, 'path': 'docs/notebooks/01_Quick_start.ipynb', 'repo_name': 'ywx649999311/EzTao', 'size': '2802'}