Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the forked lightlab #1

Merged
merged 65 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
790f1b0
Merge pull request #13 from lightwave-lab/development
thomaslima Jan 2, 2019
e63b2b9
PyPI deploy failed in travis
thomaslima Jan 2, 2019
7b0f6ef
Fixing lint error, fixing test requirements (full freeze)
thomaslima Jun 6, 2019
fe9ab8e
Linting Tektronix_DPO4032_Oscope
thomaslima Jun 6, 2019
d42dcba
Merge branch 'development' into DriverDevelopment
thomaslima Jun 6, 2019
c20d3f4
Updated formatting of the code files
ZhimuG Jun 6, 2019
56ca1d4
Update Tektronix_PPG3202.py
ZhimuG Jun 6, 2019
38d9b96
Update Tektronix_PPG3202.py
ZhimuG Jun 7, 2019
e275f79
Update Tektronix_PPG3202.py
ZhimuG Jun 7, 2019
be707f9
Update Tektronix_PPG3202.py
ZhimuG Jun 7, 2019
dafdbef
Merge pull request #20 from ZhimuG/DriverDevelopment
thomaslima Jun 8, 2019
175195d
Bumping version to 1.0.7
thomaslima Jun 8, 2019
a1dcda0
removed mbsession
aashuj Jun 17, 2019
0b95d0f
Merge branch 'bugfix_pna' into 'development'
thomaslima Jun 17, 2019
0a1aaf0
Merge branch 'master' into development
thomaslima Jun 28, 2019
3889fc6
Merge pull request #21 from lightwave-lab/development
thomaslima Jun 28, 2019
1dc0d8e
Merge remote-tracking branch 'origin/development' into development
thomaslima Jun 29, 2019
223b7fc
bumping version to 1.0.8.dev0
thomaslima Jun 29, 2019
fb7f73a
diverse bugfixes; sweep.save(filename, compress=True) available
thomaslima Aug 23, 2019
564737c
changing default sweep save to .pkl.gz (compress otherwise too large …
thomaslima Aug 23, 2019
c42fd69
repr(Waveform, Spectrum) works better now)
thomaslima Aug 24, 2019
ca4f76f
Included PRBS algorithms for the Anritsu PPG (1/2 mark only)
thomaslima Aug 25, 2019
1154598
Reducing assumptions on the abscissa in MeasuredFunction. Adding corr…
thomaslima Aug 27, 2019
47fc024
implemented __pow__ in MeasuredFunction
thomaslima Aug 28, 2019
10d2bf7
Adding nice summary for NdSweeper objects when printed
thomaslima Sep 22, 2019
d34ed43
Better resonance feature plotting
thomaslima Sep 23, 2019
225cb83
Changed peakfinding algorithm to account for FWHM between discrete wa…
thomaslima Sep 25, 2019
1598a82
Adding MockInstrument for use in data analysis
thomaslima Sep 25, 2019
4004613
minor
thomaslima Sep 26, 2019
67ce261
Minor fixes to Git with ipython notebooks docs
kynan Nov 10, 2019
ac24d04
Merge pull request #23 from kynan/patch-1
thomaslima Feb 6, 2020
c7effa0
Making _minAbsc accessible to scripts
thomaslima Feb 6, 2020
162d5ed
pylint/pytest errors, compatibility with latest packages
thomaslima Feb 6, 2020
0686633
Merge branch 'feb2020-update' into 'development'
thomaslima Feb 6, 2020
42d9879
Merge branch 'development' into dev-thomas
thomaslima Feb 7, 2020
740501d
fixing a few tests
thomaslima Feb 7, 2020
d4233ce
Adding support for Keithley 2606B
thomaslima Feb 9, 2020
1bc8e3d
Bugfixes in Keithley 2606B driver; Warning: high capacitance mode ena…
thomaslima Feb 10, 2020
968fd85
Bugfixes in Keithley 2606B drivers (ramp steps) TODO fix 2400 as well
thomaslima Feb 11, 2020
b3f07f4
optionally generate filedir during pprintFileDir
thomaslima Feb 13, 2020
a8664f8
passing simple tests
thomaslima Feb 18, 2020
d03f2c6
Temporarily ignoring failing test
thomaslima Feb 18, 2020
a093e21
really tired of formatting errors. blacking everything
thomaslima Feb 18, 2020
b98bfd8
Revert "really tired of formatting errors. blacking everything"
thomaslima Feb 18, 2020
330dd58
annoying lint
thomaslima Feb 18, 2020
970c5e0
Merge branch 'dev-thomas' into 'development'
thomaslima Feb 18, 2020
4045b91
PRBS functionality in one_dim
thomaslima Feb 24, 2020
1e43512
changing Butterworth filter default parameters and fixing nyquist fre…
thomaslima Feb 25, 2020
ffeb1d4
Adding subsample method to measured function
thomaslima Feb 25, 2020
0fb8ef5
not deleting data if sweep fails... ugh
thomaslima Feb 28, 2020
9b6bd15
Enabling None in MeasuredFunction.crop()
thomaslima Mar 3, 2020
386f683
small bugfix
thomaslima Mar 3, 2020
b53b4cd
Created SpectrumGHz object
thomaslima Mar 19, 2020
d966e6f
updating progress to temp file (easy way to check progress via ssh)
thomaslima Apr 17, 2020
39fd920
Fixing bug that shifted wavelengths from Apex OSA
thomaslima Apr 17, 2020
adf6f3a
Changing behavior of Keithley 2606B so that the output-off function i…
thomaslima Apr 17, 2020
a3b142f
Better live-plotting for NdSweeper
thomaslima Apr 30, 2020
070ac45
Minor warning in Apex driver, Including their manual
thomaslima Jun 24, 2020
b4199bb
A few linting fixes
thomaslima Jul 13, 2020
e96a71e
Merge pull request #26 from lightwave-lab/dev-thomas
thomaslima Jul 13, 2020
e83109d
Lint error (dangerous but ok for now)
thomaslima Jul 14, 2020
e528adc
SR830 lockin amplifier driver
simbilod Jul 9, 2021
25c711f
Create CITATION.cff
simbilod Sep 15, 2021
e9d1d8e
Update README.rst
simbilod Sep 16, 2021
2e0749b
BOSA driver (by Zhimu)
simbilod Jan 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
dev-requirements-temp.txt
test*.json
labstate*.json
.vscode

# compiled data
data/*
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
stages:
- test
- name: deploy
if: branch = master AND tag IS present
- deploy

stage: test
language: python
Expand Down
18 changes: 18 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# YAML 1.2
---
abstract: "A python library for remote laboratory control."
authors:
-
family-names: Tait
given-names: Alex
-
family-names: "Ferreira de Lima"
given-names: Thomas
cff-version: "1.1.0"
date-released: 2019-06-28
license: MIT
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/lightwave-lab/lightlab"
title: Lightlab
version: "1.0.7"
...
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default: help ;

venv: venv/bin/activate
venv/bin/activate:
test -e venv/bin/activate || virtualenv -p python3 --prompt "(lightlab-venv) " --distribute venv
test -e venv/bin/activate || virtualenv -p python3 --prompt "(lightlab-venv) " venv
touch venv/bin/activate

devbuild: venvinfo/devreqs~
Expand Down
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ Server: Mac OS and Linux running ≥python3.6; not tested on Windows (to do).

Auxiliary hosts: Mac OS, Linux, Windows

Acknowledgements
----------------

This material is based in part upon work supported by the National Science Foundation under Grant Number E2CDA-1740262. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
14 changes: 7 additions & 7 deletions docs/_static/misc/mergeWithNotebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Interactive tutorials are in notebooks. A full "experiment" in the lab is contai
Jupyter notebooks have two sections: inputs (code, markdown) and outputs (stdout, plots, images). Interactive python notebook files embed compiled outputs. This is good if you want to restart a kernel but still see the output, or if you close the file, etc.

### Solution 1 and Problem 2: The nbstripout filter
This is a cool thing that is integrated within the git commands. It basically ignores all of the outputs and metadata of `.ipynb` files. When you commit and push, it only pushes the inputs. It is installed via the requirements.txt, but there is also some interesting [discussion](https://stackoverflow.com/questions/18734739/using-ipython-notebooks-under-version-control/20844506) and [documentation](https://github.com/toobaz/ipynb_output_filter)
`nbstripout` is a Git filter and "hides" the output and some metadata in `.ipynb` files from Git such that it does not get committed. This allows only tracking the actual input code cells in Git. It is installed via the `requirements.txt`, but there is also some interesting [discussion](https://stackoverflow.com/questions/18734739/using-ipython-notebooks-under-version-control/20844506) and [documentation](https://github.com/kynan/nbstripout)

#### There are three downsides:
1. What if you liked keeping those outputs without rerunning every commit?
2. It has to strip evvverything, including all those high-quality graphics, every single time you `git status`.
3. It crashes your essential commands. Very easy to get into a chicken-and-egg hole where you can't `diff` anything because __some__thing isn't JSON -- causing a crash -- but you can't figure out what isn't JSON because you can't see which files just changed.
4. It corrupts your files. That's why we made cleannbline.
4. It can corrupt files. That's why we made `cleannbline`.

### Solution 2. Deactivate the nbstripout filter

Expand Down Expand Up @@ -75,13 +75,13 @@ Run

git status

It takes some time. What is that error? It means that some of the notebooks are not sufficiently JSON for the nbstripout filter.
It takes some time. What is that error? It means that some of the notebooks are not valid JSON and cannot be parsed by the `nbstripout` filter.

In the crash log, it should point to a certain file, let's say `notebooks/Test.ipynb` First, clean it with

./cleannbline notebooks/Test.ipynb

Then, open that file in Sublime and search for `<<<<`. Sometimes conflicts in your stash can get hidden in a way that does not show up in Jupyter. nbstripout will crash. You can find it in Sublime.
Then, open that file in Sublime and search for `<<<<`. Sometimes conflicts in your stash can get hidden in a way that does not show up in Jupyter. `nbstripout` will crash. You can find it in Sublime.

Return to running `git status` until it completes without error. It should show a ton of modifications: those are the effects of stripping. Add those and commit

Expand All @@ -95,13 +95,13 @@ Your filter is currently active, so when you try

it will automatically crash. As above though, it will point to a file. Keep going until `git status` completes. Add those and commit.

Side note: even though `git status` shows a ton of modifications, you should get a clean `git diff` (Although sometimes it will just crash, NBD). Both commands are applying the ipynb filter... in some way.
Side note: even though `git status` shows a ton of modifications, you should get a clean `git diff` (Although sometimes it will just crash, NBD). Both commands are applying the `.ipynb` filter... in some way.

#### Do the merge
git checkout test_merge_cool-feature-into-development
git merge cool-feature

You will get conflicts in two categories: notebooks and other. Since there are `<<<<` things everywhere, your `git diff` will crash while you're in the merge. It also doesn't point you to an offending file. Here is where you'll really appreciate Sublime.
You will get conflicts in two categories: notebooks and other. Since there are `<<<<` conflict markers everywhere, your `git diff` will crash while you're in the merge. It also doesn't point you to an offending file. Here is where you'll really appreciate Sublime.

Make sure Sublime opens the entire `notebooks` _directory_. That way Find All will search all the files.

Expand All @@ -116,7 +116,7 @@ Repeat for all the notebooks. Then do the same for all the regular code files. W

git commit

If for some reason, you want to escape the merge while keeping the test_merge branch stripped, you can run `git reset --hard`
If for some reason, you want to abandon the merge while keeping the test_merge branch stripped, you can run `git reset --hard`

#### Finalize
Double check that everything went well (i.e. open some notebooks in Jupyter). If something screwed up in your merging _or_ stripping, you can just delete the test_merge branch and start over.
Expand Down
3 changes: 1 addition & 2 deletions lightlab/equipment/abstract_drivers/TekScopeAbstract.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import pyvisa

from lightlab import logger
from lightlab.util.data import Waveform, FunctionBundle
Expand Down Expand Up @@ -154,7 +153,7 @@ def _triggerAcquire(self, timeout=None):
if timeout is None:
timeout = self.timeout / 1e3
if timeout > 60:
logger.warning(f'Long timeout {timeout} specified, testing')
logger.warning('Long timeout %s specified, testing', timeout)
old_avgCnt = self.timebaseConfig()['avgCnt']
self.timebaseConfig(avgCnt=2)
self._triggerAcquire(timeout=10)
Expand Down
3 changes: 2 additions & 1 deletion lightlab/equipment/abstract_drivers/configurable.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from lightlab import visalogger as logger
from pyvisa import VisaIOError
from contextlib import contextmanager
import dpath
import dpath.util
import json
from numpy import floor
from pathlib import Path
Expand Down Expand Up @@ -149,6 +149,7 @@ def transfer(self, source, subgroup=''):
raise Exception('Invalid source for transfer. Got ' + str(type(source)))
commands = sCon.getList(subgroup=subgroup)
self.setList(commands)
return self

@classmethod
def fromFile(cls, fname, subgroup=''):
Expand Down
4 changes: 2 additions & 2 deletions lightlab/equipment/abstract_drivers/electrical_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def _checkMode(cls, mode):
'''
if mode not in cls.supportedModes:
raise TypeError('Invalid mode: ' + str(mode) + '. Valid: ' + str(cls.supportedModes))
else:
return mode.lower()

return mode.lower()

@classmethod
def val2baseUnit(cls, value, mode):
Expand Down
2 changes: 1 addition & 1 deletion lightlab/equipment/lab_instruments/Agilent_N5222A_NA.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def spectrum(self):

self.setConfigParam('FORM', 'ASC')
self.open()
dbm = self.mbSession.query_ascii_values('CALC{}:DATA? FDATA'.format(self.chanNum))
dbm = self.query_ascii_values('CALC{}:DATA? FDATA'.format(self.chanNum))
self.close()

fStart = float(self.getConfigParam('SENS:FREQ:STAR'))
Expand Down
40 changes: 38 additions & 2 deletions lightlab/equipment/lab_instruments/Anritsu_MP1763B_PPG.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from . import VISAInstrumentDriver
from lightlab.equipment.abstract_drivers import Configurable
from lightlab.laboratory.instruments import PulsePatternGenerator
from lightlab.util.data.one_dim import prbs_pattern
import warnings
import numpy as np
import matplotlib.pyplot as plt
Expand All @@ -10,7 +11,7 @@ class Anritsu_MP1763B_PPG(VISAInstrumentDriver, Configurable):
''' ANRITSU MP1761A PulsePatternGenerator
The PPG MP1763B at Alex's bench, which also support MP1761A (by Hsuan-Tung 07/27/2017)

Manual?
Manual (MP1763C): http://www.otntech.com/modules/catalogue/download.php?id=52&mode=download&file_name=MP1763C.pdf

Usage: :any:`/ipynbs/Hardware/PulsePatternGenerator.ipynb`

Expand Down Expand Up @@ -182,7 +183,8 @@ def bitseq(self, chpulses, clockfreq, ext=0, addplot=False, mult=1, res=5):
# delay channel (D=0) outputs the (P=N) set of pulses, the second min. delay channel (D=1)
# outputs the (P=N-1) set of pulses, etc.
# As a result, each pulse receives an inverse channel delay: K - current_delay + pulsePosition, for some K.
# We set K to max(delay) since that sets the last channel [max(delay)] at the beginning of the pattern.
# We set K to max(delay) since that sets the last channel [max(delay)] at
# the beginning of the pattern.

pIndex = int(np.round((max(chpulses.keys()) - delay + pulsePos) * clockfreq))
# add pulse to pattern at correct delay
Expand All @@ -206,3 +208,37 @@ def circ_time(T, pattern):
plt.legend()

return pattern

@classmethod
def PRBS_pattern(cls, order, mark_ratio=0.5):
# Documentation present in page 5-1 of the manual.
if mark_ratio != 0.5:
raise NotImplementedError("Only mark ratio of 1/2 is implemented so far.")

# The seed corresponds to the first digits in the bit sequence
# presented on the PPG (inverted order)
if order == 7:
polynomial = 0b10000011 # 1 + X^6 + X^7
seed = 0b1000000
elif order == 9:
polynomial = 0b1000010001 # 1 + X^5 + X^9
seed = 0b111100000
elif order == 11:
polynomial = 0b100000000101 # 1+X9+X11
seed = 0b11000000000
elif order == 15:
polynomial = 0b1000000000000011 # 1+X14+X15
seed = 0b000000000000001
elif order == 20:
polynomial = (1 << 20) + (1 << 20 - 3) + (1 << 20 - 20) # 1+X3+X20
seed = 0b00111000111000111000
elif order == 23:
polynomial = (1 << 23) + (1 << 23 - 18) + (1 << 23 - 23) # 1+X18+X23
seed = 0b1111100 << 16
elif order == 31:
polynomial = (1 << 31) + (1 << 31 - 28) + (1 << 31 - 31) # 1+X28+X31
seed = 0b1110000 << 24
else:
raise NotImplementedError("PRBS{} not implemented.".format(order))

return prbs_pattern(polynomial, seed)
11 changes: 9 additions & 2 deletions lightlab/equipment/lab_instruments/Apex_AP2440A_OSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,14 @@ def transferData(self):

dataLen = int(powerData[0])
powerData = np.array(powerData[1:])
wavelengthData = np.linspace(self.wlRange[1], self.wlRange[0], dataLen)
retStr = self._query('SPDATAWL0')
wavelengthData = pyvisa.util.from_ascii_block(retStr,
converter='f',
separator=' ',
container=list)
assert dataLen == wavelengthData[0]
wavelengthData = np.array(wavelengthData[1:])
# wavelengthData = np.linspace(self.wlRange[1], self.wlRange[0], dataLen)

return wavelengthData[::-1], powerData[::-1]

Expand All @@ -205,7 +212,7 @@ def spectrum(self, average_count=1):
self.triggerAcquire()
nm, dbm = self.transferData()

if i is 0:
if i == 0:
dbmAvg = dbm / average_count
else:
dbmAvg = dbmAvg + dbm / average_count
Expand Down
Loading