Measurement

Taking measurements using a MultispeQ connected via Serial port and analyze the data from the instrument.

Also functions are provided to load data from locally saved measurements as well as from notebooks saved by the PhotosynQ Desktop Application (limited support).

MultispeQ Measurements

Take measurements using the MultispeQ device connected to a serial port. The returned data can be analyzed and viewed.

measure(connection=None, protocol=[{}], filename='auto', notes='', directory='./local/')[source]

Take a measurement using a MultispeQ connected via a serial connection (USB or Bluetooth).

Parameters:
  • connection (serial) – Connection to the MultispeQ.

  • protocol (str, dict or list) – Measurement Protocol

  • filename (str) – Name for saved measurement file. If set to None, no file is saved, Default name is current date and time.

  • notes (str) – Notes for the measurement

  • directory (str) – Directory the measurement is saved in. Default directory is “local”.

Returns:

The MultispeQ data is returned on success, otherwise None.

Return type:

str

Raises:
  • ValueError – if no connection is defined

  • ValueError – if no protocol for the MultispeQ is provided

  • ValueError – if protocol is not encoded as a string or dictionary

  • ValueError – if notes are not provided as a string

  • ValueError – if directory is not provided as a string

  • Exception – if connection is not open or device connected

analyze(data=None, fn=None)[source]

Pipe data from the MultispeQ measurement to an analysis function. This can be done manually, but this helps with the convoluted structure of the measurement output.

Parameters:
  • data (dict) – MultispeQ data output

  • fn (function) – Function to analyze the provided data

Returns:

Analyzed data output, returns None if fails

Return type:

dict

Raises:
  • ValueError – if no data is provided

  • Exeption – if fn is not a function

view(data=None)[source]

Tabular display of data for a single measurent. If a parameter is a list or dictionary or other type ‘n/a’ will be displayed as such content will not be plotted.

Parameters:

data (dict) – MultispeQ data output

Returns:

None

Return type:

NoneType

Raises:
  • ValueError – if no data is provided

  • ValueError – if data is not a dictionary

to_df(data=None, append=None)[source]

Adding data to dataframe. A new dataframe can be created or the data can be appended to an existing one, if the column format is the same.

Parameters:

data (dict or list[dict]) – MultispeQ data output

Returns:

None

Return type:

NoneType

Raises:
  • ValueError – if no data is provided

  • ValueError – if data is not a dictionary

Measurement Files

Support on working with local measurement files.

list_files(directory='./local/')[source]

List all local files in the provided directory

Parameters:

directory (str) – Directory

Returns:

None

Return type:

None

load_files(directory=None, recursive=False, fn=None)[source]

Load files from selected directories into a dictionary.

Parameters:
  • directory (str or list[str]) – Measurements in one or multiple directories

  • recursive (bool) – Recursive listing of files and subdirectories

  • fn (function) – Function to analyze the provided data

Returns:

Dictionary with Measurements

Return type:

list[dict]

Raises:
  • ValueError – if directory is not provided with a sting or list

  • ValueError – if recursive is not True or False

  • ValueError – if no valid function is provided

load_files_df(directory=None, recursive=False, fn=None)[source]

Load files from selected directories into a dataframe.

Parameters:
  • directory (str or list[str]) – Measurements in one or multiple directories

  • recursive (bool) – Recursive listing of files and subdirectories

  • fn (function) – Function to analyze the provided data

Returns:

Dataframe with Measurements

Return type:

pandas.DataFrame

Checksums

Checksum handeling and calculation for MultispeQ Measurements.

get_crc32(data=None)[source]

Calculate a CRC32 checksum from data and represent as HEX.

Parameters:

data (str) – Data stream

Returns:

HEX CRC32 checksum

Return type:

str

Raises:
  • ValueError – if no data is provided

  • ValueError – if provided data is not a string

strip_crc32(data=None)[source]

Strip CRC32 checksum from data string and return data and checksum separately.

Parameters:

data (str) – Data stream

Returns:

data string and HEX CRC32 checksum

Return type:

str, str

Raises:
  • ValueError – if no data is provided

  • ValueError – if provided data is not a string


Notebooks

Import PhotosynQ Notebooks into a dataframe.

import_notebook(source=None)[source]

Import one or multiple Notebook files exported from the PhotosynQ, Inc. Desktop Application’s notebook.

Warning

The values calculated by Macros in the PhotosynQ, Inc. Desktop Application are not available when imported using this package. Notebook files can be exported according to the PhotosynQ, Inc. Documentation. This package only provides limited support of the Notebook format.

Parameters:

source (str or list[str]) – Notebook file(s)

Returns:

Dataframe or None

Return type:

pandas.Dataframe

Raises:

ValueError – if no source file is provided