Skip to content

dvexporter

SliceType module-attribute

SliceType: Type[int | Iterable[int] | slice] = Union[
    int, Iterable[int], slice, None
]

labels module-attribute

labels: Dict[str, str] = dict(
    index="Index",
    mixed_load_error="Mixed load error",
    mixed_loads="Number of mixed loads",
    integration_error="Integration error",
    integrations="Number of contact integrations",
)

DVExporter

Debug variables exporter

GroupBy class-attribute instance-attribute

GroupBy = Union[
    Mapping,
    Callable,
    str,
    Literal[
        "phase",
        "step",
        "mixedLoad",
        "integration",
        "increment",
        "plasticCorrection",
        "idx",
    ],
]

GroupStat class-attribute instance-attribute

GroupStat = Union[
    Callable, str, Literal["sum", "mean", "std", "min", "max", "count"]
]

_caches instance-attribute

_caches: Dict[str, ndarray] = {}

The caches.

_caches_with_index instance-attribute

_caches_with_index: Dict[str, ndarray] = {}

cache class-attribute instance-attribute

cache: LRUCache = LRUCache(maxsize=128)

The cache.

dv instance-attribute

dv: 'DebugVariable' = dv

__contains__

__contains__(field: str) -> bool

Check if the field is in the debug information.

__getitem__

__getitem__(field: str) -> ndarray

Get the debug information.

__init__

__init__(dv: 'DebugVariable')

_toDataFrame

_toDataFrame(field: str) -> 'DataFrame'

Get the debug information as a pandas DataFrame.

clear_cache

clear_cache()

Clear the cached data.

heatmap

heatmap(
    x: Literal["phase", "step", "mixedLoad", "integration"] | str = "step",
    y: Literal["phase", "step", "mixedLoad", "integration"] | str = "mixedLoad",
    z: (
        Literal[
            "mixed_load_error",
            "mixed_loads",
            "integration_error",
            "integrations",
        ]
        | str
    ) = "integrations",
    *,
    ax: Axes | None = None,
    props: dict | None = None,
    **kwargs
)

Plot a heatmap of the number of steps/mixed loads/integrations

PARAMETER DESCRIPTION
x

The x, y, z-axis to plot.

TYPE: Literal['phase', 'step', 'mixedLoad', 'integration'] | str DEFAULT: 'step'

y

The x, y, z-axis to plot.

TYPE: Literal['phase', 'step', 'mixedLoad', 'integration'] | str DEFAULT: 'step'

z

The x, y, z-axis to plot.

TYPE: Literal['phase', 'step', 'mixedLoad', 'integration'] | str DEFAULT: 'step'

ax

The axes to plot on.

TYPE: Axes DEFAULT: None

props

The properties to set on the axes.

TYPE: dict DEFAULT: None

kwargs

Keyword arguments passed to :meth:seaborn.heatmap.

DEFAULT: {}

plot

plot(
    *args: str | Literal["index", "phase", "step", "mixedLoad", "integration"],
    x: str | Literal["first", "auto"] = "auto",
    phase: SliceType | None = None,
    step: SliceType | None = None,
    mixedLoad: SliceType | None = None,
    integration: SliceType | None = None,
    increment: SliceType | None = None,
    plasticCorrection: SliceType | None = None,
    idx: SliceType | None = None,
    filters: dict[str, SliceType] | None = None,
    col: int | None = None,
    groupby: GroupBy | List[GroupBy] | None = None,
    groupby_kwargs: dict | None = None,
    groupby_stat: GroupStat | List[GroupStat] | Dict[str, GroupStat] = "sum",
    label: str = "{x} vs {y}",
    on: Plottable | None = None,
    ncols: int = 2,
    backend: Literal["matplotlib", "bokeh"] | None = None,
    subplots_kwargs: dict | None = None,
    line_kwargs: Iterable[Dict[str, Any]] | None = None,
    legend_kwargs: Dict | None = None,
    props: Dict[str, Any] | None = None,
    bokeh_show: bool = False,
    tight_layout: bool = True,
    **kwargs
) -> Union["MplFigure", "BkGridPlot"]

Plot anything from the debug information providing step, mixedLoad, integration, contact and col filters.

Notes

The following placeholders are supported for arguments label, kwargs and line_kwargs:

  • {x} and {y} for the name of the variable
PARAMETER DESCRIPTION
args

State variables to plot. If the number of arguments is an even number, multiple curves will be plotted with every two arguments as a pair of x and y. If the number of arguments is an odd number, the x will be the index number and the y will be all the arguments.

TYPE: str DEFAULT: ()

x

Variable to plot on x-axis, by default "auto".

  • "auto": the default strategy, the x variable depends on the number of arguments described above
  • "first": use the first variable as x, the rest variables in args as y
  • any other string: use the specified variable as x, all the variables in args as y

TYPE: str DEFAULT: 'auto'

phase

The phase to get.

TYPE: SliceType DEFAULT: None

step

The step to get.

TYPE: SliceType DEFAULT: None

mixedLoad

The mixed load to get.

TYPE: SliceType DEFAULT: None

integration

The integration to get.

TYPE: SliceType DEFAULT: None

increment

The increment to get.

TYPE: SliceType DEFAULT: None

plasticCorrection

The plastic correction to get.

TYPE: SliceType DEFAULT: None

idx

The index of the integration point to get.

TYPE: SliceType DEFAULT: None

filters

Additional filters, by default None

TYPE: dict[str, SliceType] DEFAULT: None

col

The value column of the array to plot.

TYPE: int DEFAULT: None

groupby

The groupby parameter to group the data, by default None

TYPE: Mapping | Callable | Grouper | Literal['phase', 'step', 'mixedLoad', 'integration'] | list DEFAULT: None

groupby_kwargs

Keyword arguments for the groupby function, by default None

TYPE: dict DEFAULT: None

groupby_stat

The statistic method to use for the groupby, by default "sum"

TYPE: Callable | str | Literal['sum', 'mean', 'std', 'min', 'max', 'count'] | list | dict DEFAULT: 'sum'

label

The label of the plot, by default "{x} vs {y}"

TYPE: str DEFAULT: '{x} vs {y}'

on

The axes to plot on. If not given, a new figure is created by calling :func:plt.gca.

TYPE: Plottable DEFAULT: None

ncols

Number of columns in the figure grid, by default 2

TYPE: int DEFAULT: 2

backend

Backend to use, by default None which means the backend set in the environment variable MICROMECHANICAL_PLOTTING_BACKEND.

TYPE: Literal['matplotlib', 'bokeh'] DEFAULT: None

subplots_kwargs

Keyword arguments for creating the subplots, by default None

TYPE: dict DEFAULT: None

line_kwargs

Line-specific keyword arguments, by default None

TYPE: Iterable[Dict[str, Any]] DEFAULT: None

legend_kwargs

Keyword arguments for the legend, by default None

TYPE: dict DEFAULT: None

props

The properties to set on the axes.

TYPE: dict DEFAULT: None

bokeh_show

Whether to show the figure in the browser, by default False

TYPE: bool DEFAULT: False

tight_layout

Whether to use tight layout in the matplotlib figure, by default True

TYPE: bool DEFAULT: True

kwargs

Keyword arguments passed to :meth:seaborn.lineplot.

  • The x argument is index by default;
  • The y argument is not supported and is always the field name, or {field}{col+1} if col is an integer.

DEFAULT: {}

RETURNS DESCRIPTION
Figure | GridPlot

The matplotlib figure or bokeh gridplot

toDataFrame

toDataFrame(
    field: str,
    *,
    phase: SliceType | None = None,
    step: SliceType | None = None,
    mixedLoad: SliceType | None = None,
    integration: SliceType | None = None,
    increment: SliceType | None = None,
    plasticCorrection: SliceType | None = None,
    idx: SliceType | None = None,
    **kwargs
) -> "DataFrame"

Get the debug information as a pandas DataFrame with filters. The data is stored in the field column for scalar fields. The filter parameters are used to filter the data, if an integer smaller than 0 is given, it will be converted to the maximum value of the index.

PARAMETER DESCRIPTION
field

The name of the field to get.

TYPE: str

phase

The phase to get.

TYPE: SliceType DEFAULT: None

step

The step to get.

TYPE: SliceType DEFAULT: None

mixedLoad

The mixed load to get.

TYPE: SliceType DEFAULT: None

integration

The integration to get.

TYPE: SliceType DEFAULT: None

increment

The increment to get.

TYPE: SliceType DEFAULT: None

plasticCorrection

The plastic correction to get.

TYPE: SliceType DEFAULT: None

idx

The index of the integration point to get.

TYPE: SliceType DEFAULT: None

kwargs

Additional filters.

DEFAULT: {}

_getattr

_getattr(dv: 'DebugVariable', field: str) -> List[Union['Scalar', 'Vector']]