Skip to main content

pySpectroWorks is a Python module for loading data from SpectroWorks™.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyspectroworks-1.0.1.tar.gz (40.9 kB view details)

Uploaded Source

Built Distribution

pyspectroworks-1.0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file pyspectroworks-1.0.1.tar.gz.

File metadata

  • Download URL: pyspectroworks-1.0.1.tar.gz
  • Upload date:
  • Size: 40.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for pyspectroworks-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a04d2a8af02b1fef21a22f904362817a3a3bbea1ea5331c7d3e95a472060bc5f
MD5 10a01b2779da3bebb36ff90684481566
BLAKE2b-256 9ead0692d305e921a952f9495987cba944ff4f41e9c787668c774cc299ae682d

See more details on using hashes here.

File details

Details for the file pyspectroworks-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyspectroworks-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7bc0b6faf34cabb7c899a3a969dc37453cb9233cff3602335a977a7071d5945f
MD5 5f295d8b6da741ad8f99c9f7e03c6ceb
BLAKE2b-256 5a644e1a28399ff302697551a23335b38cd962cb8ae67828dc4a8323ba8bd2ae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page