VisualArt

Visualization

class VisualArt.VisualArt

Bases: object

initGas(mech_path)

instantiate cantera.Solution object

Parameters

mech_path (str) – mechanism input file, could be .yaml, .xml or .cti format.

phaseDiagram(input, label, delta_t, data_name, size_show=500000, dpi=200)

Draw and save the phase diagram of a chemical dataset (TPY).

Parameters
  • input (str or numpy.ndarray) – Input dataset.

  • label (str or numpy.ndarray) – Label dataset.

  • delta_t (float) – Time step between input and label.

  • data_name (str) – The name of dataset, will be used when saving figures.

  • size_show (int, optional) – Random pick samples in dataset to show. Default 500,000.

  • dpi (int, optional) – The dpi used to save figure. Default 200.

static _subplotPhaseSave(fig, plt, points, data_name, dim, pic_folder, dpi)

The built-in function to save phase diagram.

singleDisplot(input, data_name, scale, plot_dims='all', ignore_negative=True, size_show=500000, offset=10, dpi=200)

Draw and save the distribution diagram of a chemical dataset (TPY). If plot_dims=’all’, Each figure contains 9 subplots. Else, each figure contains one subplot.

Parameters
  • input (str or numpy.ndarray) – Input dataset which should be non-negative.

  • data_name (str) – The name of dataset, will be used when saving figures.

  • scale (str) – Data scale, could be ‘log’, ‘lin’ or ‘bct’.

  • plot_dims (str or list, optional) – List of dimensions expected to be plotted, e.g. [1,4,5,7] or Range(20) or [‘T’,’O’,’CH4’,’N2’]. Default string ‘all’ means plotting all the dimensions and every 9 subplots in one figure.

  • ignore_negative (bool, optinal) – Whether ignore negative values in the input dataset. Default True.

  • size_show (int, optional) – Random pick samples in dataset to show. Default 500,000.

  • offset (int,optional) – Approximate display range for species under log scale. For instance, \([10^{x}, 10^{x+offset}]\). Default 10.

  • dpi (int) – The dpi used to save figure.

static _subplotDisSave(plt, pic_fold, data_name, scale, dim, dpi)

The built-in function to save distribution.

doubleDisplot(input1, input2, label_text1, label_text2, data_name, scale, plot_dims='all', ignore_negative=True, size_show=500000, offset=10, dpi=200)

Draw and save the distribution diagram of two chemical datasets (TPY). If plot_dims=’all’, Each figure contains 9 subplots. Else, each figure contains one subplot.

Parameters
  • input1 (str or numpy.ndarray) – Dataset 1 which should be non-negative.

  • input2 (str or numpy.ndarray) – Dataset 2 which should be non-negative.

  • label_text1 (str) – Legend of dataset 1.

  • label_text2 (str) – Legend of dataset 2.

  • data_name (str) – The datasets name, will be used when saving figures.

  • scale (str) – Data scale, could be ‘log’, ‘lin’ or ‘bct’.

  • plot_dims (str or list, optional) – List of dimension expected to be plotted, e.g. [1,4,5,7] or Range(20) or [‘T’,’O’,’CH4’,’N2’]. Default string ‘all’ means plotting all the dimensions and every 9 subplots in one figure.

  • ignore_negative (bool, optional) – Whether ignore negative values in dataset. Default True.

  • size_show (int, optional) – Random pick samples in dataset to show. Default 500,000.

  • offset (int,optional) – Approximate display range for species under log scale. For instance, \([10^{x}, 10^{x+offset}]\). Default 10.

  • dpi (int) – The dpi used to save figure.

static _subplotDoubleDisSave(plt, pic_fold, data_name, scale, dim, dpi)

The built-in function to save double dataset distribution diagram.

static _preCheckBeforePlot(input, scale, ignore_negative)

Check dataset whether contain negative values. If there exists negative values in the dataset, raise warning. If scale is not in [‘log’,’lin’,’bct’], raise TypeError.

Parameters
  • input (str or numpy.ndarray) – The chemical dataset. If input is str, then input=np.load(input).

  • scale (str) – Data scale, could be ‘lin’, ‘log’ or ‘bct’.

  • ignore_negative (bool) – Whether ignore negative values in dataset.

static _logDegree(data, offset)

Determine the approximate range of species mass fraction. The range will be used to display mass fraction under log scale.

Parameters
  • data (numpy.ndarray) – Species mass fraction which should be in [0,1].

  • offset (int) – Desired display range for species under log scale.

Returns

  • low (int) – Let mid be the median of \(log_{10}(data)\) and then low will be mid-offset/2.

  • up (int) – Let mid be the median of \(log_{10}(data)\) and then up will be mid+offset/2.

static _latexStyle(text)

Convert the given text to \(\LaTeX\) bold style e.g. T–>$\bf{T}$, CH4–>$\bf{CH_{4}}$, C10H18O8–>$\bf{C_{10}H_{18}O_{8}}$

_latexStyleName(index)

For a chemical dataset (TPY), the state names could be denoted as [‘T’,’P’,…species names]. Convert state_names[index] to \(\LaTeX\) bold style if there exists \(\LaTeX\) enviroment.