beetroots.inversion.plots package

Submodules

beetroots.inversion.plots.map_shaper module

class beetroots.inversion.plots.map_shaper.MapShaper(df: DataFrame)[source]

Bases: object

Defines the transformation from a vector to an map. Necessary for non-rectangular maps.

Parameters:

df (pandas.DataFrame) – should have (x, y) coordinates in the index and one “idx” column to define the transformation

N

number of pixels in map, i.e., dimension of vectors

Type:

int

from_vector_idx_to_map_coords(idx: List[int]) Dict[int, ndarray][source]

transforms vector index in map coordinates

Parameters:

idx (numpy.array of shape (N,) or (N, -1)) – vector or tensor to be reshaped

Returns:

x_shaped – information of x shaped for plotting

Return type:

numpy.array

Raises:

ValueError – if x has an invalid shape

from_vector_to_map(x: ndarray) ndarray[source]

applies a reshaping for a vector to plot it in 2D

Parameters:

x (numpy.array of shape (N,) or (N, -1)) – vector or tensor to be reshaped

Returns:

x_shaped – information of x shaped for plotting

Return type:

numpy.array

Raises:

ValueError – if x has an invalid shape

index_arr

map that contains the indices of the vector entries

Type:

2D np.ndarray

beetroots.inversion.plots.plots_2d module

class beetroots.inversion.plots.plots_2d.AbstractPlots2D(map_shaper: MapShaper, pixels_of_interest: Dict[int, str] = {})[source]

Bases: ABC

abstract class for drawing figures of maps of observations, noise standard deviations, estimated physical parameters, estimated credibility interval sizes, etc.

map_shaper

defines the transformation from vectors to 2D maps

Type:

MapShaper

pixels_of_interest_coords

coordinates of some user-informed pixels to be highlighted. These pixels will be outlines with a black square in figures.

Type:

list

pixels_of_interest_names

(coordinate, name) pair of some user-informed pixels to be highlighted. These pixels will be outlines with a black square in figures.

Type:

dict

beetroots.inversion.plots.plots_2d_setup module

class beetroots.inversion.plots.plots_2d_setup.Plots2DSetup(path_img: str, map_shaper: MapShaper, N: int, pixels_of_interest: Dict[int, str] = {})[source]

Bases: AbstractPlots2D

utilitary class that draws and saves maps related to the inference setup.

N

number of pixels in the maps, i.e., dimension of the observation vectors

Type:

int

map_shaper

defines the transformation from vectors to 2D maps

Type:

MapShaper

path_img

path to the folder in which the figures are to be saved

Type:

str

pixels_of_interest_coords

coordinates of some user-informed pixels to be highlighted. These pixels will be outlines with a black square in figures.

Type:

list

pixels_of_interest_names

(coordinate, name) pair of some user-informed pixels to be highlighted. These pixels will be outlines with a black square in figures.

Type:

dict

plot_all(y: ndarray, sigma_a: ndarray, omega: ndarray, list_lines: list, dict_sites_: dict[int, ndarray]) None[source]

runs all the class methods, i.e., plots and saves the maps of the observations \(y\), of the additive noise standard deviation \(\sigma_a\), of the signal-to-noise ratio \(y : \sigma_a\), of censored pixels. It also plots and saves the map of proportion of censored observables per pixel, the map of indices and of spatial prior sites.

Parameters:
  • y (np.ndarray of shape (N, L)) – observation vector of \(N\) pixels and \(L\) lines.

  • sigma_a (np.ndarray of shape (N, L)) – vector containing the additive noise standard deviations of each of the \(N\) pixels and \(L\) lines.

  • omega (np.ndarray of shape (N, L)) – vector of censorship limits.

  • list_lines (list) – list of the names of the observed lines

  • dict_sites (dict[int, np.ndarray]) – dictionary of sites (see spatial prior modules).

plot_censored_lines_proportion(y: ndarray, omega: ndarray, folder_path: str) None[source]

plots the map of the proportion of censored observables per pixel. Only relevant for likelihood models involving censorship.

Parameters:
  • y (np.ndarray of shape (N, L)) – observation vector of \(N\) pixels and \(L\) lines.

  • omega (np.ndarray of shape (N, L)) – vector of censorship limits.

  • folder_path (str) – path to the folder where the figure is to be saved

plot_indices_map() None[source]

plots and saved a map of the indices. Simplifies the choice of pixels of interest.

plot_mask_censored_pixels(y: ndarray, omega: ndarray, list_lines: list, folder_path: str) None[source]

plots and saves the map of censored pixels for each line

Parameters:
  • y (np.ndarray of shape (N, L)) – observation vector of \(N\) pixels and \(L\) lines.

  • omega (np.ndarray of shape (N, L)) – vector of censorship limits.

  • list_lines (list) – list of the names of the observed lines

  • folder_path (str) – path to the folder where the figure is to be saved

plot_observations(y: ndarray, list_lines: list, folder_path: str) None[source]

plots the observation map for each line in list_lines, and saves the figure.

Parameters:
  • y (np.ndarray of shape (N, L)) – observation vector of \(N\) pixels and \(L\) lines.

  • list_lines (list) – list of the lines to plot

  • folder_path (str) – path to the folder where the figure is to be saved

plot_sigma_a(sigma_a: ndarray, list_lines: list, folder_path: str) None[source]

plots and saves the maps of standard deviations for each of the \(L\) observables.

Parameters:
  • sigma_a (np.ndarray of shape (N, L)) – vector containing the additive noise standard deviations of each of the \(N\) pixels and \(L\) lines.

  • list_lines (list) – list of the names of the observed lines

  • folder_path (str) – path to the folder where the figures are to be saved

plot_sites_map(dict_sites_: dict[int, ndarray]) None[source]

plots the map of sites defined from the spatial prior. The pixels within one site are all sampled in parallel in the MTM-chromatic Gibbs sampling kernel (see beetroots.sampler.my_sampler.MySampler)

Parameters:

dict_sites (dict[int, np.ndarray]) – dictionary of sites (see spatial prior modules).

plot_snr_add(y: ndarray, sigma_a: ndarray, list_lines: list, folder_path: str) None[source]

plots and saves the maps of signal-to-noise ratio (SNR) for each of the \(L\) observables. For one pixel \(n\) and one line \(\ell\), the SNR is defined as \(y_{n\ell} / \sigma_{a,n\ell}\) with \(y_{n\ell}\) the observed value and \(\sigma_{a,n\ell}\) the additive noise standard deviation.

Parameters:
  • y (np.ndarray of shape (N, L)) – observation vector of \(N\) pixels and \(L\) lines.

  • sigma_a (np.ndarray of shape (N, L)) – vector containing the additive noise standard deviations of each of the \(N\) pixels and \(L\) lines.

  • list_lines (list) – list of the names of the observed lines

  • folder_path (str) – path to the folder where the figures are to be saved

beetroots.inversion.plots.plots_estimator module

class beetroots.inversion.plots.plots_estimator.PlotsEstimator(map_shaper: MapShaper, list_names: List[str], lower_bounds_lin: ndarray, upper_bounds_lin: ndarray, list_idx_sampling: List[int], pixels_of_interest: Dict[int, str] = {})[source]

Bases: AbstractPlots2D

utilitary class that draws and saves maps related to the inference results.

list_idx_sampling

contains the indices of the physical parameters to be sampled

Type:

1D np.ndarray

list_names

physical parameter names

Type:

list

lower_bounds_lin

contains the lower bounds in linear scale on the physical parameters

Type:

1D np.ndarray

map_shaper

defines the transformation from vectors to 2D maps

Type:

MapShaper

pixels_of_interest_coords

coordinates of some user-informed pixels to be highlighted. These pixels will be outlines with a black square in figures.

Type:

list

pixels_of_interest_names

(coordinate, name) pair of some user-informed pixels to be highlighted. These pixels will be outlines with a black square in figures.

Type:

dict

plot_CI_size(Theta_ci_size: ndarray, CI_name: str, folder_path: str) None[source]

plots the map of credibility interval sizes for a physical parameter

Parameters:
  • Theta_ci_size (np.ndarray of shape (N, D)) – vector of credibility interval sizes for the D physical parameters

  • CI_name (str) – name of the credibility interval, e.g., “95%” or “99%”

  • folder_path (str) – path to the folder where the figure is to be saved

plot_CI_size_u(u_ci_size, CI_name, folder_path: str, model_name: str | None = '', list_lines: List[str] = [])[source]

Only used in hierarchical models. The sampling of such model is not implemented.

plot_estimator(Theta_estimated: ndarray, estimator_name: str, folder_path: str, model_name: str | None = '')[source]

plots and saves the 2D map of an estimated physical parameter

Parameters:
  • Theta_estimated (np.ndarray of shape (N, D)) – vector of the estimated physical parameter

  • estimator_name (str) – name of the estimator, e.g., “MAP” or “MMSE”

  • folder_path (str) – path to the folder where the figure is to be saved

  • model_name (Optional[str], optional) – name of the model (not used here, kept for compatibility), by default “”

plot_estimator_u(u_estimated: ndarray, estimator_name: str, folder_path: str, model_name: str | None = '', list_lines: List[str] = [])[source]

Only used in hierarchical models. The sampling of such model is not implemented.

upper_bounds_lin

contains the upper bounds in linear scale on the physical parameters

Type:

1D np.ndarray

beetroots.inversion.plots.readable_line_names module

Former version of the latex-ism-emission-lines package by L. Einig available at https://github.com/einigl/latex-ism-emission-lines/tree/main.

beetroots.inversion.plots.readable_line_names.lines_to_latex(line_name: str) str[source]

Returns a well displayed version of the formatted line line_name.

Parameters:

line_name (str) – Formatted line.

Returns:

LaTeX string representing line_name.

Return type:

str

Module contents