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.0.tar.gz (40.9 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyspectroworks-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 e8272668ab18c934cc959c097242c9d447a5833b5d67b6d210344afbab5397d9
MD5 bc1fbac954b2f9f567bb5d69c9740777
BLAKE2b-256 57b172dacfe597d97a3fe5bc2b0c6ae35aa6938bc6cda4820022772a2fd8d905

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyspectroworks-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ed8497f002b94e363528482a364406a8ad9dfbd81ff3827e68a49161cae4e0e
MD5 64801dc07c56fb32a72cd523c1e77414
BLAKE2b-256 2337366e0042b98ec6937b0d59795e39e8b521fe031022bf438bf046adda215f

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