components

Submodules

Package Contents

Classes

Storage

This class is an abstracted for all other classes, providing initialization function with a name

Dataset_Image

An object of this class represents 1 image (Multiple images have not been considered or investigated yet).

Dataset_Video

An object of this class represents the video dataset.

Parameter

An object of this class represents the Parameter.

Model

This object is used to represent the model for data processing in the experiment

Instrument

This class represents Datasets that are mapped from other datasets using a given model

Pipeline

This object represents a pipeline

Run

This object represents the run structure

class components.Storage(name)

This class is an abstracted for all other classes, providing initialization function with a name and store function to generate an HDF5 file

Parameters

name (str) – the name of the instant

set_storage_path(self, path)

set the storage path where you want to store the HDF5 file

Attention

please always use “/” in path string instead of “”

Parameters

path (str) – _description_

is_overwritable(self)
store_HDF5(self, root=None)
store_json(self, root=None)
store(self, format=None, root=None)
__str__(self)

rewrite the built-in method to modify the behaviors of print() for this instance to make the print result more readable

before:

>>>print(run1)

<run.Run object at 0x0000022AA45715A0>

after:

>>>print(run1)

‘run1’

here, the string ‘run1’ is the name of this instance

__repr__(self)

rewrite the built-in method to modify the behaviors of print() for a list of instances to make the print result more readable

before:

>>>print(run1.pipelines)

[<pipeline.Pipeline object at 0x0000022AA45715A0>, <pipeline.Pipeline object at 0x0000022AA4gd1s0>]

after:

>>>print(run1.pipelines)

[‘pipe1’, ‘pipe2’]

here, the strings ‘pipe1’ and ‘pipe2’ are the names of this instance

show(self)

use the method to show the detailed information about this instance, for example all attributes and names. It should return a string like this:

Examples

>> msmtrun.show()

#### pipelines ####

[‘aa’, ‘bb’, ‘cc’]

#### parameters ####

[‘dd’, ‘ee’, ‘ff’]

#### attributes ####

‘author’ : ‘who’

‘author’ : ‘derGeraet’

‘pmanager’ : ‘tcorneli’

‘targettmp’ : 70

‘targetrps’ : 2

‘oil’ : ‘PA06’

add_attrs_dict(self, dict)

Add a flat Dictionary of key values as a set of attributes.

dictstr

The Dictionary consists of Key Value pairs, with the keys being the names of the attribute and the value being the value assigned to the attribute

encode(self, object)

encode anything as a string Parameters: ———- object: Any

an object which can be an instance of any class

object_string: str

an encoded string, maybe very long if the original object is large

Parameters

object (Any) –

Return type

str

decode(self, object_string)

decode a string as its original form Parameters: ———– object_string: str

an encoded string

object: object

this is a instance of its original class, you can check its type with type()

Parameters

object_string (str) –

Return type

Storage.decode.object

class components.Dataset_Image(name)

Bases: Storage

An object of this class represents 1 image (Multiple images have not been considered or investigated yet).

The user only needs to provide the path of the image, this class will read it using the pillow lib

Parameters

name (str) – the name of the dataset

Examples

ataset1 = Dataset_Image(‘image_dataset_1’)

dataset1.data = “/test/test_rig_1.jpg”

property data(self)
output_file(self)

this function is designed to export image

class components.Dataset_Video(name)

Bases: Storage

An object of this class represents the video dataset.

Parameters

name (str) – the name of the dataset

Examples

dataset1 = Dataset_Video(‘video_dataset_1’)

ataset1.data = r”C:/UsersAdministrator/Videos/Captures/test_meeting _recording.mp4”

dataset1.data = “C:/Users/Administrator/Videos/Captures/test_meeting _recording.mp4”

dataset1.attrs[‘timestamp’] = ‘2022-06-13 11:22:11’

dataset1.set_storage_path(‘test/test_ut_video.h5’)

dataset1.store()

property data(self)
output_file(self, path_output)

this function is designed to convert the binary format data into the original format

Parameters

path_output (str) – the path of output

convert_pics(self, path_output)

this function is to convert the video file into frame segmentations

Parameters

path_output (str) – the path of output

class components.Parameter(name)

Bases: Storage

An object of this class represents the Parameter.

Parameters

name (str) – the name of the parameter

Examples

para1 = Parameter(‘para1’)

para1.attrs[‘value’] = 1 para1.attrs[‘units’] = ‘cm’

para1.attrs[‘variable’] = ‘-’

para1.attrs[‘origin’] = ‘this’

class components.Model(name)

Bases: Storage

This object is used to represent the model for data processing in the experiment

Parameters

name (str) – the name of the model

Examples

model = Model(‘model1’)

model.add([parameter1, parameter2])

add(self, list_obj)

add (multi) parameter(s) into model

Parameters

list_obj (List[Parameter]) – a list of Parameter object(s)

Raises

AssertionError: – raise when add method fails

class components.Instrument(name)

Bases: Storage

This class represents Datasets that are mapped from other datasets using a given model

This can be used to convert the input of a sensor to its actual physical data using the given model, for example polynomials or lookup tables.

Parameters

name (str) – the name of the instrument

Examples

instrument = Instrument(‘instrument1’)

instrument.add([model1, model2])

add(self, list_obj)

add (multi) model(s) into instrument

Parameters

list_obj (List[Model]) – a list of Model object(s)

Raises

AssertionError: – raise when adding method fails

class components.Pipeline(name)

Bases: Storage

This object represents a pipeline

This name of pipeline should contain the following information:

<measured/derived>/<capa>/<raw/scaled>

Parameters

name (str) – the name of the pipeline

Examples

pipeline1 = Pipeline(‘measured/capa1/raw’)

pipeline1.attrs[‘variable’] = ‘voltage’

pipeline1.attrs[‘units’] = ‘volts’

pipeline1.attrs[‘origin’] = ‘this’

pipeline.add([dataset1, dataset2])

pipeline.add([instrument1, insturment2])

add(self, list_obj)

add (multi) dataset(s) and instrument(s) into model

Parameters

list_obj (List[Instrument | Dataset]) – a list of Instrument or Dataset object(s)

Raises
  • TypeError – raised when the element of list_obj is not the type of Instrument or Dataset

  • AssertionError – raised when list_obj is not a list or it is empty

class components.Run(name)

Bases: Storage

This object represents the run structure

Parameters

name (str) – the name of the run

Examples

run1 = Run(‘run1’)

run1.add([parameter1, parameter2])

run1.add([pipeline1, pipeline2])

add(self, list_obj)

add (multi) parameter(s) or pipeline(s) into run

Parameters

list_obj (List[Parameter | Pipeline]) – a list of Parameter or Pipeline object(s)

Raises

AssertionError: – raise when add method fails