Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick look dashboard [WIP] #819

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions dashboard/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from dash import Dash, html, dcc, Output, Input, callback
import plotly.express as px
import pandas as pd
from stingray import Lightcurve, Crossspectrum
import numpy as np

### Had to import dash and pandas separately (make a new category in setup.cfg)

dt = 0.01
time = np.arange(0, 100, dt)

freq = 0.2
amplitude = 100.0

counts = amplitude * np.sin(2 * np.pi * freq * time)
lc = Lightcurve(time, counts, dt=dt)

df_lc = pd.DataFrame({"time": lc.time, "counts": lc.counts})

cs = Crossspectrum(lc, lc)
df_cs_mag = pd.DataFrame({"frequency": cs.freq, "magnitude": np.abs(cs.power)})
df_cs_phase = pd.DataFrame({"frequency": cs.freq, "phase": np.angle(cs.power)})

app = Dash(__name__)

graph_styles = {"width": "50vw", "height": "50vh"}

app.layout = html.Div(
[
html.H1("Stingray Data", style={"textAlign": "center"}),
html.Div(
className="wrapper",
children=[
dcc.Graph(
id="graph_lc", figure=px.line(df_lc, x="time", y="counts"), style=graph_styles
),
dcc.Graph(
id="graph_cs_mag",
figure=px.line(df_cs_mag, x="frequency", y="magnitude"),
style=graph_styles,
),
dcc.Graph(
id="graph_cs_phase",
figure=px.line(df_cs_phase, x="frequency", y="phase"),
style=graph_styles,
),
],
style={"display": "flex", "flex-direction": "column", "alignItems": "center"},
),
]
)

if __name__ == "__main__":
app.run(debug=True)
Loading