Skip to content

Commit

Permalink
Add CCE executable status and dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsvu committed Jul 15, 2024
1 parent e7f7338 commit 09402e2
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/Status/ExecutableStatus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ spectre_python_add_module(
MODULE_PATH tools/Status
PYTHON_FILES
__init__.py
CharacteristicExtract.py
EvolveGhBinaryBlackHole.py
EvolveGhSingleBlackHole.py
ExecutableStatus.py
Expand Down
64 changes: 64 additions & 0 deletions tools/Status/ExecutableStatus/CharacteristicExtract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Distributed under the MIT License.
# See LICENSE.txt for details.

import logging
from pathlib import Path

import h5py
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from spectre.Visualization.ReadH5 import to_dataframe

from .ExecutableStatus import ExecutableStatus

logger = logging.getLogger(__name__)


class CharacteristicExtract(ExecutableStatus):
executable_name_patterns = [r"^CharacteristicExtract"]
fields = {
"Time": "M",
}

def status(self, input_file, work_dir):
try:
open_reductions_file = h5py.File(
Path(work_dir)
/ (input_file["Observers"]["ReductionFileName"] + ".h5"),
"r",
)
except:
logger.debug("Unable to open reductions file.", exc_info=True)
return {}
with open_reductions_file:
try:
time_steps = to_dataframe(
open_reductions_file["Cce/CceTimeStep.dat"]
)
except:
logger.debug("Unable to read CCE time steps.", exc_info=True)
return {}
return {
"Time": time_steps.iloc[-1]["Time"],
}

def format(self, field, value):
if field in ["Time", "Speed"]:
return f"{value:g}"
raise ValueError

def render_dashboard(self, job: dict, input_file: dict):
import plotly.express as px
import streamlit as st

from spectre.Visualization.PlotCce import plot_cce

fig = plot_cce(
Path(job["WorkDir"])
/ (input_file["Observers"]["ReductionFileName"] + ".h5"),
modes=["Real Y_2,2", "Imag Y_2,2"],
x_label="Time [M]",
)
st.pyplot(fig)
2 changes: 2 additions & 0 deletions tools/Status/ExecutableStatus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import re

from .CharacteristicExtract import CharacteristicExtract
from .EvolveGhBinaryBlackHole import EvolveGhBinaryBlackHole
from .EvolveGhSingleBlackHole import EvolveGhSingleBlackHole
from .ExecutableStatus import EllipticStatus, EvolutionStatus, ExecutableStatus
Expand All @@ -13,6 +14,7 @@

# Subclasses are matched in this order. Add new subclasses here.
executable_status_subclasses = [
CharacteristicExtract,
EvolveGhBinaryBlackHole,
EvolveGhSingleBlackHole,
EvolutionStatus,
Expand Down

0 comments on commit 09402e2

Please sign in to comment.