pynpoint.core package#

Submodules#

pynpoint.core.attributes module#

Module to obtain information about the implemented attributes.

pynpoint.core.attributes.get_attributes() Dict[str, Dict[str, str | float | int | None]][source]#

Function to get a dictionary with all attributes.

Returns:

Attribute information.

Return type:

dict

pynpoint.core.dataio module#

Modules for accessing data and attributes in the central database.

class pynpoint.core.dataio.ConfigPort(tag: str, data_storage_in: DataStorage | None = None)[source]#

Bases: Port

ConfigPort can be used to read the ‘config’ tag from a (HDF5) database. This tag contains the central settings used by PynPoint, as well as the relevant FITS header keywords. You can use a ConfigPort instance to access a single attribute of the dataset using get_attribute().

Constructor of the ConfigPort class which creates the config port instance which can read the settings stored in the central database under the tag config. An instance of the ConfigPort is created in the constructor of PypelineModule such that the attributes in the ConfigPort can be accessed from within all type of modules. For example:

memory = self._m_config_port.get_attribute('MEMORY')
Parameters:
  • tag (str) – The tag name of the port. The port can be used to get data from the dataset with the key config.

  • data_storage_in (pynpoint.core.dataio.DataStorage) – The input DataStorage. It is possible to give the constructor of an ConfigPort a DataStorage instance which will link the port to that DataStorage. Usually the DataStorage is set later by calling set_database_connection().

Returns:

None

Return type:

NoneType

get_attribute(name: str) str | float | int | generic | None[source]#

Returns a static attribute which is connected to the dataset of the ConfigPort.

Parameters:

name (str) – The name of the attribute.

Returns:

The attribute value. Returns None if the attribute does not exist.

Return type:

str, float, or int

class pynpoint.core.dataio.DataStorage(location_in: str)[source]#

Bases: object

Instances of DataStorage manage to open and close the Pypeline HDF5 databases. They have an internal h5py data bank (self.m_data_bank) which gives direct access to the data if the storage is open (self.m_open == True).

Constructor of a DataStorage instance. It needs the location of the HDF5 file (Pypeline database) as input. If the file already exists it is opened and extended, if not a new File will be created.

Parameters:

location_in (str) – Location (directory + filename) of the HDF5 database.

Returns:

None

Return type:

NoneType

close_connection() None[source]#

Closes the connection to the HDF5 file. All entries of the data bank will be stored on the hard drive and the memory is cleaned.

Returns:

None

Return type:

NoneType

open_connection() None[source]#

Opens the connection to the HDF5 file by opening an old file or creating a new one.

Returns:

None

Return type:

NoneType

class pynpoint.core.dataio.InputPort(tag: str, data_storage_in: DataStorage | None = None)[source]#

Bases: Port

InputPorts can be used to read datasets with a specific tag from the HDF5 database. This type of port can be used to access:

  • A complete dataset using the get_all() method.

  • A single attribute of the dataset using get_attribute().

  • All attributes of the dataset using get_all_static_attributes() and get_all_non_static_attributes().

  • A part of a dataset using slicing. For example:

in_port = InputPort('tag')
data = in_port[0, :, :] # returns the first 2D image of a 3D image stack.

(More information about how 1D, 2D, and 3D data is organized can be found in the documentation of OutputPort (append() and set_all())

InputPorts can load two types of attributes which give additional information about a dataset the port is linked to:

  • Static attributes: contain global information about a dataset which is not changing through a dataset in the database (e.g. the instrument name or pixel scale).

  • Non-static attributes: contain information which changes for different parts of the dataset (e.g. the parallactic angles or dithering positions).

Constructor of InputPort. An input port can read data from the central database under the key tag. Instances of InputPort should not be created manually inside a PypelineModule but should be created with the add_input_port() function.

Parameters:
  • tag (str) – The tag of the port. The port can be used in order to get data from the dataset with the key tag.

  • data_storage_in (pynpoint.core.dataio.DataStorage) – It is possible to give the constructor of an InputPort a DataStorage instance which will link the port to that DataStorage. Usually the DataStorage is set later by calling set_database_connection().

Returns:

None

Return type:

NoneType

get_all() ndarray | None[source]#

Returns the whole dataset stored in the data bank under the tag of the Port. Be careful using this function for loading large datasets. The data type is inferred from the data with numpy.asarray. A 32 bit array will be returned in case the input data is a combination of float32 and float64 arrays.

Returns:

The full dataset. Returns None if the data does not exist.

Return type:

np.ndarray

get_all_non_static_attributes() List[str] | None[source]#

Returns a list of all non-static attribute keys. More information about static and non-static attributes can be found in the class documentation of InputPort.

Returns:

List of all existing non-static attribute keys.

Return type:

list(str, ), None

get_all_static_attributes() Dict[str, str | float | int | generic] | None[source]#

Get all static attributes of the dataset which are linked to the Port tag.

Returns:

Dictionary of all attributes, as {attr_name:attr_value}.

Return type:

dict, None

get_attribute(name: str) str | float | int | generic | ndarray | tuple | list | None[source]#

Returns an attribute which is connected to the dataset of the port. The function can return static and non-static attributes (static attributes have priority). More information about static and non-static attributes can be found in the class documentation of InputPort.

Parameters:

name (str) – The name of the attribute.

Returns:

The attribute value. Returns None if the attribute does not exist.

Return type:

StaticAttribute, NonStaticAttribute, None

get_ndim() int | None[source]#

Returns the number of dimensions of the dataset the port is linked to.

Returns:

Number of dimensions of the dataset. Returns None if the dataset does not exist.

Return type:

int

get_shape() Tuple[int, ...] | None[source]#

Returns the shape of the dataset the port is linked to. This can be useful if you need the shape without loading the whole data.

Returns:

Shape of the dataset. Returns None if the dataset does not exist.

Return type:

tuple(int, )

class pynpoint.core.dataio.OutputPort(tag: str, data_storage_in: DataStorage | None = None, activate_init: bool = True)[source]#

Bases: Port

Output ports can be used to save results under a given tag to the HDF5 DataStorage. An instance of OutputPort with self.tag=`tag` can store data under the key tag by using one of the following methods:

  • set_all(…) - replaces and sets the whole dataset

  • append(…) - appends data to the existing data set. For more information see function documentation (append()).

  • slicing - sets a part of the actual dataset. Example:

out_port = OutputPort('Some_tag')
data = np.ones(200, 200) # 2D image filled with ones
out_port[0,:,:] = data # Sets the first 2D image of a 3D image stack
  • add_attribute(…) - modifies or creates a attribute of the dataset

  • del_attribute(…) - deletes a attribute

  • del_all_attributes(…) - deletes all attributes

  • append_attribute_data(…) - appends information to non-static attributes. See add_attribute() (add_attribute()) for more information about static and non-static attributes.

  • check_static_attribute(…) - checks if a static attribute exists and if it is equal to a given value

  • other functions listed below

For more information about how data is organized inside the central database have a look at the function documentation of the function set_all() and append().

Furthermore it is possible to deactivate a OutputPort to stop him saving data.

Constructor of the OutputPort class which creates an output port instance which can write data to the the central database under the tag tag. If you write a PypelineModule you should not create instances manually! Use the add_output_port() function instead.

Parameters:
  • tag (str) – The tag of the port. The port can be used in order to write data to the dataset with the key = tag.

  • data_storage_in (pynpoint.core.dataio.DataStorage) – It is possible to give the constructor of an OutputPort a DataStorage instance which will link the port to that DataStorage. Usually the DataStorage is set later by calling set_database_connection().

Returns:

None

Return type:

NoneType

activate() None[source]#

Activates the port. A non activated port will not save data.

Returns:

None

Return type:

NoneType

add_attribute(name: str, value: str | float | int | generic | ndarray | tuple | list, static: bool = True) None[source]#

Adds an attribute to the dataset of the Port with the attribute name = name and the value = value. If the attribute already exists it will be overwritten. Two different types of attributes are supported:

  1. static attributes: Contain a single value or name (e.g. The name of the used Instrument).

  2. non-static attributes: Contain a dataset which is connected to the actual data set (e.g. Instrument temperature). It is possible to append additional information to non-static attributes later (append_attribute_data()). This is not supported by static attributes.

Static and non-static attributes are stored in a different way using the HDF5 file format. Static attributes will be direct attributes while non-static attributes are stored in a group with the name header_ + name of the dataset.

Parameters:
  • name (str) – Name of the attribute.

  • value (StaticAttribute, NonStaticAttribute) – Value of the attribute.

  • static (bool) – Indicate if the attribute is static (True) or non-static (False).

Returns:

None

Return type:

NoneType

add_history(module: str, history: str) None[source]#

Adds an attribute with history information about the pipeline module.

Parameters:
  • module (str) – Name of the pipeline module which was executed.

  • history (str) – History information.

Returns:

None

Return type:

NoneType

append(data: ndarray | list, data_dim: int | None = None, force: bool = False) None[source]#

Appends data to an existing dataset along the first dimension. If no data exists for the OutputPort, then a new data set is created. For more information about how the dimensions are organized, see the documentation of set_all(). Note it is not possible to append data with a different shape or data type to an existing dataset.

Example: An internal data set is 3D (storing a stack of 2D images) with shape of (233, 300, 300), that is, it contains 233 images with a resolution of 300 by 300 pixels. Thus it is only possible to extend along the first dimension by appending new images with a shape of (300, 300) or by appending a stack of images with a shape of (:, 300, 300).

It is possible to force the function to overwrite existing data set if the shape or type of the input data do not match the existing data.

Parameters:
  • data (np.ndarray) – The data that will be appended.

  • data_dim (int) – Number of data dimensions used if a new data set is created. The dimension of the data is used if set to None.

  • force (bool) – The existing data will be overwritten if the shape or type does not match.

Returns:

None

Return type:

NoneType

append_attribute_data(name: str, value: str | float | int | generic | ndarray | tuple | list) None[source]#

Function which appends data (either a single value or an array) to non-static attributes.

Parameters:
  • name (str) – Name of the attribute.

  • value (StaticAttribute, NonStaticAttribute) – Value which will be appended to the attribute dataset.

Returns:

None

Return type:

NoneType

check_non_static_attribute(name: str, comparison_value: ndarray | tuple | list) int | None[source]#

Checks if a non-static attribute exists and if it is equal to a comparison value.

Parameters:
  • name (str) – Name of the non-static attribute.

  • comparison_value (NonStaticAttribute) – Comparison values

Returns:

Status: 1 if the non-static attribute does not exist, 0 if the non-static attribute exists and is equal, and -1 if the non-static attribute exists but is not equal.

Return type:

int, None

check_static_attribute(name: str, comparison_value: str | float | int | generic) int | None[source]#

Checks if a static attribute exists and if it is equal to a comparison value.

Parameters:
  • name (str) – Name of the static attribute.

  • comparison_value (StaticAttribute) – Comparison value.

Returns:

Status: 1 if the static attribute does not exist, 0 if the static attribute exists and is equal, and -1 if the static attribute exists but is not equal.

Return type:

int, None

copy_attributes(input_port: InputPort) None[source]#

Copies all static and non-static attributes from a given InputPort. Attributes which already exist will be overwritten. Non-static attributes will be linked not copied. If the InputPort tag = OutputPort tag (self.tag) nothing will be changed. Use this function in all modules to keep the header information.

Parameters:

input_port (pynpoint.core.dataio.InputPort) – The InputPort with the header information.

Returns:

None

Return type:

NoneType

deactivate() None[source]#

Deactivates the port. A non activated port will not save data.

Returns:

None

Return type:

NoneType

del_all_attributes() None[source]#

Deletes all static and non-static attributes of the dataset.

Returns:

None

Return type:

NoneType

del_all_data() None[source]#

Delete all data belonging to the database tag.

del_attribute(name: str) None[source]#

Deletes the attribute of the dataset with the given name. Finds and removes static and non-static attributes.

Parameters:

name (str) – Name of the attribute.

Returns:

None

Return type:

NoneType

flush() None[source]#

Forces the DataStorage to save all data from the memory to the hard drive without closing the OutputPort.

Returns:

None

Return type:

NoneType

set_all(data: ndarray | list, data_dim: int | None = None, keep_attributes: bool = False) None[source]#

Set the data in the database by replacing all old values with the values of the input data. If no old values exists the data is just stored. Since it is not possible to change the number of dimensions of a data set later in the processing history one can choose a dimension different to the input data. The following cases are implemented:

  • (#dimension of the first input data#, #desired data_dim#)

  • (1, 1) 1D input or single value will be stored as list in HDF5

  • (1, 2) 1D input, but 2D array stored inside (i.e. a list of lists with a fixed size).

  • (2, 2) 2D input (single image) and 2D array stored inside (i.e. a list of lists with a fixed size).

  • (2, 3) 2D input (single image) but 3D array stored inside (i.e. a stack of images with a fixed size).

  • (3, 3) 3D input and 3D array stored inside (i.e. a stack of images with a fixed size).

For 2D and 3D data the first dimension always represents the list / stack (variable size) while the second (or third) dimension has a fixed size. After creation it is possible to extend a data set using append() along the first dimension.

Example 1:

Input 2D array with size (200, 200). Desired dimension 3D. The result is a 3D dataset with the dimension (1, 200, 200). It is possible to append other images with the size (200, 200) or other stacks of images with the size (:, 200, 200).

Example 2:

Input 2D array with size (200, 200). Desired dimension 2D. The result is a 2D dataset with the dimension (200, 200). It is possible to append other list with the length 200 or other stacks of lines with the size (:, 200). However it is not possible to append other 2D images along a third dimension.

Parameters:
  • data (np.ndarray) – The data to be saved.

  • data_dim (int) – Number of data dimensions. The dimension of the first_data is used if set to None.

  • keep_attributes (bool) – All attributes of the old dataset will remain the same if set to True.

Returns:

None

Return type:

NoneType

class pynpoint.core.dataio.Port(tag: str, data_storage_in: DataStorage | None = None)[source]#

Bases: object

Abstract interface and implementation of common functionality of the InputPort, OutputPort, and ConfigPort. Each Port has a internal tag which is its key to a dataset in the DataStorage. If for example data is stored under the entry im_arr in the central data storage only a port with the tag (self._m_tag = im_arr) can access and change that data. A port knows exactly one DataStorage instance, whether it is active or not (self._m_data_base_active).

Abstract constructor of a Port. As input the tag / key is expected which is needed to build the connection to the database entry with the same tag / key. It is possible to give the Port a DataStorage. If this storage is not given the Pypeline module has to set it or the connection needs to be added manually using set_database_connection().

Parameters:
Returns:

None

Return type:

NoneType

close_port() None[source]#

Closes the connection to the DataStorage and forces it to save the data to the hard drive. All data that was accessed using the port is cleaned from the memory.

Returns:

None

Return type:

NoneType

open_port() None[source]#

Opens the connection to the DataStorage and activates its data bank.

Returns:

None

Return type:

NoneType

set_database_connection(data_base_in: DataStorage) None[source]#

Sets the internal DataStorage instance.

Parameters:

data_base_in (pynpoint.core.dataio.DataStorage) – The input DataStorage.

Returns:

None

Return type:

NoneType

property tag: str#

Getter for the internal tag (no setter).

Returns:

Database tag name.

Return type:

str

pynpoint.core.processing module#

Interfaces for pipeline modules.

class pynpoint.core.processing.ProcessingModule(name_in: str)[source]#

Bases: PypelineModule

The abstract class ProcessingModule is an interface for all processing steps in the pipeline which read, process, and store data. Hence processing modules have read and write access to the central database through a dictionary of output ports (self._m_output_ports) and a dictionary of input ports (self._m_input_ports).

Abstract constructor of a ProcessingModule which needs the unique name identifier as input (more information: pynpoint.core.processing.PypelineModule). Call this function in all __init__() functions inheriting from this class.

Parameters:

name_in (str) – The name of the ProcessingModule.

add_input_port(tag: str) InputPort[source]#

Function which creates an InputPort for a ProcessingModule and appends it to the internal InputPort dictionary. This function should be used by classes inheriting from ProcessingModule to make sure that only input ports with unique tags are added. The new port can be used as:

port = self._m_input_ports[tag]

or by using the returned Port.

Parameters:

tag (str) – Tag of the new input port.

Returns:

The new InputPort for the ProcessingModule.

Return type:

pynpoint.core.dataio.InputPort

add_output_port(tag: str, activation: bool = True) OutputPort[source]#

Function which creates an OutputPort for a ProcessingModule and appends it to the internal OutputPort dictionary. This function should be used by classes inheriting from ProcessingModule to make sure that only output ports with unique tags are added. The new port can be used as:

port = self._m_output_ports[tag]

or by using the returned Port.

Parameters:
  • tag (str) – Tag of the new output port.

  • activation (bool) – Activation status of the Port after creation. Deactivated ports will not save their results until they are activated.

Returns:

The new OutputPort for the ProcessingModule.

Return type:

pynpoint.core.dataio.OutputPort

apply_function_in_time(func: Callable, image_in_port: InputPort, image_out_port: OutputPort, func_args: tuple | None = None) None[source]#

Applies a function to all pixel lines in time.

Parameters:
  • func (function) – The input function.

  • image_in_port (pynpoint.core.dataio.InputPort) – Input port which is linked to the input data.

  • image_out_port (pynpoint.core.dataio.OutputPort) – Output port which is linked to the results.

  • func_args (tuple, None) – Additional arguments which are required by the input function. Not used if set to None.

Returns:

None

Return type:

NoneType

apply_function_to_images(func: Callable[[...], ndarray], image_in_port: InputPort, image_out_port: OutputPort, message: str, func_args: tuple | None = None) None[source]#

Function which applies a function to all images of an input port. Stacks of images are processed in parallel if the CPU and MEMORY attribute are set in the central configuration. The number of images per process is equal to the value of MEMORY divided by the value of CPU. Note that the function func is not allowed to change the shape of the images if the input and output port have the same tag and MEMORY is not set to None.

Parameters:
  • func (function) –

    The function which is applied to all images. Its definitions should be similar to:

    def function(image_in,
                 parameter1,
                 parameter2,
                 parameter3)
    

    The function must return a numpy array.

  • image_in_port (pynpoint.core.dataio.InputPort) – Input port which is linked to the input data.

  • image_out_port (pynpoint.core.dataio.OutputPort) – Output port which is linked to the results.

  • message (str) – Progress message.

  • func_args (tuple) – Additional arguments that are required by the input function.

Returns:

None

Return type:

NoneType

connect_database(data_base_in: DataStorage) None[source]#

Function used by a ProcessingModule to connect all ports in the internal input and output port dictionaries to the database. The function is called by Pypeline and connects the DataStorage object to all module ports.

Parameters:

data_base_in (pynpoint.core.dataio.DataStorage) – The central database.

Returns:

None

Return type:

NoneType

get_all_input_tags() List[str][source]#

Returns a list of all input tags to the ProcessingModule.

Returns:

List of input tags.

Return type:

list(str)

get_all_output_tags() List[str][source]#

Returns a list of all output tags to the ProcessingModule.

Returns:

List of output tags.

Return type:

list(str)

abstract run() None[source]#

Abstract interface for the run method of a ProcessingModule which inheres the actual algorithm behind the module.

class pynpoint.core.processing.PypelineModule(name_in: str)[source]#

Bases: object

Abstract interface for the PypelineModule:

Each PypelineModule has a name as a unique identifier in the Pypeline and requires the connect_database and run methods.

Abstract constructor of a PypelineModule.

Parameters:

name_in (str) – The name of the PypelineModule.

Returns:

None

Return type:

NoneType

abstract connect_database(data_base_in: DataStorage) None[source]#

Abstract interface for the function connect_database which is needed to connect a Port of a PypelineModule with the DataStorage.

Parameters:

data_base_in (pynpoint.core.dataio.DataStorage) – The central database.

property name: str#

Returns the name of the PypelineModule. This property makes sure that the internal module name can not be changed.

Returns:

The name of the PypelineModule

Return type:

str

abstract run() None[source]#

Abstract interface for the run method of PypelineModule which inheres the actual algorithm behind the module.

class pynpoint.core.processing.ReadingModule(name_in: str, input_dir: str | None = None)[source]#

Bases: PypelineModule

The abstract class ReadingModule is an interface for processing steps in the Pypeline which have only read access to the central data storage. One can specify a directory on the hard drive where the input data for the module is located. If no input directory is given then default Pypeline input directory is used. Reading modules have a dictionary of output ports (self._m_out_ports) but no input ports.

Abstract constructor of ReadingModule which needs the unique name identifier as input (more information: pynpoint.core.processing.PypelineModule). An input directory can be specified for the location of the data or else the Pypeline default directory is used. This function is called in all __init__() functions inheriting from this class.

Parameters:
  • name_in (str) – The name of the ReadingModule.

  • input_dir (str) – Directory where the input files are located.

Returns:

None

Return type:

NoneType

add_output_port(tag: str, activation: bool = True) OutputPort[source]#

Function which creates an OutputPort for a ReadingModule and appends it to the internal OutputPort dictionary. This function should be used by classes inheriting from ReadingModule to make sure that only output ports with unique tags are added. The new port can be used as:

port = self._m_output_ports[tag]

or by using the returned Port.

Parameters:
  • tag (str) – Tag of the new output port.

  • activation (bool) – Activation status of the Port after creation. Deactivated ports will not save their results until they are activated.

Returns:

The new OutputPort for the ReadingModule.

Return type:

pynpoint.core.dataio.OutputPort

connect_database(data_base_in: DataStorage) None[source]#

Function used by a ReadingModule to connect all ports in the internal input and output port dictionaries to the database. The function is called by Pypeline and connects the DataStorage object to all module ports.

Parameters:

data_base_in (pynpoint.core.dataio.DataStorage) – The central database.

Returns:

None

Return type:

NoneType

get_all_output_tags() List[str][source]#

Returns a list of all output tags to the ReadingModule.

Returns:

List of output tags.

Return type:

list(str)

abstract run() None[source]#

Abstract interface for the run method of a ReadingModule which inheres the actual algorithm behind the module.

class pynpoint.core.processing.WritingModule(name_in: str, output_dir: str | None = None)[source]#

Bases: PypelineModule

The abstract class WritingModule is an interface for processing steps in the pipeline which do not change the content of the internal DataStorage. They only have reading access to the central data base. WritingModules can be used to export data from the HDF5 database. WritingModules know the directory on the hard drive where the output of the module can be saved. If no output directory is given the default Pypeline output directory is used. WritingModules have a dictionary of input ports (self._m_input_ports) but no output ports.

Abstract constructor of a WritingModule which needs the unique name identifier as input (more information: pynpoint.core.processing.PypelineModule). In addition one can specify a output directory where the module will save its results. If no output directory is given the Pypeline default directory is used. This function is called in all __init__() functions inheriting from this class.

Parameters:
  • name_in (str) – The name of the WritingModule.

  • output_dir (str) – Directory where the results will be saved.

Returns:

None

Return type:

NoneType

add_input_port(tag: str) InputPort[source]#

Function which creates an InputPort for a WritingModule and appends it to the internal InputPort dictionary. This function should be used by classes inheriting from WritingModule to make sure that only input ports with unique tags are added. The new port can be used as:

port = self._m_input_ports[tag]

or by using the returned Port.

Parameters:

tag (str) – Tag of the new input port.

Returns:

The new InputPort for the WritingModule.

Return type:

pynpoint.core.dataio.InputPort

connect_database(data_base_in: DataStorage) None[source]#

Function used by a WritingModule to connect all ports in the internal input and output port dictionaries to the database. The function is called by Pypeline and connects the DataStorage object to all module ports.

Parameters:

data_base_in (pynpoint.core.dataio.DataStorage) – The central database.

Returns:

None

Return type:

NoneType

get_all_input_tags() List[str][source]#

Returns a list of all input tags to the WritingModule.

Returns:

List of input tags.

Return type:

list(str)

abstract run() None[source]#

Abstract interface for the run method of a WritingModule which inheres the actual algorithm behind the module.

pynpoint.core.pypeline module#

Module which capsules the methods of the Pypeline.

class pynpoint.core.pypeline.Pypeline(working_place_in: str | None = None, input_place_in: str | None = None, output_place_in: str | None = None)[source]#

Bases: object

The Pypeline class manages the pipeline modules. It inheres an internal dictionary of pipeline modules and has a DataStorage which is accessed by the various modules. The order in which the pipeline modules are executed depends on the order they have been added to the Pypeline. It is possible to run all modules at once or run a single module by name.

Parameters:
  • working_place_in (str, None) – Working location where the central HDF5 database and the configuration file will be stored. Sufficient space is required in the working folder since each pipeline module stores a dataset in the HDF5 database. The current working folder of Python is used as working folder if the argument is set to None.

  • input_place_in (str, None) – Default input folder where a ReadingModule that is added to the Pypeline will look for input data. The current working folder of Python is used as input folder if the argument is set to None.

  • output_place_in (str, None) – Default output folder where a WritingModule that is added to the Pypeline will store output data. The current working folder of Python is used as output folder if the argument is set to None.

Returns:

None

Return type:

NoneType

add_module(module: PypelineModule) None[source]#

Method for adding a PypelineModule to the internal dictionary of the Pypeline. The module is appended at the end of this ordered dictionary. If the input module is a reading or writing module without a specified input or output location then the default location is used. The module is connected to the internal data storage of the Pypeline.

Parameters:

module (ReadingModule, WritingModule, ProcessingModule) – Pipeline module that will be added to the Pypeline.

Returns:

None

Return type:

NoneType

delete_data(tag: str) None[source]#

Method for deleting a dataset and related attributes from the central database. Disk space does not seem to free up when using this method.

Parameters:

tag (str) – Database tag.

Returns:

None

Return type:

NoneType

get_attribute(data_tag: str, attr_name: str, static: bool = True) str | float | int | generic | ndarray | tuple | list[source]#

Method for reading an attribute from the database.

Parameters:
  • data_tag (str) – Database tag.

  • attr_name (str) – Name of the attribute.

  • static (bool) – Static (True) or non-static attribute (False).

Returns:

Attribute value. For a static attribute, a single value is returned. For a non-static attribute, an array of values is returned.

Return type:

StaticAttribute, NonStaticAttribute

get_data(tag: str, data_range: Tuple[int, int] | None = None) ndarray[source]#

Method for reading data from the database.

Parameters:
  • tag (str) – Database tag.

  • data_range (tuple(int, int), None) – Slicing range for the first axis of a dataset. This argument can be used to select a subset of images from dataset. The full dataset is read if the argument is set to None.

Returns:

The selected dataset from the database.

Return type:

np.ndarray

get_module_names() List[str][source]#

Method to return a list with the names of all pipeline modules that are added to the Pypeline.

Returns:

Ordered list of all Pypeline modules.

Return type:

list(str)

get_shape(tag: str) Tuple[int, ...] | None[source]#

Method for returning the shape of a database entry.

Parameters:

tag (str) – Database tag.

Returns:

Shape of the dataset. None is returned if the database tag is not found.

Return type:

tuple(int, …), None

get_tags() List[str][source]#

Method for returning a list with all database tags, except header and configuration tags.

Returns:

Database tags.

Return type:

list(str)

list_attributes(data_tag: str) Dict[str, str | float64 | ndarray][source]#

Method for printing and returning an overview of all attributes of a dataset.

Parameters:

data_tag (str) – Database tag of which the attributes will be extracted.

Returns:

Dictionary with all attributes, both static and non-static.

Return type:

dict(str, bool)

remove_module(name: str) bool[source]#

Method to remove a PypelineModule from the internal dictionary with pipeline modules that are added to the Pypeline.

Parameters:

name (str) – Name of the module that has to be removed.

Returns:

Confirmation of removing the PypelineModule.

Return type:

bool

run() None[source]#

Method for running all pipeline modules that are added to the Pypeline.

Returns:

None

Return type:

NoneType

run_module(name: str) None[source]#

Method for running a pipeline module.

Parameters:

name (str) – Name of the pipeline module.

Returns:

None

Return type:

NoneType

set_attribute(data_tag: str, attr_name: str, attr_value: str | float | int | generic | ndarray | tuple | list, static: bool = True) None[source]#

Method for writing an attribute to the database. Existing values will be overwritten.

Parameters:
  • data_tag (str) – Database tag.

  • attr_name (str) – Name of the attribute.

  • attr_value (StaticAttribute, NonStaticAttribute) – Attribute value.

  • static (bool) – Static (True) or non-static attribute (False).

Returns:

None

Return type:

NoneType

validate_pipeline() Tuple[bool, str | None][source]#

Method to check if each InputPort is pointing to an OutputPort of a previously added PypelineModule.

Returns:

  • bool – Validation of the pipeline.

  • str, None – Name of the pipeline module that can not be validated. Returns None if all modules were validated.

validate_pipeline_module(name: str) Tuple[bool, str | None][source]#

Method to check if each InputPort of a PypelineModule with label name points to an existing dataset in the database.

Parameters:

name (str) – Name of the pipeline module instance that will be validated.

Returns:

  • bool – Validation of the pipeline module.

  • str, None – Pipeline module name in case it is not valid. Returns None if the module was validated.

Module contents#