fish2eod.analysis package

Submodules

fish2eod.analysis.plotting module

Plotting module for wrapping matplotlib with fish2eod data.

2D plots are “domain-like” 1D plots are “boundary-like”

fish2eod.analysis.plotting.extract(solution, variable, **kwargs)

Extract data from a solution given variable and parameter values.

Variable and parameters are set in the solution and the data is extracted from the h5 file

Parameters:
  • solution – fish2eod solution so load

  • variable – Name of the variable to load

  • kwargs – Optional parameters to extract from solution

Returns:

Extracted data

fish2eod.analysis.plotting.extract_edges(solution, variable, **kwargs)

Extract edges (boundaries) from the dataset.

Convenience to select plottable boundaries

Parameters:
  • solution (H5Solution) – fish2eod solution to use

  • variable (str) – Name of the variable to use

  • mask – Valid mask

  • kwargs – Optional parameters from solution

Returns:

Triangles and data for the selected data

fish2eod.analysis.plotting.field_norm(e_x, e_y)

Compute norm of a vector field.

Parameters:
  • e_x (ndarray) – x component of the field

  • e_y (ndarray) – y compoennt of the field

Return type:

ndarray

Returns:

Norm of the field

fish2eod.analysis.plotting.generate_mask(solution, include_domains=('water', 'body'), include=True, **kwargs)

Generate a Mask For the Domain name.

Masked nodes are removed from plot/analysis. When requesting include the masked nodes are flipped

Parameters:
  • solution (H5Solution) – Loaded solution object

  • include_domains (Tuple[str, ...]) – Tuple of domains to mask

  • include – Whether or not the domains included or excluded

Return type:

Tuple[int, ...]

Returns:

Valid matplotlib mask

fish2eod.analysis.plotting.generate_triangles(topology, geometry, mask=None)

Convert topology and geometry to triangles - optionally set mask as well.

Parameters:
  • topology – Topology of the triangles (connectivity)

  • geometry – Geometry of the triangles (location of the nodes)

  • mask (Optional[Sequence[bool]]) – Valid matplotlib mask

Return type:

Triangulation

Returns:

Triangulation object for plotting

fish2eod.analysis.plotting.generate_triangles_for_1d(solution, variable, mask=None, **kwargs)

Generate the triangle and data structure for 1d data (boundary-like).

Parameters:
  • solution (H5Solution) – Loaded solution object

  • variable (str) – Variable to extract

  • mask (Optional[Sequence[bool]]) – Valid mask

  • kwargs – Parameter selection for the solution

Return type:

Tuple[Triangulation, Any]

Returns:

Triangles and data for plotting

fish2eod.analysis.plotting.generate_triangles_for_2d(solution, variable, mask=None, **kwargs)

Generate the triangle and data structure for 2d data (domain-like).

Parameters:
  • solution (H5Solution) – Loaded solution object

  • variable (str) – Variable to extract

  • mask (Optional[Sequence[bool]]) – Valid mask

  • kwargs – Parameter selection for the solution

Return type:

Tuple[Triangulation, Any]

Returns:

Triangles and data for plotting

fish2eod.analysis.plotting.get_valid_nodes(triangles)

Get nodes in the mesh wish are valid (not masked).

Parameters:

triangles (Triangulation) – The triangulated mesh

Return type:

ndarray

Returns:

List of node ids outside of mask

fish2eod.analysis.plotting.gradient(solution, variable, *, gradient_norm=True, plot=True, color_style='equal', mask=None, **kwargs)

Compute and plot the gradient of a scalar field.

Parameters:
  • solution – The solution structure

  • variable – Name of the variable

  • gradient_norm – Should the norm be computed

  • plot – Should the data be plotted

  • color_style (Union[str, Sequence, None]) – How to symmetrize the colormap (False/None, ‘full’, ‘equal’)

  • mask – Valid matplotlib mask see generate_mask

  • kwargs

Return type:

Union[ndarray, Tuple[ndarray, ndarray]]

Returns:

Computed field as a scalar or vector field

fish2eod.analysis.plotting.mesh_plot_1d(solution, variable, *, color_style=None, colorbar=True, **kwargs)

Create a 1D mesh plot.

1D plots represent boundary functions

Parameters:
  • solution – fish2eod solution to plot

  • variable – Name of the variable to plot

  • cmap – Name of the colormap

  • color_style (Union[str, Sequence, None]) – Which type of symmetry see compute_norm

  • color – Color to use (if not data i.e. outline)

Returns:

None

fish2eod.analysis.plotting.mesh_plot_2d(solution, variable, *, color_style='equal', colorbar=True, mask=None, **kwargs)

Plot surface functions i.e. functions defined on the surface of the mesh or on the nodes.

Parameters:
  • solution – The solution structure

  • variable (str) – Name of the variable

  • color_style (Union[str, Sequence, None]) – How to symmetrize the colormap (False/None, ‘full’, ‘equal’)

  • colorbar (bool) – Should the colorbar be plotted

  • mask – Valid matplotlib mask see generate_mask

  • kwargs – Data subset parameters and matplotlib settings

fish2eod.analysis.plotting.normalize_color(triangles, data, color_style)

Compute a colormap for data based on color style.

color_style options:

Falsy (None, false, …): Standard color map from min(data) – max(data) “full”: Centers at 0 with the bounds being min(data), max(data). This does not have even positive and negative scales. I.e. for a red-blue map with range -1 to +10 then 0-10 will be white to red and -1 to 0 will be blue to white “equal” Symmetric color ranges with 0 at center. I.e. scale is from pm max(abs(data)) array-like [min, max] sets the colorbar to a preset range

Parameters:
  • triangles (Optional[Triangulation]) – Triangulated mesh

  • data – Data to normalized

  • color_style (Union[str, Sequence, None]) – What type of colormap

Return type:

Normalize

Returns:

Normalized map

fish2eod.analysis.plotting.plot_edges(g, **kwargs)

Plot solution edges as lines.

Parameters:
  • g – Coordinates of the edges

  • norm – Color normalization

  • colors – Which colors to use

Return type:

None

Returns:

None

fish2eod.analysis.plotting.plot_outline(solution, **kwargs)

Plot solution outline.

Parameters:
  • solution – fish2eod solution to plot

  • kwargs – Optional parameters from the solution

Return type:

None

Returns:

None

fish2eod.analysis.plotting.split_mpl_kwargs(tainted)

Split kwargs into valid mpl kwargs and internal fish2fem kwargs

Valid keys are determined by inclusion in the Line2D signature which should contain most common ones

Parameters:

tainted (Dict[str, Any]) – kwarg dictionary containing the mixture of kwargs

Return type:

Tuple[Dict[str, Any], Dict[str, Any]]

Returns:

Matplotlib kwargs and fish2fem kwargs dictionaries

fish2eod.analysis.plotting.upscale_parameter_name(normal_params)

Infer valid matplotlib parameters for line collection.

Line collection parameters have plural names of common parameters (i.e. color -> colors). Try every parameter with an additional ‘s’ and see it it fits a valid parameter name

Parameters:

normal_params (Dict[str, Any]) – Parameters with standard (color, linestyle, …) names

Return type:

Dict[str, Any]

Returns:

Parameters with pluralized (colors, linestyles, …) names

fish2eod.analysis.transdermal module

Compute transdermal potential (tdp).

Compute the tdp for the left and right sides. Images are computed when the input has already been subtracted.

fish2eod.analysis.transdermal.compute_transdermal_potential(model)

Compute the electric image.

TODO refactor this

Parameters:

model (BaseFishModel) – Saved model

Return type:

Iterable[Tuple[SkinStructure, TDP]]

Returns:

Iterator over skin and electric image as structs

fish2eod.analysis.transdermal.get_side_information(fish)
Return type:

Iterable[ComputatableSideInformation]

fish2eod.analysis.transdermal.get_skin_arc_length(coordinates)
Return type:

ndarray

fish2eod.analysis.transdermal.get_skin_coordinates(fish, skin_type, side)
Return type:

ndarray

fish2eod.analysis.transdermal.skin_potential(model, side_information)