Dataset widget to display the contents of a dataset.

Classes:

DatasetWidget([ds])

A widget to control the visualization of the variables in a dataset

DatasetWidgetPlugin(*args, **kwargs)

A DatasetWidget plugin for the psyplot GUI.

DatasetWidgetStandAlone([ds])

A DatasetWidget that is supposed to work as a standalone GUI

Functions:

get_dims_to_iterate(arr)

Get the dimensions of an array to iterate over

class psy_view.ds_widget.DatasetWidget(ds: Dataset | None = None, *args, **kwargs)[source]

Bases: QSplitter

A widget to control the visualization of the variables in a dataset

Methods:

addLayout(layout)

Add a layout to the splitter.

add_ds_item()

Add a new DatasetTreeItem for the current ds.

animate_backward()

Start the current animation in backward direction, or stop it.

animate_forward([nframes])

Start the current animation in forward direction, or stop it.

animation_frames()

Get the animation frames for the combo_dims dimension.

block_tree()

Block all signals of a tree temporarily.

block_widgets(*widgets)

Temporarilly block all signals for the given widgets.

change_combo_array()

Update the iteration dimension depending on the selected variable.

change_ds(ds_item)

Change the current dataset to another one.

clear_table()

Clear the table that shows the available dimensions.

close_current_plot()

Close the figure of the current variable.

close_sp()

Close the current subproject.

creating_new_plot()

Tell that we are making a new plot.

disable_navigation([but])

Disable the navigation buttons.

disable_variables()

Disable all variable selection buttons.

display_line(event)

Display the line when clicked on a 2D-plot.

enable_navigation()

Enable all navigation buttons again.

enable_variables()

Enable all variable selection buttons again.

excepthook(type, value, traceback)

A method to replace the sys.excepthook

expand_current_variable([variable])

Expand the item in the dataset tree of variable.

expand_ds_item(ds_item)

Expand an item of a dataset.

export_all_images()

Ask for a filename and export all plots to one (or more) files.

export_animation()

Ask for a filename and export the animation.

export_image()

Ask for a filename and export the current plot to a file.

export_project()

Ask for a filename and export the psyplot project as .pkl file.

export_project_with_data()

Ask for a filename export project (incl.

export_python()

Export the project as python file.

filter_sp(sp[, ds_only])

Filter the psyplot project to only include the arrays of ds

get_sp()

go_to_next_step()

Increase the movie dimension to the next step.

go_to_previous_step()

Decrease the movie dimension to the previous step.

increase_dim(dim[, increase])

Get a function to update a specific dimension.

load_preset(preset)

Load a given preset from disk.

load_variable_desc(item)

Load the description of the variable of a given tree item.

make_plot()

Make or update the plot of the current variable.

maybe_show_preset()

Show the name of the current preset if one is selected.

new_dimension_button(dim, label)

Generate a new button to increase of decrease a dimension.

new_plot()

Select a new variable and make a plot.

refresh([reset_combo])

Refresh the state of this widget.

reload()

Close the plot and recreate it.

replot(plotmethod)

Regenerate the plot of a given plotmethod, without closing it.

reset(plotmethod)

Close the plot of the given plotmethod and regenerate it.

reset_combo_array()

Clear and fill the iteration dimension based on ds.

reset_timer_interval(value)

Change the interval of the timer.

save_current_preset()

Save the preset of the current plot to a file.

save_full_preset()

Save the preset of all open plots to a file.

set_dataset([ds])

Ask for a file name and open the dataset.

setup_ds_tree()

Setup the number of columns and the header of the dataset tree.

setup_export_menu()

Set up the menu to export the current plot.

setup_plot_tabs()

Setup the tabs of the various plot methods.

setup_preset_menu()

Set up the menu to select/load presets.

setup_variable_buttons([ncols])

Setup the variable buttons for the current dataset.

showEvent(self, a0)

show_current_figure()

Show figure of the current plotmethod.

show_fig(sp)

Show the first figure in a psyplot project.

silence_variable_buttons()

Context manager to disable variable selection buttons.

start_animation([nframes])

Start the animation along the selected dimension.

stop_animation()

Stop the current animation.

switch_tab()

Select a valid variable when switching the plotmethod tabs.

unset_preset()

Unset the current preset and do not use it anymore.

update_dims(dims)

update_project(*args, **kwargs)

Update the correct project sp and refresh the widget.

Attributes:

animation

Get the animation of the current plotmethod.

arr_name

Get the name of the array of the current plot (if there is one).

available_plotmethods

Get the plotmethods that can visualize the selected variable.

data

Get the raw data of the current plot.

dock_position

Display the dock widget at the right side of the GUI

ds_attr_columns

Attributes to use in the dataset tree

ds_item

Get the current dataset item (if there is one).

ds_items

Get the DatasetTreeItems for the open datasets.

fig

Get the figure of the current plot.

open_datasets

Get a mapping from path to dataset number of the open datasets.

plot

Get the plotting function of the currently selected plotmethod.

plot_options

Get further keyword arguments for the plot function.

plotmethod

Get the name of the current plotmethod.

plotmethod_widget

Get widget of the current plotmethod.

plotmethod_widgets

Get a list of available plotmethod widgets.

plotmethods

Get a list of available plotmethods.

plotter

Get the psyplot plotter of the current plot.

preset

Get the currently loaded preset.

sp

Get the psyplot project of the current plotmethod.

title

The title of the widget

variable

The current variable

variable_buttons

Buttons for selecting variables in the ds

variable_frame

A PyQt5.QtWidgets.QGroupBox that contains the variable buttons

addLayout(layout: QLayout) QWidget[source]

Add a layout to the splitter.

This convenience function creates a new QWidget that wraps the given layout and returns it.

Parameters:

layout (QtWidget.QLayout) – The layout to add

Returns:

The widget that wraps the given layout

Return type:

QtWidgets.QWidget

add_ds_item() None[source]

Add a new DatasetTreeItem for the current ds.

animate_backward() None[source]

Start the current animation in backward direction, or stop it.

animate_forward(nframes=None)[source]

Start the current animation in forward direction, or stop it.

property animation: FuncAnimation | None

Get the animation of the current plotmethod.

animation_frames() Iterator[Dict[str, int]][source]

Get the animation frames for the combo_dims dimension.

property arr_name: str | None

Get the name of the array of the current plot (if there is one).

property available_plotmethods: List[str]

Get the plotmethods that can visualize the selected variable.

Returns:

A list of plotmethod names that can visualize the current variable

Return type:

list of str

block_tree() Iterator[None][source]

Block all signals of a tree temporarily.

Use this via:

with self.block_tree():
    do_something
block_widgets(*widgets: QWidget) Iterator[None][source]

Temporarilly block all signals for the given widgets.

change_combo_array() None[source]

Update the iteration dimension depending on the selected variable.

change_ds(ds_item: DatasetTreeItem) None[source]

Change the current dataset to another one.

Parameters:

ds_item (psyplot_gui.content_widget.DatasetTreeItem) – The item in the tree of the new dataset to use

cids: Dict[str, int]
clear_table() None[source]

Clear the table that shows the available dimensions.

close_current_plot() None[source]

Close the figure of the current variable.

close_sp() None[source]

Close the current subproject.

creating_new_plot() Iterator[None][source]

Tell that we are making a new plot.

property data: psyd.InteractiveList | DataArray

Get the raw data of the current plot.

disable_navigation(but: QPushButton | None = None) None[source]

Disable the navigation buttons.

This function disables all navigation buttons but the one you specify.

Parameters:

but (PyQt5.QtWidgets.QPushButton) – If not None, this button is not disabled.

disable_variables()[source]

Disable all variable selection buttons.

display_line(event: MouseEvent) None[source]

Display the line when clicked on a 2D-plot.

dock_position = 2

Display the dock widget at the right side of the GUI

ds: Dataset | None
ds_attr_columns: List[str] = ['long_name', 'dims', 'shape']

Attributes to use in the dataset tree

property ds_item: DatasetTreeItem | None

Get the current dataset item (if there is one).

property ds_items: List[DatasetTreeItem]

Get the DatasetTreeItems for the open datasets.

enable_navigation() None[source]

Enable all navigation buttons again.

enable_variables()[source]

Enable all variable selection buttons again.

excepthook(type, value, traceback) None[source]

A method to replace the sys.excepthook

expand_current_variable(variable: Any | Hashable | None = None) None[source]

Expand the item in the dataset tree of variable.

Parameters:

variable (str) – The name of the variable to expand. If None, the current variable is used.

expand_ds_item(ds_item: DatasetTreeItem) None[source]

Expand an item of a dataset.

Parameters:

ds_item (DatasetTreeItem) – The item to expand

export_all_images() None[source]

Ask for a filename and export all plots to one (or more) files.

export_animation() None[source]

Ask for a filename and export the animation.

export_image() None[source]

Ask for a filename and export the current plot to a file.

export_project() None[source]

Ask for a filename and export the psyplot project as .pkl file.

export_project_with_data() None[source]

Ask for a filename export project (incl. data) as .pkl file.

Same as export_project(), but adds the data to the pickle dump.

export_python()[source]

Export the project as python file.

This method is not yet implemented as the functionality is missing in psyplot.

property fig: Figure

Get the figure of the current plot.

filter_sp(sp: Project, ds_only: bool = False) Project[source]

Filter the psyplot project to only include the arrays of ds

get_sp() Project | None[source]
go_to_next_step() None[source]

Increase the movie dimension to the next step.

go_to_previous_step() None[source]

Decrease the movie dimension to the previous step.

increase_dim(dim: str, increase: int = 1) Callable[[], None][source]

Get a function to update a specific dimension.

Parameters:
  • dim (str) – The dimension name

  • increase (int) – The number of steps to increase (or decrease) the given dim.

load_preset(preset: str | Dict[str, Any] | None)[source]

Load a given preset from disk.

Parameters:

preset (str or dict) – The name or path to the preset, or a dictionary

load_variable_desc(item: QTreeWidgetItem) None[source]

Load the description of the variable of a given tree item.

Parameters:

item (PyQt5.QtWidget.QTreeWidgetItem) – The item of the variable in the ds_tree. If this is not an item of a variable, nothing is done.

make_plot() None[source]

Make or update the plot of the current variable.

See also

new_plot

A function to select the variable first

maybe_show_preset() None[source]

Show the name of the current preset if one is selected.

new_dimension_button(dim: Hashable, label: Any) QRightPushButton[source]

Generate a new button to increase of decrease a dimension.

new_plot() None[source]

Select a new variable and make a plot.

This method asks for a variable and them makes a new plot with the selected plotmethod.

See also

make_plot

plot the currently selected variable without asking

property open_datasets: Dict[int, Dataset]

Get a mapping from path to dataset number of the open datasets.

property plot: PlotterInterface

Get the plotting function of the currently selected plotmethod.

property plot_options: Dict[str, Any]

Get further keyword arguments for the plot function.

property plotmethod: str

Get the name of the current plotmethod.

property plotmethod_widget: PlotMethodWidget

Get widget of the current plotmethod.

property plotmethod_widgets: Dict[str, PlotMethodWidget]

Get a list of available plotmethod widgets.

property plotmethods: List[str]

Get a list of available plotmethods.

property plotter: Plotter

Get the psyplot plotter of the current plot.

property preset: Dict[str, Any]

Get the currently loaded preset.

refresh(reset_combo: bool = True) None[source]

Refresh the state of this widget.

This method refreshes the widget based on the selected project, variable, etc.

Parameters:

reset_combo (bool) – If True (default), the reset_combo_array() is called

reload() None[source]

Close the plot and recreate it.

replot(plotmethod: str) None[source]

Regenerate the plot of a given plotmethod, without closing it.

Parameters:

plotmethod (str) – The name of the plotmethod

See also

reset

The same method, but closes the plot before genereting a new one.

reset(plotmethod: str) None[source]

Close the plot of the given plotmethod and regenerate it.

The same as replot(), but closes the plot.

Parameters:

plotmethod (str) – The name of the plotmethod

See also

reset

The same method, but closes the plot before genereting a new one.

reset_combo_array() None[source]

Clear and fill the iteration dimension based on ds.

reset_timer_interval(value: int) None[source]

Change the interval of the timer.

save_current_preset() None[source]

Save the preset of the current plot to a file.

save_full_preset() None[source]

Save the preset of all open plots to a file.

set_dataset(ds: Dataset | None = None) None[source]

Ask for a file name and open the dataset.

setup_ds_tree() None[source]

Setup the number of columns and the header of the dataset tree.

setup_export_menu() QMenu[source]

Set up the menu to export the current plot.

setup_plot_tabs() None[source]

Setup the tabs of the various plot methods.

setup_preset_menu() QMenu[source]

Set up the menu to select/load presets.

setup_variable_buttons(ncols: int = 4) None[source]

Setup the variable buttons for the current dataset.

showEvent(self, a0: QShowEvent | None)[source]
show_current_figure() None[source]

Show figure of the current plotmethod.

show_fig(sp: Project) None[source]

Show the first figure in a psyplot project.

silence_variable_buttons() Iterator[None][source]

Context manager to disable variable selection buttons.

property sp: Project | None

Get the psyplot project of the current plotmethod.

start_animation(nframes: int | None = None)[source]

Start the animation along the selected dimension.

Parameters:

nframes (int or None) – If not None, the number of frames to draw

See also

animation_frames

The iterator to generate the frames

stop_animation() None[source]

Stop the current animation.

switch_tab() None[source]

Select a valid variable when switching the plotmethod tabs.

title: str = 'psy-view Plot Control'

The title of the widget

unset_preset() None[source]

Unset the current preset and do not use it anymore.

update_dims(dims: Dict[str, Any])[source]
update_project(*args, **kwargs) None[source]

Update the correct project sp and refresh the widget.

property variable: str

The current variable

variable_buttons: Dict[str, QtWidgets.QPushButton]

Buttons for selecting variables in the ds

variable_frame: QtWidgets.QGroupBox | None = None

A PyQt5.QtWidgets.QGroupBox that contains the variable buttons

class psy_view.ds_widget.DatasetWidgetPlugin(*args, **kwargs)[source]

Bases: DatasetWidget, DockMixin

A DatasetWidget plugin for the psyplot GUI.

This widget can be embeded in the psyplot GUI. Different from the standalone DatasetWidget class, this one here uses the current psyplot project (psyplot.project.gcp())

Attributes:

cids

dock_position

Display the dock widget at the right side of the GUI

ds

open_datasets

Get a mapping from path to dataset number of the open datasets.

sp

Get the psyplot project of the current plotmethod.

title

The title of the widget

variable_buttons

Buttons for selecting variables in the ds

Methods:

close_sp()

Close the current subproject.

oncpchange(sp)

Update this widget from the current psyplot main (or sub) project.

position_dock(main, *args, **kwargs)

Set the position of the dock widget

reload()

Close the plot and recreate it.

setup_ds_tree()

Setup the number of columns and the header of the dataset tree.

show_fig(sp)

Show the figure of the the current subproject.

cids: Dict[str, int]
close_sp() None[source]

Close the current subproject.

dock_position = 2

Display the dock widget at the right side of the GUI

ds: Dataset | None
oncpchange(sp: Project | None) None[source]

Update this widget from the current psyplot main (or sub) project.

property open_datasets: Dict[int, Dataset]

Get a mapping from path to dataset number of the open datasets.

position_dock(main: MainWindow, *args, **kwargs) None[source]

Set the position of the dock widget

This method places the plugin widget at the desired dock position (by default, indicated with the dock_position attribute)

Parameters:

main (psyplot_gui.main.Mainwindow) – The main window where the dock is added

reload() None[source]

Close the plot and recreate it.

setup_ds_tree() None[source]

Setup the number of columns and the header of the dataset tree.

Reimplemented to use the psyplot_gui.content_widget.DatasetTree

show_fig(sp: Project | None) None[source]

Show the figure of the the current subproject.

property sp: Project | None

Get the psyplot project of the current plotmethod.

title: str = 'psy-view Dataset viewer'

The title of the widget

variable_buttons: Dict[str, QtWidgets.QPushButton]

Buttons for selecting variables in the ds

class psy_view.ds_widget.DatasetWidgetStandAlone(ds: Dataset | None = None, *args, **kwargs)[source]

Bases: DatasetWidget

A DatasetWidget that is supposed to work as a standalone GUI

Attributes:

cids

ds

variable_buttons

Buttons for selecting variables in the ds

Methods:

closeEvent(event)

Reimplemented close event to stop the running QApplication.

cids: Dict[str, int]
closeEvent(event: Any)[source]

Reimplemented close event to stop the running QApplication.

ds: Dataset | None
variable_buttons: Dict[str, QtWidgets.QPushButton]

Buttons for selecting variables in the ds

psy_view.ds_widget.get_dims_to_iterate(arr: DataArray) List[str][source]

Get the dimensions of an array to iterate over

This function takes a data array and returns the dimension in the base dataset that one can interator over.

Parameters:

arr (xarray.DataArray) – The data array to iterate over

Returns:

The dimension strings

Return type:

list of strings