Welcome to BaiKit’s documentation!

class baikit.Data(manifest_fn, manifest_dir='input/manifest/')

Bases: object

Base class of BaiKit

manifest_fn

Manifest filename.

Type:

str

line_dir

Default: “”

Type:

str

line_ext

Default: “.txt”

Type:

str

line_loadtxt

Default: {“comments”: “#”, “delimiter”: None, “skiprows”: 0, “unpack”: False, “encoding”: “latin1”}

Type:

dict

load_manifest() ndarray

Load manifest

Loads manifest file and return manifest lines in list.

Returns:

List of manifest lines.

Return type:

numpy.ndarray

class baikit.WrangleData(manifest_fn, manifest_dir='input/manifest/')

Bases: Data

Wrangling data

Wrangles data for later use.

load_data(manifest_line_index) tuple[numpy.ndarray, str, str]

Convert manifest line to data

Loads data from manifest line.

Parameters:

manifest_line_index (int) – Line number of the manifest line.

Returns:

Data, line filename, and line tag.

Return type:

tuple[numpy.ndarray, str, str]

save_data(data, line_fn, line_tag)

Convert data to manifest line

Saves data as specified in manifest line, and print manifest line.

Parameters:
  • data (numpy.ndarray) – Data to save.

  • line_fn (str) – Line filename.

  • line_tag (str) – Line tag.

unique_col0(data) ndarray

Find the unique values in 1st column

Returns data where the values in 1st column are unique (duplicates removed) and sorted.

Parameters:

data (numpy.ndarray) – Input ndarray.

Returns:

Output ndarray.

Return type:

numpy.ndarray

find_peak(data, peakregion_boundaries) tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

Find single peak

Finds a single peak within peak region boundaries.

Parameters:
  • data (numpy.ndarray) – Data.

  • peakregion_boundaries (numpy.ndarray) – ndarray of the peak region boundaries of the peak.

Returns:

Data within peak region, peak value, and data generated from fitted model.

Return type:

tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

find_peaks(data, peakregion_boundaries) ndarray

Wrapper of find_peak()

Finds multiple peaks within a series of peak region boundaries.

Parameters:
  • data (numpy.ndarray) – Data.

  • peakregion_boundaries (numpy.ndarray) – A 2-D ndarray of peak region boundaries.

Returns:

Peaks values.

Return type:

numpy.ndarray

shift_col0(data, peakregion_par, col0_precision=4) tuple[numpy.ndarray, numpy.ndarray, float]

Shift column 0

Shifts column 0 of data according to peakregion_par.

Parameters:
  • data (numpy.ndarray) – Input data.

  • peakregion_par (numpy.ndarray) – An ndarray of two elements, the 1st one is the peak center, the 2nd one is peak half width.

  • col0_precision (int, optional) – Column 0 data output precision. Default: 4

Returns:

Output data, peak value, and diff.

Return type:

tuple[numpy.ndarray, numpy.ndarray, float]

stretch_col1(data, peaksregion_boundaries, height, col1_precision=4) tuple[numpy.ndarray, float]

Stretch column 1

Stretches column 1 of data to height.

Parameters:
  • data (numpy.ndarray) – Input data.

  • peaksregion_boundaries (numpy.ndarray) – An ndarray of two elements, the 1st one is left boundary, the 2nd one is right boundary.

  • height (float) – The average height within boundaries that the data are stretched to.

  • col1_precision (int, optional) – Column 1 data output precision. Default: 4

Returns:

Output data and coeff.

Return type:

tuple[numpy.ndarray, float]

raman_calib(data) ndarray

Calibrate Raman spectrum

Calibrates shift with Si’s 1st order peak position (520 cm^-1). Calibrates intensity with Si’s 2nd order peak average height.

Parameters:

manifest_line_index (int) – Line number of the manifest line.

Returns:

Calibrated Raman spectrum.

Return type:

numpy.ndarray

class baikit.PlotData(plot_title, manifest_dir='input/manifest/')

Bases: Data

Plot figure

Plots figure of 2-D data.

plot_figsize

Default: (6.4, 4.8)

Type:

tuple

plot_title_flag

Default: False

Type:

bool

plot_title
Type:

str

plot_title_fontsize

Default: 14

Type:

float

plot_xlabel

Default: “”

Type:

str

plot_ylabel

Default: “”

Type:

str

plot_label_fontsize

Default: 18

Type:

float

subplots_layout

Default: numpy.array([[2 * x - 1, 2 * x] for x in range(4, 0, -1)]).reshape(4, 1, 2)

Type:

numpy.ndarray

subplots_tag

Default: numpy.array([f”example_{x}” for x in range(4, 0, -1)]).reshape(4, 1)

Type:

numpy.ndarray

subplots_annotate_xyoffset

Default: numpy.tile([0, -12], (4, 1, 2, 1))

Type:

numpy.ndarray

subplots_wspace

Default: 0

Type:

float

subplots_hspace

Default: 0

Type:

float

subplot_xlim

Default: []

Type:

list

subplot_ylim

Default: []

Type:

list

subplot_ylim_offset

Default: 0

Type:

float

subplot_xlabel

Default: “”

Type:

list

subplot_ylabel_flag

Default: True

Type:

bool

subplot_xscale

Default: “linear”

Type:

list

subplot_yscale

Default: “linear”

Type:

list

subplot_linewidth

Default: 1.5

Type:

float

subplot_legend_flag

Default: False

Type:

bool

subplot_legend_loc

Default: “best”

Type:

str

subplot_legend_fontsize

Default: 10

Type:

float

line_ystep

Default: 0

Type:

float

line_annotate_flag

Default: False

Type:

bool

line_annotate_x

The x position of the annotation. Default: 1200

Type:

float

line_annotate_interval

The x interval of the data. Default: 2

Type:

float

line_annotate_kwargs

Default: {“textcoords”: “offset points”, “horizontalalignment”: “center”, “fontsize”: 12, “bbox”: dict(boxstyle=”square”, alpha=0.8, ec=”w”, fc=”w”)}

Type:

dict

line_print_flag

Default: True

Type:

bool

persistent_styles_flag

Default: False

Type:

bool

persistent_styles

Default: defaultdict(lambda: next(loop_cy_iter))

Type:

dict

init_figure()

Initialise figure

Creates subplots with axes.

subplots_shape
Type:

numpy.ndarray

manifest_lines_fields
Type:

numpy.ndarray

subplot_x_tick_params

Default: {“which”: “both”, “direction”: “in”, “width”: self.subplot_linewidth, “labelsize”: 15, “bottom”: True, “top”: False, “labelbottom”: True}

Type:

dict

subplot_y_tick_params

Default: {“which”: “both”, “direction”: “in”, “width”: self.subplot_linewidth, “labelsize”: 15, “left”: False, “right”: False, “labelleft”: False}

Type:

dict

fig
Type:

Figure

gs
Type:

GridSpec

axs

List of Axes.

Type:

list

subplot_cycler

Default: (cycler(color=palettable.tableau.Tableau_10.mpl_colors) * cycler(linewidth=[1.5]) * cycler(markersize=[5]))

Type:

Cycler

save_figure()

Save figure

Saves current figure to output folder, with some settings.

plot_subplots()

Wrapper of subplot_lines()

Plots subplots.

subplot_lines(i, j, its)

Wrapper of line()

Wraps lines into a subplot.

Parameters:
  • i (int) – Row number of subplot grid.

  • j (int) – Column number of subplot grid.

  • its (numpy.ndarray) – Iteration numbers.

line(manifest_line_index, i, j, its) ndarray

Plot line

Plots an ndarray of 2-D data.

Parameters:
  • manifest_line_index (int) – Row number of manifest line.

  • i (int) – Row number of subplot grid.

  • j (int) – Column number of subplot grid.

  • its (numpy.ndarray) – Iteration numbers.

Returns:

Iteration numbers.

Return type:

numpy.ndarray

baikit.Data(manifest_fn[, manifest_dir])

Base class of BaiKit

baikit.WrangleData(manifest_fn[, manifest_dir])

Wrangling data

baikit.PlotData(plot_title[, manifest_dir])

Plot figure

Indices and tables