Skip to content

Commit

Permalink
Tweaking comms_avail and write table to file
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Nov 16, 2024
1 parent 9a50101 commit b82de3f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions make_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@

import argparse
import functools
import io
import json
import os
import re
Expand Down Expand Up @@ -218,6 +219,7 @@ def arc_data_file(
goes_x_h5_file = functools.partial(arc_data_file, DATA_ARC3, "GOES_X.h5")
ace_h5_file = functools.partial(arc_data_file, DATA_ARC3, "ACE.h5")
hrc_h5_file = functools.partial(arc_data_file, DATA_ARC3, "hrc_shield.h5")
comms_avail_file = functools.partial(arc_data_file, DATA_ARC3, "comms_avail.html")


def get_web_data(data_dir):
Expand Down Expand Up @@ -262,9 +264,16 @@ def get_fluence(filename):
return start, p3_fluence


def get_available_comms(start: CxoTime, stop: CxoTime) -> Table:
def get_comms_avail(start: CxoTime, stop: CxoTime) -> Table:
"""Get the available DSN comms from OCCweb
Parameters
----------
start : CxoTime
Start time for the available DSN comms table
stop : CxoTime
Stop time for the available DSN comms table
Returns
-------
dat : Table
Expand Down Expand Up @@ -599,7 +608,7 @@ def main(args_sys=None):
rates = np.ones_like(fluence_times) * max(avg_flux, 0.0) * args.dt
fluence = calc_fluence(fluence_times, fluence0, rates, states)
zero_fluence_at_radzone(fluence_times, fluence, radzones)
comms_avail = get_available_comms(start, stop)
comms_avail = get_comms_avail(now, stop)

# Initialize the main plot figure
fig = plt.figure(1, figsize=(9, 5))
Expand Down Expand Up @@ -670,6 +679,7 @@ def main(args_sys=None):
hrc_vals,
hrc_times,
)
write_comms_avail(comms_avail, comms_avail_file(args.data_dir, test=args.test))


def draw_log_scale_axes(fig, y0, y1):
Expand Down Expand Up @@ -913,6 +923,14 @@ def get_si(simpos):
return si


def write_comms_avail(comms_avail: Table, filename: str | Path):
out = io.StringIO()
comms_avail.write(out, format="ascii.html")
# Get the text between <table> and </table> and write out.
match = re.search("<table>(.*)</table>", out.getvalue(), re.DOTALL)
Path(filename).write_text(match.group(0))


def write_states_json(
fn,
fig,
Expand Down

0 comments on commit b82de3f

Please sign in to comment.