Skip to main content

pySpectroWorks

pySpectroWorks is a Python module for loading data from SpectroWorks™. This readme file provides a brief introduction to the module and how it can be used.

Getting started

Installation:

pip install pyspectroworks

Import the module and establish a connection to SpectroWorks™ using your API key:

import pyspectroworks

api_key = "INSERT_API_KEY_HERE"
conn = pyspectroworks.connect(api_key)

Usage

Once you have a connection instance you can extract all your projects as a list:

projects = conn.get_projects()

Each element in this list is a Project object. All data about a project is found in its data attribute, however, the most useful information has its own attributes:

project = projects[0]  # get first project
print("Project name:", project.project_name)
print("Number of items:", project.num_files)
print("Created:", project.created)  # unix timestamp of when this project was created
print("Last modified:", project.modified)  # unix timestamp of when this project was last modified

Each project can include several items. These are your experiments and can be extracted with the get_items method:

items = project.get_items() # get all items in project

Like projects, items include a multitude of different data which can be accessed by the item's data attribute. The box code and cuvette number can be found in the box_code and cuvette_idx attributes. Calculated results are available in the items results attribute.

item = items[0] # get first item
ri = item.results['refractive_index']['value'] # get the refractive index
# print cuvette and refractive index
print(f'Cuvette: {item.box_code: >6}{item.cuvette_idx:0>2}, Refractive Index: {ri: >8}')

To extract the spectral data use the get_spectrum method of the item.
The available spectrum types are:

  • reference_B (B side reference spectrum)
  • sample_A (A side sample spectrum)
  • sample_B (B side sample spectrum)
  • sample_D (D side sample spectrum)
spectrum = item.get_spectrum('sample_B')

The spectrum is a list consisting of pairs of wavelengths and attenuance values.

Example script

An example script can be found in api_test.py

Aplications

  • Analysis of water quality - pySpectroWorks can be used to extract spectral data from water samples, which can be used to identify pollutants and contaminants.

  • Analysis of beverages - pySpectroWorks can be used to analyze the spectral data of beverages such as wine, beer, and juice, which can provide information on their chemical composition and quality.

  • Analysis of oils and fats - pySpectroWorks can be used to analyze the spectral data of liquid oils and fats, which can provide information on their composition and purity.

  • Analysis of biological fluids - pySpectroWorks can be used to extract spectral data from biological fluids such as blood, urine, and saliva, which can provide information on disease diagnosis and treatment.

Release files for pyspectroworks 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyspectroworks 1.0.1
File Size Uploaded
pyspectroworks-1.0.1.tar.gz 40.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyspectroworks 1.0.1
File Interpreter ABI Platform
pyspectroworks-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 46.7 kB

Release files / pyspectroworks-1.0.1.tar.gz

Download URL pyspectroworks-1.0.1.tar.gz
Size 40.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a04d2a8af02b1fef21a22f904362817a3a3bbea1ea5331c7d3e95a472060bc5f
BLAKE2b-256 checksum
How to use checksums
9ead0692d305e921a952f9495987cba944ff4f41e9c787668c774cc299ae682d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / pyspectroworks-1.0.1-py3-none-any.whl

Download URL pyspectroworks-1.0.1-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7bc0b6faf34cabb7c899a3a969dc37453cb9233cff3602335a977a7071d5945f
BLAKE2b-256 checksum
How to use checksums
5a644e1a28399ff302697551a23335b38cd962cb8ae67828dc4a8323ba8bd2ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page