Dataset widget to display the contents of a dataset.
Classes:
|
A widget to control the visualization of the variables in a dataset |
|
A |
|
A |
Functions:
|
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 a new
DatasetTreeItem
for the currentds
.Start the current animation in backward direction, or stop it.
animate_forward
([nframes])Start the current animation in forward direction, or stop it.
Get the animation frames for the
combo_dims
dimension.Block all signals of a tree temporarily.
block_widgets
(*widgets)Temporarilly block all signals for the given widgets.
Update the iteration dimension depending on the selected variable.
change_ds
(ds_item)Change the current dataset to another one.
Clear the table that shows the available dimensions.
Close the figure of the current variable.
close_sp
()Close the current subproject.
Tell that we are making a new plot.
disable_navigation
([but])Disable the navigation buttons.
Disable all variable selection buttons.
display_line
(event)Display the line when clicked on a 2D-plot.
Enable all navigation buttons again.
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.
Ask for a filename and export all plots to one (or more) files.
Ask for a filename and export the animation.
Ask for a filename and export the current plot to a file.
Ask for a filename and export the psyplot project as .pkl file.
Ask for a filename export project (incl.
Export the project as python file.
filter_sp
(sp[, ds_only])Filter the psyplot project to only include the arrays of
ds
get_sp
()Increase the movie dimension to the next 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 or update the plot of the current variable.
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.
Clear and fill the iteration dimension based on
ds
.reset_timer_interval
(value)Change the interval of the timer.
Save the preset of the current plot to a file.
Save the preset of all open plots to a file.
set_dataset
([ds])Ask for a file name and open the dataset.
Setup the number of columns and the header of the dataset tree.
Set up the menu to export the current plot.
Setup the tabs of the various plot methods.
Set up the menu to select/load presets.
setup_variable_buttons
([ncols])Setup the variable buttons for the current dataset.
showEvent
(self, a0)Show figure of the current plotmethod.
show_fig
(sp)Show the first figure in a psyplot project.
Context manager to disable variable selection buttons.
start_animation
([nframes])Start the animation along the selected dimension.
Stop the current animation.
Select a valid variable when switching the plotmethod tabs.
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:
Get the animation of the current plotmethod.
Get the name of the array of the current plot (if there is one).
Get the plotmethods that can visualize the selected variable.
Get the raw data of the current plot.
Display the dock widget at the right side of the GUI
Attributes to use in the dataset tree
Get the current dataset item (if there is one).
Get the
DatasetTreeItems
for the open datasets.Get the figure of the current plot.
Get a mapping from path to dataset number of the open datasets.
Get the plotting function of the currently selected plotmethod.
Get further keyword arguments for the
plot
function.Get the name of the current plotmethod.
Get widget of the current plotmethod.
Get a list of available plotmethod widgets.
Get a list of available plotmethods.
Get the psyplot plotter of the current plot.
Get the currently loaded preset.
Get the psyplot project of the current plotmethod.
The title of the widget
The current variable
Buttons for selecting variables in the
ds
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
- 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 available_plotmethods: List[str]
Get the plotmethods that can visualize the selected variable.
- 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
- property data: psyd.InteractiveList | DataArray
Get the raw data of the current plot.
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.
- dock_position = 2
Display the dock widget at the right side of the GUI
- 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 all navigation buttons again.
- 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_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
- increase_dim(dim: str, increase: int = 1) Callable[[], None] [source]
Get a function to update a specific dimension.
- 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
- 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 plotmethod_widget: PlotMethodWidget
Get widget of the current plotmethod.
- property plotmethod_widgets: Dict[str, PlotMethodWidget]
Get a list of available plotmethod widgets.
- property plotter: Plotter
Get the psyplot plotter of the current plot.
- 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
- 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.
Set up the menu to export the current plot.
Set up the menu to select/load presets.
- setup_variable_buttons(ncols: int = 4) None [source]
Setup the variable buttons for the current dataset.
- silence_variable_buttons() Iterator[None] [source]
Context manager to disable variable selection buttons.
- 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
- 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:
Display the dock widget at the right side of the GUI
Get a mapping from path to dataset number of the open datasets.
Get the psyplot project of the current plotmethod.
The title of the widget
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 the number of columns and the header of the dataset tree.
show_fig
(sp)Show the figure of the the current subproject.
- dock_position = 2
Display the dock widget at the right side of the GUI
- 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
- 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
- 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 GUIAttributes:
Buttons for selecting variables in the
ds
Methods:
closeEvent
(event)Reimplemented close event to stop the running
QApplication
.
- 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