Documentation of the Classes

Reading Measurements

This module holds classes and helper functions to represent the data format of the measurements carried out with the HHG spectrometer.

It helps reading in the data from the folders and extracts information from the implicit data structure found in the sets of

  • XML
  • and TIFF files.

The Measurement class

class dataformat.Measurement(folder)[source]

This class can hold a complete measurement taken with the HHG spectrometer.

It holds a list of the individual MeasurementPoint instances.

after_process()[source]

Calculate properties derived from all the measurement points.

If they are expensive to calculate, their calculation should be prepared in the instantiation process of the MeasurementPoint class.

static other_files_for_xml(xml_filename)[source]

Returns the names of the image and background files that belong to a certain xml file.

read_measurement(folder)[source]

This function contains the logic to read in measurement folders. First, it finds out what it has to do and creates a list of instructions. Then it starts to process those jobs in parallel.

Parameters:folder (str.) – The path to the folder that contains the measurment.

The MeasurementPoint class

class dataformat.MeasurementPoint(date, avgnum, xmlfile, imgfile, bgfile=None)[source]

This class holds all data associated with a single measurement point. This includes an XML file, the image from the spectrometer and a background reference image.

display_image(rescale=False, rescale_to_global_minmax=False, rescale_to_percentile_and_max=False)[source]

Displayes the spectrometer image using OpenCV’s function cv2.imshow()

dump_xml_structure(level=0)[source]

Returns a human readable dump of the xml structure.

Implemented as a recursive function. Therefore call without providing the level argument.

read_image(imgfile, bgfile=None)[source]

imgfile and bgfile should be (‘/path/to/folder’,’filename.tif’)

read_xml(xmlfile)[source]

xmlfile should be (‘/path/to/folder’,’filename.xml’)

The tiff Module

A module to leverage the usage of TIFF images.

TIFF - A class to read 16bit TIFFs

class tiff.TIFF(filename=None)[source]

A Class that helps reading TIFF image files, especially 16 bit grayscale images. It also contains frequently used operations on those images.

The image array data can be accessed via the property TIFF.data.

data

The property holding the image data itself in the form of a numpy.ndarray.

minmax[source]

A tuple containing the minimum and maximum pixel values in the image.

percentiles(percentages)[source]

Calculates percentiles over all pixel values of the image.

read(filename)[source]

Reads the image file using OpenCV.

rescale(minmax=None)[source]

Get image data with changed intensity scaling.

This method returns image data where the minimum and maximum pixel values are being rescaled to the given values.

update()[source]

Updates properties of the image like its colour depth or the dimensions.

This method is being called whenever the property TIFF.data is being changed.