Skip to content
Open
Show file tree
Hide file tree
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
18 changes: 7 additions & 11 deletions projects/online/online/monitor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
from .utils.parse_logs import estimate_tb, pipeline_online
from .pages import EventPage, SummaryPage

from gwpy.time import tconvert
from datetime import datetime, timezone


def main(
run_dir: Path,
Expand All @@ -25,7 +22,9 @@ def main(
online_args: Configuration parameters for the online search.
start_time:
The earliest GPS time to consider for processing events.
If None, the current GPS time is used.
If None and an event dataframe file exists, the oldest
event time will be used. If the file does not exist,
the current GPS time is used.
update_cadence:
The interval in seconds to check for new events.
logger: Logger object for standardizing logging output
Expand All @@ -36,26 +35,23 @@ def main(

detected_event_dir = run_dir / "output" / "events"

if start_time is None:
start_time = float(tconvert(datetime.now(timezone.utc)))

summary_page = SummaryPage(start_time, run_dir, out_dir, logger)
# Estimate analysis live time since the given start time
tb = estimate_tb(run_dir, start_time)
tb = estimate_tb(run_dir, summary_page.start_time)
logger.info(f"Estimated analysis live time: {tb:.2f} seconds")

previous_update_time = time.time()

summary_page = SummaryPage(start_time, run_dir, out_dir, logger)
while True:
detected_events = [
event
for event in detected_event_dir.iterdir()
if float(event.name.split("_")[1]) >= start_time
if float(event.name.split("_")[1])
]

# The event page will be created/updated only if the event directory
# is missing expected plots. Otherwise it will be skipped.
for event in detected_events:
for event in sorted(detected_events):
event_page = EventPage(
event, online_args, run_dir, out_dir, logger
)
Expand Down
20 changes: 20 additions & 0 deletions projects/online/online/monitor/pages/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ def __init__(
) -> None:
super().__init__(*args, **kwargs)
self.start_time = start_time
if self.start_time is None:
if self.dataframe_file.exists():
df = pd.read_hdf(self.dataframe_file)
self.start_time = min(df["gpstime"])
self.logger.info(
"start_time was None, setting start_time to the oldest "
f"event time in {self.dataframe_file}, {self.start_time}"
)
else:
self.start_time = float(tconvert(datetime.now(timezone.utc)))
self.logger.info(
"start_time was None, setting start_time to current time"
)

self.plots_dir = self.out_dir / "plots"
if not self.plots_dir.exists():
self.plots_dir.mkdir(exist_ok=True, parents=True)
Expand Down Expand Up @@ -83,6 +97,12 @@ def update_summary_plots(self, tb: float):
tb: Total time in seconds that the pipeline has been running.
"""
df = pd.read_hdf(self.dataframe_file)
df = df[df["gpstime"] >= self.start_time]
if df.empty:
self.logger.warning(
"No events found in the DataFrame after the start time."
)
return
latency_plot(self.plots_dir, df)
ifar_plot(self.plots_dir, df, tb)
event_rate_plots(self.plots_dir, df)
Expand Down
3 changes: 2 additions & 1 deletion scripts/aframe_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def create_online_runfile(path: Path):
monitor_cmd = "apptainer run "
monitor_cmd += f" --bind {path} "
monitor_cmd += "$AFRAME_CONTAINER_ROOT/online.sif /opt/env/bin/monitor "
monitor_cmd += f"--run_dir {path} --out_dir $MONITOR_OUTDIR &"
monitor_cmd += f"--run_dir {path} --out_dir $MONITOR_OUTDIR "
monitor_cmd += ">> summary_pages.log 2>&1 &"

content = f"""
#!/bin/bash
Expand Down