Van den Heuvel diagrams with POSYDON๏
Warning
This is an experimental feature of POSYDON. Unexpected behaviors or results may occur.
Note
To use the visualization functionalities, install the optional visualization modules pip install .[vis]
VHdiagram provides a visual representation of individual POSYDON binaries, offering a more intuitive sense of their properties. This tutorial uses the โpopulation.h5โ dataset as an example. You can use the population in the Stellar Transient Populations tutorial.
Visualizing a Specific Binary๏
Simple Usage๏
To visualize a specific binary within an interactive window, use the following code:
from posydon.visualization.VHdiagram import VHdiagram
VHdiagram('population.h5', path='./dataset/', index=18976)

Tip
Use the โpathโ named parameter if your dataset resides in a different directory.
The options window, accessible via the โoptionโ button, lets you customize the view:

Clicking the โsaveโ button captures a screenshot of the current view and saves it to a newly created โscreensโ folder in the current directory.
Predefined Views๏
You can choose from four predefined views for faster visualization:
from posydon.visualization.VHdiagram import VHdiagram
from posydon.visualization.VH_diagram.PresenterMode import PresenterMode
VHdiagram('population.h5', index=19628, presentMode=PresenterMode.DIAGRAM)

Display Modes๏
You have the flexibility to display the diagram either within an interactive window or inline within a Jupyter notebook. The available display modes are:
from posydon.visualization.VHdiagram import VHdiagram, DisplayMode
from posydon.visualization.VH_diagram.Presenter import PresenterMode
VHdiagram(
"population.h5",
index=19628,
presentMode=PresenterMode.DIAGRAM,
displayMode=DisplayMode.INLINE_B,
)

Advanced Visualization Techniques๏
Visualizing Multiple Binaries๏
The VDdiagramm_m module allows multiple binary visualizations to be arranged horizontally in a single plot:
from posydon.visualization.VH_diagram.PresenterMultiple import VHdiagramm_m
from posydon.visualization.VHdiagram import DisplayMode
from posydon.visualization.VH_diagram.PresenterMode import PresenterMode
VHD = VHdiagramm_m('./data/population.h5',
index=[19627,19628,19629,19630],
hierarchy=False,
presentMode=PresenterMode.DIAGRAM,
displayMode=DisplayMode.INLINE_B)

Hierarchical Visualization๏
This visualization style aggregates identical steps into a tree plot where nodes represent common steps. Each node is labeled with percentages relative to the parent node percentage.
from posydon.visualization.VH_diagram.PresenterMultiple import VHdiagramm_m
from posydon.visualization.VHdiagram import DisplayMode
from posydon.visualization.VH_diagram.PresenterMode import PresenterMode
VHD = VHdiagramm_m('./data/population.h5',
index=[19627,19628,19629,19630],
hierarchy=True,
presentMode=PresenterMode.DIAGRAM,
displayMode=DisplayMode.INLINE_B)

Binary Analysis Tools๏
Counting Binaries๏
Use the ParseDataFrame class to iterate through the binary file, counting identical binary simulations:
from posydon.visualization.VH_diagram.ParseDataFrame import ParseDataFrame
parse_df = ParseDataFrame('./data/population.h5')
parse_df.count_dict
>>> Counter({...})
Sorting Binaries๏
You can sort binaries based on filenames of images representing their steps:
VHD = VHdiagramm_m('./data/population.h5',
index=VHD.get_sorted_index(),
frequency=parse_df.get_frequencies(),
hierarchy=False,
presentMode=PresenterMode.DIAGRAM,
displayMode=DisplayMode.INLINE_B)
