Skip to content

Commit

Permalink
Merge f43315f into 760deb3
Browse files Browse the repository at this point in the history
  • Loading branch information
scasagrande committed Oct 17, 2020
2 parents 760deb3 + f43315f commit c76708b
Show file tree
Hide file tree
Showing 130 changed files with 822 additions and 856 deletions.
29 changes: 15 additions & 14 deletions doc/examples/ex_qubitekkcc.py
Expand Up @@ -2,24 +2,25 @@
from sys import platform as _platform

import instruments as ik
from quantities import second, nanosecond
import instruments.units as u


def main():
cc = ik.qubitekk.CC1.open_serial(vid=1027, pid=24577, baud=19200, timeout=10)
cc1.dwell_time = 1.0 * second
print cc1.dwell_time
cc1.delay = 0.0 * nanosecond
print cc1.delay
cc1.window = 3.0 * nanosecond
print cc1.window
cc1 = ik.qubitekk.CC1.open_serial(vid=1027, pid=24577, baud=19200, timeout=10)
cc1.dwell_time = 1.0 * u.s
print(cc1.dwell_time)
cc1.delay = 0.0 * u.ns
print(cc1.delay)
cc1.window = 3.0 * u.ns
print(cc1.window)
cc1.trigger = ik.qubitekk.TriggerModeInt.start_stop
print cc1.trigger
print "Fetching Counts"
print cc1.channel[0].count
print cc1.channel[1].count
print cc1.channel[2].count
print "Fetched Counts"
print(cc1.trigger)
print("Fetching Counts")
print(cc1.channel[0].count)
print(cc1.channel[1].count)
print(cc1.channel[2].count)
print("Fetched Counts")


if __name__ == "__main__":
while True:
Expand Down
18 changes: 9 additions & 9 deletions doc/examples/ex_qubitekkcc_simple.py
Expand Up @@ -4,7 +4,7 @@
from sys import platform as _platform

import instruments as ik
import quantities
import instruments.units as u


if __name__ == "__main__":
Expand All @@ -15,13 +15,13 @@
else:
cc = ik.qubitekk.CC1.open_serial('COM8', 19200, timeout=1)

print "Initializing Coincidence Counter"
cc.dwell_time = 1.0*quantities.s
cc.delay = 0.0*quantities.ns
cc.window = 3.0*quantities.ns
print("Initializing Coincidence Counter")
cc.dwell_time = 1.0*u.s
cc.delay = 0.0*u.ns
cc.window = 3.0*u.ns
cc.trigger = cc.TriggerMode.start_stop
print "ch1 counts: "+str(cc.channel[0].count)
print "ch2 counts: "+str(cc.channel[1].count)
print "counts counts: "+str(cc.channel[2].count)
print(f"ch1 counts: {str(cc.channel[0].count)}")
print(f"ch2 counts: {str(cc.channel[1].count)}")
print(f"counts counts: {str(cc.channel[2].count)}")

print "Finished Initializing Coincidence Counter"
print("Finished Initializing Coincidence Counter")
2 changes: 1 addition & 1 deletion doc/examples/ex_tekdpo70000.ipynb
Expand Up @@ -152,7 +152,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"_.rescale('GHz')"
"_.to('GHz')"
],
"language": "python",
"metadata": {},
Expand Down
10 changes: 5 additions & 5 deletions doc/examples/ex_thorlabstc200.py
@@ -1,10 +1,10 @@
#Thorlabs Temperature Controller example

import instruments as ik
import quantities
import instruments.units as u
tc = ik.thorlabs.TC200.open_serial('/dev/tc200', 115200)

tc.temperature_set = 70*quantities.degF
tc.temperature_set = 70*u.degF
print("The current temperature is: ", tc.temperature)

tc.mode = tc.Mode.normal
Expand All @@ -22,7 +22,7 @@
tc.d = 2
print("The current d gain is: ", tc.d)

tc.degrees = quantities.degF
tc.degrees = u.degF
print("The current degrees settings is: ", tc.degrees)

tc.sensor = tc.Sensor.ptc100
Expand All @@ -31,10 +31,10 @@
tc.beta = 3900
print("The current beta settings is: ", tc.beta)

tc.max_temperature = 150*quantities.degC
tc.max_temperature = 150*u.degC
print("The current max temperature setting is: ", tc.max_temperature)

tc.max_power = 1000*quantities.mW
tc.max_power = 1000*u.mW
print("The current max power setting is: ", tc.max_power)


2 changes: 1 addition & 1 deletion doc/examples/srs_DG645.py
Expand Up @@ -15,7 +15,7 @@

# <markdowncell>

# We start by importing the `srs` package from within the main `instruments` package, along with the `quantities` package
# We start by importing the `srs` package from within the main `instruments` package, along with the `instruments.units` package
# that is used to track physical quantities.

# <codecell>
Expand Down
9 changes: 1 addition & 8 deletions doc/source/apiref/other.rst
Expand Up @@ -29,11 +29,4 @@ Units
-----

Units are identified to the Phase Matrix FSW-0020 using the
`~quantities.Quantity` class implemented by the `quantities` package. To support
the FSW-0020, we provide several additional unit quantities, listed here.

.. autodata:: mHz

.. autodata:: dBm

.. autodata:: cBm
`~pint.Quantity` class implemented by the `pint` package.
2 changes: 1 addition & 1 deletion doc/source/conf.py
Expand Up @@ -248,7 +248,7 @@
'http://docs.python.org/': None,
'numpy': ('http://docs.scipy.org/doc/numpy', None),
'serial': ('http://pyserial.sourceforge.net/', None),
'quantities': ('http://pythonhosted.org/quantities/', None),
'pint': ('https://pint.readthedocs.io/en/stable/', None),
}

autodoc_member_order = 'groupwise'
2 changes: 1 addition & 1 deletion doc/source/devguide/code_style.rst
Expand Up @@ -10,7 +10,7 @@ Data Types
Numeric Data
------------

When appropriate, use :class:`quantities.Quantity` objects to track units.
When appropriate, use :class:`pint.Quantity` objects to track units.
If this is not possible or appropriate, use a bare `float` for scalars
and `np.ndarray` for array-valued data.

Expand Down
10 changes: 5 additions & 5 deletions doc/source/devguide/util_fns.rst
Expand Up @@ -75,12 +75,12 @@ These properties, when implemented in your class, might look like this::
voltage = unitful_property(
"VOLT",
u.volt,
valid_range=(0*quantities.volt, 10*quantities.volt)
valid_range=(0*u.volt, 10*u.volt)
doc="""
Gets/sets the output voltage.

:units: As specified, or assumed to be :math:`\\text{V}` otherwise.
:type: `float` or `~quantities.Quantity`
:type: `float` or `~pint.Quantity`
"""
)

Expand Down Expand Up @@ -136,11 +136,11 @@ the `~instruments.thorlabs.TC200` class::
doc="""
Gets the actual temperature of the sensor

:units: As specified (if a `~quantities.quantity.Quantity`) or assumed
:units: As specified (if a `~pint.Quantity`) or assumed
to be of units degrees C.
:type: `~quantities.quantity.Quantity` or `int`
:type: `~pint.Quantity` or `int`
:return: the temperature (in degrees C)
:rtype: `~quantities.quantity.Quantity`
:rtype: `~pint.Quantity`
"""
)

Expand Down
4 changes: 2 additions & 2 deletions doc/source/intro.rst
Expand Up @@ -29,7 +29,7 @@ $ pip install -r requirements.txt

- NumPy
- `PySerial`_
- `quantities`_
- `pint`_
- `python-vxi11`_
- `PyUSB`_ (version 1.0a or higher, required for raw USB support)
- `python-usbtmc`_
Expand All @@ -40,7 +40,7 @@ Optional Dependencies
~~~~~~~~~~~~~~~~~~~~~

.. _PySerial: http://pyserial.sourceforge.net/
.. _quantities: http://pythonhosted.org/quantities/
.. _pint: https://pint.readthedocs.io/en/stable/
.. _ruamel.yaml: http://yaml.readthedocs.io
.. _PyUSB: http://sourceforge.net/apps/trac/pyusb/
.. _PyVISA: http://pyvisa.sourceforge.net/
Expand Down
5 changes: 4 additions & 1 deletion instruments/__init__.py
Expand Up @@ -6,6 +6,8 @@

# IMPORTS ####################################################################

__all__ = ["units"]


from . import abstract_instruments
from .abstract_instruments import Instrument
Expand Down Expand Up @@ -33,7 +35,8 @@
from . import toptica
from . import yokogawa

from . import units
from .units import ureg as units

from .config import load_instruments

# VERSION METADATA ###########################################################
Expand Down
12 changes: 6 additions & 6 deletions instruments/abstract_instruments/comm/gpib_communicator.py
Expand Up @@ -12,7 +12,7 @@
import io
import time

import instruments.units as u
from instruments.units import ureg as u

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
Expand Down Expand Up @@ -98,7 +98,7 @@ def timeout(self):
Gets/sets the timeeout of both the GPIB bus and the connection
channel between the PC and the GPIB adapter.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified, or assumed to be of units ``seconds``
"""
return self._timeout
Expand All @@ -107,13 +107,13 @@ def timeout(self):
def timeout(self, newval):
newval = assume_units(newval, u.second)
if self._model == GPIBCommunicator.Model.gi and self._version <= 4:
newval = newval.rescale(u.second)
newval = newval.to(u.second)
self._file.sendcmd('+t:{}'.format(int(newval.magnitude)))
else:
newval = newval.rescale(u.millisecond)
newval = newval.to(u.millisecond)
self._file.sendcmd("++read_tmo_ms {}".format(int(newval.magnitude)))
self._file.timeout = newval.rescale(u.second)
self._timeout = newval.rescale(u.second)
self._file.timeout = newval.to(u.second)
self._timeout = newval.to(u.second)

@property
def terminator(self):
Expand Down
6 changes: 3 additions & 3 deletions instruments/abstract_instruments/comm/serial_communicator.py
Expand Up @@ -11,7 +11,7 @@
import io
import serial

import instruments.units as u
from instruments.units import ureg as u

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
Expand Down Expand Up @@ -80,14 +80,14 @@ def timeout(self):
"""
Gets/sets the communication timeout of the serial comm channel.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified or assumed to be of units ``seconds``
"""
return self._conn.timeout * u.second

@timeout.setter
def timeout(self, newval):
newval = assume_units(newval, u.second).rescale(u.second).magnitude
newval = assume_units(newval, u.second).to(u.second).magnitude
self._conn.timeout = newval

# FILE-LIKE METHODS #
Expand Down
6 changes: 3 additions & 3 deletions instruments/abstract_instruments/comm/socket_communicator.py
Expand Up @@ -11,7 +11,7 @@
import io
import socket

import instruments.units as u
from instruments.units import ureg as u

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
Expand Down Expand Up @@ -70,14 +70,14 @@ def timeout(self):
"""
Gets/sets the connection timeout of the socket comm channel.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified or assumed to be of units ``seconds``
"""
return self._conn.gettimeout() * u.second

@timeout.setter
def timeout(self, newval):
newval = assume_units(newval, u.second).rescale(u.second).magnitude
newval = assume_units(newval, u.second).to(u.second).magnitude
self._conn.settimeout(newval)

# FILE-LIKE METHODS #
Expand Down
6 changes: 3 additions & 3 deletions instruments/abstract_instruments/comm/usbtmc_communicator.py
Expand Up @@ -14,7 +14,7 @@

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
import instruments.units as u
from instruments.units import ureg as u

# CLASSES #####################################################################

Expand Down Expand Up @@ -67,14 +67,14 @@ def timeout(self):
"""
Gets/sets the communication timeout of the usbtmc comm channel.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified or assumed to be of units ``seconds``
"""
return self._filelike.timeout * u.second

@timeout.setter
def timeout(self, newval):
newval = assume_units(newval, u.second).rescale(u.s).magnitude
newval = assume_units(newval, u.second).to(u.s).magnitude
self._filelike.timeout = newval

# FILE-LIKE METHODS #
Expand Down
4 changes: 2 additions & 2 deletions instruments/abstract_instruments/comm/visa_communicator.py
Expand Up @@ -14,7 +14,7 @@

from instruments.abstract_instruments.comm import AbstractCommunicator
from instruments.util_fns import assume_units
import instruments.units as u
from instruments.units import ureg as u

# CLASSES #####################################################################

Expand Down Expand Up @@ -86,7 +86,7 @@ def timeout(self):

@timeout.setter
def timeout(self, newval):
newval = assume_units(newval, u.second).rescale(u.second).magnitude
newval = assume_units(newval, u.second).to(u.second).magnitude
self._conn.timeout = newval

# FILE-LIKE METHODS #
Expand Down
Expand Up @@ -89,7 +89,7 @@ def timeout(self):
"""
Gets/sets the communication timeout of the vxi11 comm channel.
:type: `~quantities.Quantity`
:type: `~pint.Quantity`
:units: As specified or assumed to be of units ``seconds``
"""
return self._inst.timeout
Expand Down
2 changes: 1 addition & 1 deletion instruments/abstract_instruments/electrometer.py
Expand Up @@ -47,7 +47,7 @@ def unit(self):
Gets/sets the measurement mode for the electrometer. This is an
abstract method.
:type: `~quantities.UnitQuantity`
:type: `~pint.Unit`
"""

@property
Expand Down

0 comments on commit c76708b

Please sign in to comment.