posydon.visualization.VH_diagram

posydon.visualization.VH_diagram.GraphVisualizer

Graph Visualizer for the VH diagram.

class posydon.visualization.VH_diagram.GraphVisualizer.CaseInfos(column_id, *, centered_txt: str = '', bot_right_txt: str = '', bot_left_txt: str = '', top_right_txt: str = '', tot_left_txt: str = '', border_width: int = 0)[source]

Bases: Infos

Informations to create a case widget.

Initialize a CaseInfos instance.

border_width: int
bot_left_text: str
bot_right_text: str
centered_text: str
top_left_text: str
top_right_text: str
class posydon.visualization.VH_diagram.GraphVisualizer.ConnectedItem(from_item: GraphVisualizerItem, to_item: GraphVisualizerItem)[source]

Bases: object

Represent a visual link between 2 widgets.

Initialize a ConnectedItem instance.

from_item: GraphVisualizerItem
to_item: GraphVisualizerItem
class posydon.visualization.VH_diagram.GraphVisualizer.GraphVisualizer[source]

Bases: QWidget

Widget used to display the different columns and add widget in them.

Initialize a GraphVisualizer instance.

add_column(column_type, column_span=1)[source]

Create a column according to the column_type.

It takes account for the column_span of the logical column.

Parameters:
  • column_type (columnTYPE) – Type of the column to add.

  • column_span (int) – Nb of logical column used.

Returns:

ID of created column.

Return type:

int

add_line(infos)[source]

Add all lines based on all elements in infos.

For each info in infos, create the corresponding widget and add it to the column with corresponding id (given in each info), only 1 widget per column by call, if one column haven’t any widget associated, column skip this row.

Parameters:

infos (Array of Infos) – Array with derivated struct of Infos to create the different widget for this line.

clear()[source]

Clear each column.

get_column(column_id)[source]

Return visual column with the given id.

Parameters:

column_id (int) – ID of searched column.

Returns:

column with the given ID.

Return type:

GraphVisualizercolumn

paintEvent(event)[source]

Paint the event.

reset()[source]

Clear all delete each column.

saveAsPicture(filename)[source]

Render this widget in a picture and save it a filename.

Parameters:

filename (str) – Destination file of the picture.

class posydon.visualization.VH_diagram.GraphVisualizer.GraphVisualizerCase[source]

Bases: GraphVisualizerItem

Case widget in GraphVisualizer.

Provides the ability to display 5 texts: 2 on the top 2 on the bottom, and 1 in center. Can have a border.

Initialize a GraphVisualizerCase instance.

get_attach_point_bot()[source]

Get coordinate to connect this widget with the next one.

get_attach_point_top()[source]

Get coordinate to connect this widget with the previous one.

set_bottom_left_text(text)[source]

Set the text at the bottom left.

set_bottom_rigth_text(text)[source]

Set the text at the bottom right.

set_central_border(width)[source]

Set the text at the central border.

set_central_text(text)[source]

Set the text at the center.

set_top_left_text(text)[source]

Set the text at the top left.

set_top_right_text(text)[source]

Set the text at the top right.

class posydon.visualization.VH_diagram.GraphVisualizer.GraphVisualizerConnectedcolumn(grid, column_id, column_span=1)[source]

Bases: GraphVisualizercolumn

Simple visual column with arrow between connected widget.

Initialize a GraphVisualizerConnectedcolumn instance.

draw(surface)[source]

Draw the surface.

class posydon.visualization.VH_diagram.GraphVisualizer.GraphVisualizerItem[source]

Bases: QWidget

Define the mother-class for widget in GraphVisualizer.

connected

Indicate if this widget need to be connected with the previous one in the same column.

Type:

bool

Initialize a GraphVisualizerItem instrance.

get_attach_point_bot()[source]

Get coordinate to connect this widget with the next one.

Returns:

Coordinate to link the widget with the next one.

Return type:

int

get_attach_point_top()[source]

Get coordinate to connect this widget with the previous one.

Returns:

Coordinate to link the widget with the previous one.

Return type:

int

class posydon.visualization.VH_diagram.GraphVisualizer.GraphVisualizerPoint[source]

Bases: GraphVisualizerItem

Widget containing GraphVisualizerPointDraw.

Provides the ability to display 2 texts, one at each side.

Initialize a GraphVisualizerPoint instance.

get_attach_point_bot()[source]

Get coordinate to connect this widget with the next one.

get_attach_point_top()[source]

Get coordinate to connect this widget with the previous one.

set_text(text)[source]

Se the text of the label.

class posydon.visualization.VH_diagram.GraphVisualizer.GraphVisualizerPointDraw[source]

Bases: QWidget

Define an empty widget with a point drew.

Initialize a GraphVisualizerPointDraw instance.

paintEvent(event)[source]

Paint an event.

class posydon.visualization.VH_diagram.GraphVisualizer.GraphVisualizerState[source]

Bases: GraphVisualizerItem

Widget containing drawings.

Provides the ability to display 4 texts on top & bottom.

Initialize a GraphVisualizerState instance.

get_attach_point_bot()[source]

Get coordinate to connect this widget with the next one.

get_attach_point_top()[source]

Get coordinate to connect this widget with the previous one.

paintEvent(event)[source]

Paint the event.

resizeEvent(event)[source]

Resize the event.

set_bot_text(text, index)[source]

Se the text of the bottom label.

set_distance(dist)[source]

Set the distance.

set_event(filename)[source]

Load the picture ‘filename’ and resize it if needed.

Parameters:

filename (str) – Name (+ path) to the picture.

Returns:

Indicate if loading & resize success.

Return type:

bool

set_first_star(filename)[source]

Load the picture ‘filename’ and resize it if needed.

Parameters:

filename (str) – Name (+ path) to the picture.

Returns:

Indicate if loading & resize success.

Return type:

bool

set_second_star(filename)[source]

Load the picture ‘filename’ and resize it if needed.

Parameters:

filename (str) – Name (+ path) to the picture.

Returns:

Indicate if loading & resize success.

Return type:

bool

set_top_text(text, index)[source]

Set the text of the top label.

class posydon.visualization.VH_diagram.GraphVisualizer.GraphVisualizerTimeline(grid, column_id, column_span=1)[source]

Bases: GraphVisualizercolumn

Draw a visual column, compressed by another other column.

Initialize a GraphVisualizerTimeline instance.

draw(surface)[source]

Draw the surface.

class posydon.visualization.VH_diagram.GraphVisualizer.GraphVisualizercolumn(grid, column_id, column_span)[source]

Bases: object

Mother-class of visual column in GraphVisualizer.

Manage one visual column in the QGridLayout (can take several logical columns).

Initialize a GraphVisualizercolumn instance.

Parameters:
  • grid (QGridLayout) – Grid where column take place.

  • column_id (int) – Unique id of this column.

  • column_span (int) – Number of logical column used.

add_item(item)[source]

Add one item in the column, connect it to previous if needed.

Parameters:

item (GraphVisualizerItem) – Widget to add in column.

clear()[source]

Delete all widget in the column, keep the title.

get_id()[source]

Return the column id.

reset()[source]

Delete everythings (widget + title), reset logical column used.

set_title(title)[source]

Set the title.

skip()[source]

Skip one row.

class posydon.visualization.VH_diagram.GraphVisualizer.INFOSTYPE(value)[source]

Bases: Enum

Enumeration of different type of infos.

CASE = 1
POINT = 2
STATE = 3
class posydon.visualization.VH_diagram.GraphVisualizer.Infos(column_id, infos_type, connected)[source]

Bases: object

Mother-class with common informations uselful for all widget.

Initialize an Infos instance.

column_id: int
connected: bool
infos_type: INFOSTYPE
class posydon.visualization.VH_diagram.GraphVisualizer.PointInfos(column_id, text: str = '')[source]

Bases: Infos

Informations to create a widget with a point drew.

Initialize a PointInfos instance.

text: str
class posydon.visualization.VH_diagram.GraphVisualizer.StateInfos(column_id, *, S1_filename=None, S2_filename=None, event_filename=None, distance=1)[source]

Bases: Infos

Information to create a widget with a line of diagram inside.

Initialize a StateInfos instance.

S1_filename: str
S2_filename: str
bot_texts: list
distance: int
event_filename: str
top_texts: list
class posydon.visualization.VH_diagram.GraphVisualizer.columnTYPE(value)[source]

Bases: Enum

Enumeration of different column type.

CONNECTED = 2
TIMELINE = 1
posydon.visualization.VH_diagram.GraphVisualizer.prepare_case(infos: CaseInfos)[source]

Help to create GraphVisualizerCase from CaseInfos.

Parameters:

infos (CaseInfos) – Infos to create the widget.

Returns:

Created widget with given infos.

Return type:

GraphVisualizerCase

posydon.visualization.VH_diagram.GraphVisualizer.prepare_point(infos: PointInfos)[source]

Help to create GraphVisualizerPoint from PointInfos.

Parameters:

infos (PointInfos) – Infos to create the widget.

Returns:

Created widget with given infos.

Return type:

GraphVisualizerPoint

posydon.visualization.VH_diagram.GraphVisualizer.prepare_state(infos: StateInfos)[source]

Help to create GraphVisualizerState from StateInfos.

Parameters:

infos (StateInfos) – Infos to create the widget.

Returns:

Created widget with given infos.

Return type:

GraphVisualizerState

posydon.visualization.VH_diagram.MainWindow

Main Window handler for VH diagram.

class posydon.visualization.VH_diagram.MainWindow.MainWindow[source]

Bases: QMainWindow

Custom window to display the application.

Initialize a MainWindow instance.

closeEvent(event)[source]

Close the option window.

save_requiered

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

start_visualization()[source]

Star the visualization.

Returns:

Return the interface with current window, binded visualizer widget and option window. Expose callbacks.

Return type:

VisualizerInterface

class posydon.visualization.VH_diagram.MainWindow.VisualizerInterface(main_win, visualizer, options)[source]

Bases: object

Handle for all callback triggered by user.

Initialize a VisualizerInterface instance.

Parameters:
detail_required()[source]
diagram_required()[source]
distance_representation_required()[source]
options()[source]
reduce_required()[source]
save_required()[source]
simplify_required()[source]

posydon.visualization.VH_diagram.MathTextLabel

Provide LaTeX-interpreted labels in the VH diagram.

class posydon.visualization.VH_diagram.MathTextLabel.MathTextLabel(parent=None, **kwargs)[source]

Bases: QWidget

Custom label to display LaTeX formula.

Initialize a MathTextLabel instance.

setText(text)[source]

Set the diplayed text.

Parameters:

text (str) – Text to display, interpreted as LaTeX formula.

posydon.visualization.VH_diagram.OptionsWindow

Options Window handler for the VH diagram.

class posydon.visualization.VH_diagram.OptionsWindow.OptionsWindow[source]

Bases: QWidget

Window to display available options, emit signal for selected option.

Initialize a OptionsWindow instance.

detail_requiered

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

diagram_required

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

distance_representation_required

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

reduce_required

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

set_distance_representation(state: bool)[source]

Set the distance representation.

set_showed_mode(mode: PresenterMode)[source]

Set the showed mode.

simplify_required

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

posydon.visualization.VH_diagram.ParseDataFrame

Counting distincts occurence of binary simulation from a file

class posydon.visualization.VH_diagram.ParseDataFrame.ParseDataFrame(filename, path='./', key='history', column_list=['state', 'event', 'S1_state', 'S2_state'], index_name='binary_index', start=None, stop=None, chunk_size=500000)[source]

Bases: object

Handle the binary parsing

get_frequencies()[source]
get_most_numpy(k)[source]
parse_dataf_gb_iter_chunk(index_list, cnt)[source]

a more relevant parser imo but turns out to take more time than than groupby/apply

posydon.visualization.VH_diagram.Presenter

Data visualization in VH diagram.

class posydon.visualization.VH_diagram.Presenter.Presenter(filename, path='./')[source]

Bases: object

Charged to setup window and format data before calling display funcs.

Initialize a Presenter instance.

PATH_TO_DRAWS = '/home/runner/work/POSYDON/POSYDON/POSYDON/posydon/visualization/VH_diagram/draws'
PATH_TO_SCREENS = '/home/runner/work/POSYDON/POSYDON/POSYDON/docs/screens'
close()[source]

Close the window.

present(index, mode=PresenterMode.DETAILED)[source]

Preset the binary.

screen()[source]

Take a screen of the displayed window.

class posydon.visualization.VH_diagram.Presenter.SimplifiedInfo(state_before=None, state_after=None)[source]

Bases: object

Simple class to store an before/after info and simplfy dataframe.

Parameters:
  • state_before (any value) – Value for the older state.

  • state_after (any value) – Value for the younger state.

state_before
state_after

Initialize a SimplifiedInfo instance.

posydon.visualization.VH_diagram.Presenter.calculate_separation(data)[source]

For each row in dataframe, calculate the separation.

Parameters:

data (pandas.DataFrame) – Complete dataframe without ‘separation’.

Returns:

Array of calculated separations, len(array) == nb rows.

Return type:

Array of float

posydon.visualization.VH_diagram.Presenter.combine_simplified_data(*, data_to, data_from)[source]

Combine 2 dictionaries of SimplifiedInfo.

data_to[].state_after take the value of data_from[].state_before.

Parameters:
  • data_to (dictionary of SimplifiedInfo) – Informations who will be udpated.

  • data_from (dictionary of SimplifiedInfo) – Informations who will be combined.

posydon.visualization.VH_diagram.Presenter.equal_with_epsilon(nb_1, nb_2, epsilon)[source]

Check if 2 numbers are equal up to epsilon.

Parameters:
  • nb_1 (int, float, double) – Value 1 to compare.

  • nb_2 (int, float, double) – Value 2 compare.

  • epsilon (int, float, double) – Difference allowed.

Returns:

True if numbers are equal up to epsilon, False if not.

Return type:

bool

posydon.visualization.VH_diagram.Presenter.file_exist(filename)[source]

Check if file exists.

posydon.visualization.VH_diagram.Presenter.get_event_state_filename(left_star_state, event_state, right_star_state, *, suffix='')[source]

Get the name of the file illustrating the event with the 2 given star.

Parameters:
  • left_star_state (str) – State’s name of the left star.

  • event_state (str) – State’s name of the event.

  • right_star_state (type) – State’s name of the right star.

Returns:

Name of the file illustrating this complete state.

Return type:

str

posydon.visualization.VH_diagram.Presenter.get_max_distance(data)[source]

Get max distance from a dictionary of SimplifiedInfo.

Parameters:

data (dictionnary of SimplifiedInfo) – Dictionnary, full of SimplifiedInfo, containing all infos

Returns:

Max distance of this row, accroding to before/after state

Return type:

float

posydon.visualization.VH_diagram.Presenter.get_star_state_filename(state, *, suffix='')[source]

Get the name of the file illustring the state of one star.

Parameters:

state (str) – State name of the star.

Returns:

Name of the file illustrating this state.

Return type:

str

posydon.visualization.VH_diagram.Presenter.to_megayears(nb)[source]

Convert yr to Myr.

posydon.visualization.VH_diagram.Presenter.to_simplified_data(row)[source]

Convert dictionnary of SimplifiedInfo with values as .state_before.

Parameters:

row (dictionnary) – Dictionnary of value to convert.

Returns:

Dictionnary of SimplifiedInfo containing the value as SimplifiedInfo.state_before.

Return type:

dictionnary of SimplifiedInfo

posydon.visualization.VH_diagram.PresenterMode

The definition of the PresenterMode class in VH diagram.

class posydon.visualization.VH_diagram.PresenterMode.PresenterMode(value)[source]

Bases: Enum

The different view for the Presenter.

DETAILED = 4
DIAGRAM = 1
REDUCED = 2
SIMPLIFIED = 3

posydon.visualization.VH_diagram.PresenterMultiple

class posydon.visualization.VH_diagram.PresenterMultiple.Presenter_h(filename, path='./', frequency=None)[source]

Bases: Presenter

Handles drawing binaries as hierarchical trees

Initialize a Presenter instance.

present_h(indexes, mode=None)[source]

Preset the binary.

class posydon.visualization.VH_diagram.PresenterMultiple.Presenter_m(filename, path='./', frequency=None)[source]

Bases: Presenter

Handle multiple Diagram view

Initialize a Presenter instance.

present_m(indexes, mode=PresenterMode.DETAILED)[source]

Preset the binary.

class posydon.visualization.VH_diagram.PresenterMultiple.VHdiagramm_m(filename, path='./', index=[0], *, frequency=None, hierarchy=False, presentMode=PresenterMode.DIAGRAM, displayMode=DisplayMode.WINDOW, figsize=(10, 8))[source]

Bases: object

Handle a multiple or hierarchical VH diagram plot.

Initialize a VHdiagram_m instance.

get_sorted_index()[source]

posydon.visualization.VH_diagram.SimulationModel

The definition of the SimulationModel class.

class posydon.visualization.VH_diagram.SimulationModel.SimulationModel(filename, path='./')[source]

Bases: object

Model containing the dataset of simulations.

Initialize a SimulationModel instance.

get_by_binary_index(index)[source]

Return a copy of dataframe’s slice with binary_index == index.

Parameters:

index (int) – Binary index wanted.

Returns:

Copy of a sub-dataframe with binary_index == index

Return type:

pandas.DataFrame

load_csv()[source]

Load dataframe as CSV with .gz compression.