Git Product home page Git Product logo

comet's Introduction

COMET

Control and Measurement Toolkit

Providing generic instrument drivers, instrument emulators for testing and and utilities for instrumentation applications. Inspired by QCoDeS, Lantz, Slave, FluidLab.

Install

Install from GitHub using pip

pip install git+https://github.com/hephy-dd/[email protected]

Drivers

Generic instrument drivers use a PyVISA compatible resource to communicate with.

import pyvisa

from comet.driver.keithley import K2470

rm = pyvisa.ResourceManager("@py")

with rm.open_resource("TCPIP::0.0.0.0::11001::SOCKET") as res:
    smu = K2470(res)
    print(smu.identify())

    smu.reset()
    smu.function = smu.FUNCTION_VOLTAGE
    smu.current_compliance = 1e-6
    smu.output = smu.OUTPUT_ON
    smu.voltage_level = 5.0

    reading = smu.measure_current()
    print(reading)

    smu.voltage_level = 0.0
    smu.output = smu.OUTPUT_OFF

Switching between generic drivers.

from comet.driver.keithley import K2410
from comet.driver.keithley import K2470
from comet.driver.keithley import K2657A

smu_drivers = {
    "Keithely2410": K2410,
    "Keithely2470": K2470,
    "Keitley2657A": K2657A,
}

driver_name = "Keithely2470"

rm = pyvisa.ResourceManager("@py")

with rm.open_resource("TCPIP::0.0.0.0::11001::SOCKET") as res:
    smu = smu_drivers.get(driver_name)(res)

See comet/driver for available instrument drivers.

Helpers

Estimate

Estimate remaining time for loop operations using class Estimate.

Call method advance to proceed to the next iteration and update average and remaining time calculation.

from comet.estimate import Estimate

e = Estimate(42)  # start stopwatch
for i in range(42 + 1):
    ...
    e.advance()  # stop time since last step
    print("passed:", e.passed)
    print("remaining time:", e.remaining)
    print("elapsed time:", e.elapsed)
    print("average time:", e.average)

Filters

Test if standard deviation / mean < threshold using function std_mean_filter.

from comet.filters import std_mean_filter

if std_mean_filter(readings, threshold=0.005):
    ...

Functions

Voltage ramps using LinearRange generator class.

from comet.functions import LinearRange

for voltage in LinearRange(-10, +10, 0.25):
    ...

Parameter

Bind typed and bounded parameters to classes inheriting from class ParameterBase.

from comet.parameter import ParameterBase, Parameter

class Measurement(ParameterBase):

    voltage_level = Parameter(unit="V", minimum=-1000, maximum=1000)
    current_compliance = Parameter(default="25 uA", unit="A", minimum=0, maximum="10 mA")
    terminal = Parameter(default="front", choice=["front", "rear"])
    write_output = Parameter(default=True, type=bool)

measurement = Measurement({"voltage_level": "100 V"})  # supply required parameters

# Get dictionary of all parameter values.
print(measurement.parameters)
# {'voltage_level': 100.0, 'current_compliance': 2.5e-05, 'terminal': 'front', 'write_output': True}

# Update parameter values
measurement.update_parameters({"current_compliance": "50 uA", "terminal": "rear"})

# Access individual parameter
print(measurement.voltage_level)
# 100.0
print(measurement.current_compliance)
# 5e-05
print(measurement.terminal)
# 'rear'

measurement.write_output = False
# AttributeError: can't set parameter: 'write_output'

Utils

Use pint unit registry to convert between units.

from comet.utils import ureg, to_unit

quantity = ureg("25 nA").to("A")

print(to_unit(quantity, "mA"))
# 2.5e-05

print(to_unit("1200 V", "kV"))
# 1.2

print(to_unit(2.5, "pA"))
# 2.5

Emulators

To emulate one or more instruments using TCP sockets create a emulators.yaml configuration file in your project directory specifying emulator module and port.

version: '1.0'
emulators:
  smu:
    module: keithley.k2470
    port: 11001
  lcr:
    module: keysight.e4980a
    port: 11002

To spin up the emulator sockets execute the comet.emulator package.

python -m comet.emulator

Use command line argument -f to use a custom configuration file.

python -m comet.emulator -f custom_emulators.yaml

See comet/emulator for available instrument emulators.

License

COMET is licensed under the GNU General Public License Version 3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.