Skip to main content

No project description provided

Project description

cerillo

Cerillo python API for control of Cerillo devices

PyPI - Version PyPI - Python Version


Table of Contents

Installation

pip install cerillo

Usage

Below are concrete examples showing how to instantiate, connect, control, and disconnect StratusReader and RayoReader. These examples use the real public APIs implemented in cerillo.base_plate_reader and the reader modules.

StratusReader

The StratusReader extends CerilloBasePlateReader. Key methods on the base class include connect(), disconnect(), and the newer experiment APIs: start_kinetic_experiment(...), start_endpoint_experiment(...), and the higher-level start_experiment(...) that accepts a FullExperimentBuilder.

Note: read_absorbance(...) is deprecated. Use start_kinetic_experiment() for time-series (kinetic) experiments or start_endpoint_experiment() for single endpoint measurements.

Example (kinetic experiment, simulation):

from cerillo.stratus import StratusReader

# Create a reader. Use simulate=True for local testing without hardware.
reader = StratusReader(port="/dev/ttyUSB0", simulate=True)
reader.connect()
print(reader)

# Start a kinetic experiment: wavelength (nm), interval (seconds), optional duration (seconds)
results = reader.start_kinetic_experiment(wavelength=600, interval=60, duration=3600)

# `results` is an ExperimentResults instance - see ExperimentResults section below
print(results.to_json())

reader.disconnect()

Example (endpoint experiment):

from cerillo.stratus import StratusReader

reader = StratusReader(simulate=True)
reader.connect()
results = reader.start_endpoint_experiment(wavelength=600)
print(results.to_csv(format='long'))
reader.disconnect()

RayoReader

RayoReader also extends CerilloBasePlateReader and adds motor control utilities. The constructor accepts has_motor to enable motor operations and simulate for dry runs.

Example (motor commands + experiments in simulation):

from cerillo.rayo import RayoReader, MotorStepCommand, MotorNamedCommand

# Create a Rayo reader. Enable simulate for dry-run and has_motor if device has a motor.
reader = RayoReader(port="/dev/ttyUSB0", has_motor=True, simulate=True)

# Connect (simulation will populate device info)
reader.connect()
print(reader)

# Start a kinetic experiment (time-series). Returns ExperimentResults
kinetic_results = reader.start_kinetic_experiment(wavelength=590, interval=30, duration=1800)
print("Kinetic JSON:\n", kinetic_results.to_json())

# Start an endpoint experiment (single measurement)
endpoint_results = reader.start_endpoint_experiment(wavelength=590)
print("Endpoint CSV (long):\n", endpoint_results.to_csv(format='long'))

# Move motor by a number of steps (positive/negative). If simulate=True this will print simulated responses.
step_cmd = MotorStepCommand(steps=100)
ok = reader.move_motor(step_cmd)
print("Motor step result:", ok)

# Use named commands for common operations: 'c' (close) and 'o' (open) are provided helpers.
close_ok = reader.close_lid()
open_ok = reader.open_lid()
print("Close lid result:", close_ok, "Open lid result:", open_ok)

# When done
reader.disconnect()

Notes:

  • If move_motor is called on a reader constructed without has_motor=True, it will return False and print a helpful message.
  • Motor commands are represented by MotorStepCommand (step count) and MotorNamedCommand (string commands). Both inherit the CDCL command base and are sent with send_command internally. RayoReader::open_lid() and RayoReader::close_lid() use the MotorNamedCommand.

Kinetic vs Endpoint summary:

  • Kinetic experiments collect repeated timepoints and are started with start_kinetic_experiment(wavelength, interval, duration).
  • Endpoint experiments take single or sparse measurements and are started with start_endpoint_experiment(wavelength).

Both return an ExperimentResults object (or start_experiment will create/populate one) — see the ExperimentResults section below for how to work with and export data.

Advanced experiment setup (CDCL ExperimentBuilder)

A minimal flow to create an experiment and start it with the reader:

from cerillo.cdcl.experiment_builder import ExperimentBuilder
from cerillo.stratus import StratusReader

# Build an experiment configuration
builder = FullExperimentBuilder()
builder.experiment().set_name("example_experiment").set_interval(60).set_duration(3600)
builder.plate().set_manufacturer("corning")
# add plates, templates, etc. via builder API
# builder.set_interval(...)


# Create reader and start the experiment
reader = StratusReader(simulate=True)
reader.connect()
try:
    # Use start_experiment if you want the reader to send the builder messages and collect data
    data = reader.start_experiment(builder)
    print("Experiment data:", data)
finally:
    reader.disconnect()

License

cerillo is distributed under the terms of the GPLv3 license.

ExperimentResults (exporting & inspecting data)

When you start an experiment with start_experiment, start_kinetic_experiment, or start_endpoint_experiment the reader will return an ExperimentResults instance. This container provides utilities to inspect and export collected data.

Common methods and examples:

  • to_json(indent=2) : return a JSON string of the full results.
  • to_csv(format='long'|'wide', include_metadata=True) : return CSV in either long (one row per measurement) or wide (one row per timepoint with one column per well) formats.
  • save_json(filepath) / save_csv(filepath, format='long') : convenience methods to write files.
  • get_wells() : list of wells with data (sorted like A1, A2, ...).
  • get_wavelengths() : list of measured wavelengths.
  • get_data_points(well=None, wavelength=None) : filter points by well and/or wavelength.
  • get_well_timeseries(well, wavelength=None) : returns a list of (timestamp, value) tuples for the well.

Example: basic exports

# assume `results` is an ExperimentResults instance returned from start_...()
print(results.to_json(indent=2))
csv_long = results.to_csv(format='long')
csv_wide = results.to_csv(format='wide')

# Save to disk
results.save_json('experiment.json')
results.save_csv('experiment_long.csv', format='long')
results.save_csv('experiment_wide.csv', format='wide')

Example: export one CSV per well

for well in results.get_wells():
  timeseries = results.get_well_timeseries(well)
  # write a small per-well CSV
  with open(f"results_{well}.csv", 'w') as f:
    f.write('timestamp,datetime,value\n')
    for ts, val in timeseries:
      from datetime import datetime
      f.write(f"{ts},{datetime.fromtimestamp(ts).isoformat()},{val}\n")

Example: filter by wavelength or well

# all measurements for well A1
a1_points = results.get_data_points(well='A1')

# all measurements at 600 nm
led600 = results.get_data_points(wavelength=600)

These methods make it straightforward to integrate Cerillo experiment output into downstream analysis pipelines or to produce per-plate/per-well exports for collaborators.

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

cerillo-0.1.0.tar.gz (32.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cerillo-0.1.0-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file cerillo-0.1.0.tar.gz.

File metadata

  • Download URL: cerillo-0.1.0.tar.gz
  • Upload date:
  • Size: 32.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for cerillo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4544597ec419eb6899fd3e69b5e6d686cf60ba4371e1d8ceb904ba2c5e2d0484
MD5 9c0b8c7c8576727eb06c818aafb24fa8
BLAKE2b-256 32db651fa7240cb0eb97e440a13c39fc6782c8cada4c002c6ea27fff56cdc9de

See more details on using hashes here.

File details

Details for the file cerillo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cerillo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for cerillo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4e536531116cae6a63337112ed697be7a6dab5ef27f2a51cbde810b63a04126
MD5 6f8d7110608d870b4e04d9ad71f5d5d0
BLAKE2b-256 571d4eb2ac85cfad4e11ab1c02f84143a905d3d46a03c59aacdaa4760ee022e5

See more details on using hashes here.

Supported by

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