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. TODO: this need to be tested on a v2.0.0 dataset.

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)
../../_images/detailled_window.png

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:

../../_images/option_window.png

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)
../../_images/diagram_window.png

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,
)
../../_images/diagram_inline.png

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=cnt[:,0],
                frequency=parse_df.get_frequencies(),
                hierarchy=False,
                presentMode=PresenterMode.DIAGRAM,
                displayMode=DisplayMode.INLINE_B)
../../_images/diagram_multiple.png

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=cnt[:,0],
                frequency=parse_df.get_frequencies(),
                hierarchy=True,
                presentMode=PresenterMode.DIAGRAM,
                displayMode=DisplayMode.INLINE_B)
../../_images/diagram_hierarchy.png

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)
../../_images/diagram_multiple_sort.png