# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import pylab as plt
# %matplotlib inline
import tqdm
import json
from frbpa.utils import get_phase

# +
with open('r3_data.json', 'r') as f:
    r3_data = json.load(f)
    
burst_dict = r3_data['bursts']
# -

period = 16.35

phases_1 = []
phases_2 = []
mjds = []
for k in burst_dict.keys():
    phases_1 += list(get_phase(np.array(burst_dict[k]), period, ref_mjd=58369.30))
    phases_2 += list(get_phase(np.array(burst_dict[k]), period+0.01, ref_mjd=58369.30))
    mjds += burst_dict[k]

plt.scatter(np.array(mjds) - 58369.30, phases_1, color='r', label='Period = 16.35 days')
plt.scatter(np.array(mjds) - 58369.30, phases_2, color='b', label='Period = 16.36 days')
plt.xlabel('MJDs')
plt.ylabel('Phases')
plt.legend()
plt.grid()

_, b, _ = plt.hist(phases_1, bins=15, alpha=0.6, label='Period = 16.35 days')
plt.hist(phases_2, bins=b, alpha=0.6, label='Period = 16.36 days')
plt.legend()
plt.xlabel('phase')

StarcoderdataJupyterScriptsDedupFiltered