Skip to content

Commit 083b43b

Browse files
authored
Merge pull request #196 from wright-group/development
REL: PyCMDS 0.9.0
2 parents 73db4fc + 4a4b2df commit 083b43b

File tree

40 files changed

+1207
-930
lines changed

40 files changed

+1207
-930
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ autonomic/files/
55
somatic/saved/
66
somatic/temp/
77
hardware/opas/OPA-800/OPA2 curves/
8+
hardware/opas/PoyntingCorrection/curves/
89
hardware/opas/OPA-800/OPA3 curves/
910
hardware/opas/OPA-800/Master Curves/
1011
hardware/opas/TOPAS/OPA? (*) curves/
@@ -23,6 +24,7 @@ hardware/filters/homebuilt/wheel B calibration
2324

2425
# Google Drive Credentials
2526
*.json
27+
!.zenodo.json
2628
*mycreds.txt
2729

2830
# PDFs
@@ -72,6 +74,7 @@ $RECYCLE.BIN/
7274
# python specific
7375
*.spyderworkspace
7476
*.pyc
77+
*__pycache__*
7578

7679
# Vim swap files
7780
*.sw?

.zenodo.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"license": {"id": "MIT"},
3+
"title": "PyCMDS",
4+
"upload_type": "software",
5+
"creators": [
6+
{
7+
"orcid": "0000-0002-3845-824X",
8+
"affiliation": "University of Wisconsin–Madison",
9+
"name": "Blaise J. Thompson"
10+
},
11+
{
12+
"orcid": "0000-0001-6167-8059",
13+
"affiliation": "University of Wisconsin–Madison",
14+
"name": "Kyle F. Sunden"
15+
},
16+
{
17+
"orcid": "0000-0002-8922-8049",
18+
"affiliation": "University of Wisconsin–Madison",
19+
"name": "Darien J. Morrow"
20+
},
21+
{
22+
"orcid": "0000-0002-9453-3590",
23+
"affiliation": "University of Wisconsin–Madison",
24+
"name": "Nathan Andrew Neff-Mallon"
25+
}
26+
],
27+
"access_right": "open"
28+
}

PyCMDS.pdf

-236 KB
Binary file not shown.

PyCMDS.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
# MAJOR.MINOR.PATCH (semantic versioning)
6969
# major version changes may break backwards compatibility
70-
__version__ = '0.8.0'
70+
__version__ = '0.9.0'
7171

7272
# add git branch, if appropriate
7373
p = os.path.join(directory, '.git', 'HEAD')
@@ -93,7 +93,7 @@ def __init__(self):
9393
QtGui.QMainWindow.__init__(self, parent=None)
9494
g.main_window.write(self)
9595
g.shutdown.write(self.shutdown)
96-
self.setWindowTitle('Coherent Multidimensional Spectroscopy | Python')
96+
self.setWindowTitle('PyCMDS %s'%__version__)
9797
# begin poll timer
9898
self._begin_poll_loop()
9999
# disable 'x'

autonomic/coset.py

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
import project.widgets as pw
1818
import project.project_globals as g
1919

20-
main_dir = g.main_dir.read()
21-
ini = project.ini_handler.Ini(os.path.join(main_dir, 'autonomic', 'coset.ini'))
22-
ini.return_raw = True
23-
24-
#hardwares (also ensure present in GUI)
20+
# hardwares (also ensure present in GUI)
2521
import hardware.opas.opas as opas
2622
import hardware.spectrometers.spectrometers as spectrometers
2723
import hardware.delays.delays as delays
2824
import hardware.filters.filters as filters
2925
all_hardwares = opas.hardwares + spectrometers.hardwares + delays.hardwares + filters.hardwares
3026

27+
main_dir = g.main_dir.read()
28+
ini = project.ini_handler.Ini(os.path.join(main_dir, 'autonomic', 'coset.ini'))
29+
ini.return_raw = True
30+
3131
# ensure that all elements are in the ini file
3232
all_hardware_names = [hw.name for hw in all_hardwares]
3333
ini.config.read(ini.filepath)
@@ -44,14 +44,13 @@
4444
if not ini.config.has_option(section, option):
4545
ini.write(section, option, None)
4646
ini.write(section, option + ' offset', 0.)
47-
4847

4948

5049
### objects ###################################################################
5150

5251

5352
class Corr:
54-
53+
5554
def __init__(self, path):
5655
self.path = path
5756
# headers
@@ -92,16 +91,17 @@ def evaluate(self):
9291
'''
9392
control_position = self.control_hardware.get_destination(self.control_units)
9493
# coerce control position to be within control_points array
95-
control_position = np.clip(control_position, self.control_points.min(), self.control_points.max())
94+
control_position = np.clip(
95+
control_position, self.control_points.min(), self.control_points.max())
9696
out = self.function(control_position)
9797
return out
98-
98+
9999
def interpolate(self):
100100
'''
101101
Generate interpolation function.
102102
'''
103103
self.function = scipy.interpolate.interp1d(self.control_points, self.offset_points)
104-
104+
105105
def zero(self):
106106
'''
107107
Zero based on current positions.
@@ -113,7 +113,7 @@ def zero(self):
113113

114114

115115
class CoSetHW:
116-
116+
117117
def __init__(self, hardware):
118118
self.hardware = hardware
119119
# directly write stored offset to hardware
@@ -141,7 +141,7 @@ def __init__(self, hardware):
141141
# initialize
142142
self.update_display()
143143
self.update_use_bool()
144-
144+
145145
def add_table_row(self, corr):
146146
# insert into table
147147
new_row_index = self.table.rowCount()
@@ -216,18 +216,19 @@ def create_frame(self, layout):
216216
self.table.setColumnWidth(1, 100)
217217
self.table.horizontalHeader().setStretchLastSection(True)
218218
settings_layout.addWidget(self.table)
219-
219+
220220
def launch(self):
221221
'''
222222
Apply offsets.
223223
'''
224224
if self.use_bool.read():
225-
corr_results = [corr.evaluate() for corr in self.corrs]
225+
corr_results = [wt.units.converter(
226+
corr.evaluate(), corr.offset_units, self.hardware.native_units) for corr in self.corrs]
226227
new_offset = np.sum(corr_results)
227228
if g.hardware_initialized.read():
228229
self.hardware.set_offset(new_offset, self.hardware.native_units)
229230
ini.write(self.hardware.name, 'offset', new_offset)
230-
231+
231232
def load_file(self, path):
232233
'''
233234
Load a file.
@@ -238,7 +239,7 @@ def load_file(self, path):
238239
self.update_combobox()
239240
self.update_use_bool()
240241
return corr
241-
242+
242243
def on_add_file(self):
243244
'''
244245
Add a file through file dialog.
@@ -262,15 +263,18 @@ def on_add_file(self):
262263
self.load_file(path)
263264
ini.write(self.hardware.name, corr.control_name, corr.path, with_apostrophe=True)
264265
self.display_combobox.write(corr.control_name)
265-
266+
266267
def on_remove_file(self, row):
267268
'''
268269
Fires when one of the REMOVE buttons gets pushed.
269270
'''
270271
# get row as int (given as QVariant)
271-
row = row.toInt()[0]
272+
try:
273+
row = row.toInt()[0]
274+
except AttributeError:
275+
pass # already an int?
272276
self.unload_file(row)
273-
277+
274278
def on_toggle_use(self):
275279
ini.write(self.hardware.name, 'use', self.use_bool.read())
276280
if self.use_bool.read():
@@ -279,7 +283,7 @@ def on_toggle_use(self):
279283
if g.hardware_initialized.read():
280284
self.hardware.set_offset(0., self.hardware.native_units)
281285
ini.write(self.hardware.name, 'offset', 0.)
282-
286+
283287
def unload_file(self, index):
284288
removed_corr = self.corrs.pop(index)
285289
ini.write(self.hardware.name, removed_corr.headers['control'], None)
@@ -300,14 +304,14 @@ def update_combobox(self):
300304
allowed_values = [corr.headers['control'] for corr in self.corrs]
301305
self.display_combobox.set_allowed_values(allowed_values)
302306
self.update_display()
303-
307+
304308
def update_use_bool(self):
305309
if len(self.corrs) == 0:
306310
self.use_bool.write(False)
307311
self.use_bool.set_disabled(True)
308312
else:
309313
self.use_bool.set_disabled(False)
310-
314+
311315
def update_display(self):
312316
if len(self.corrs) > 0:
313317
corr = self.corrs[self.display_combobox.read_index()]
@@ -319,9 +323,9 @@ def update_display(self):
319323
self.plot_scatter.clear()
320324
self.plot_scatter.setData(xi, yi)
321325
else:
322-
# this doesn't work as expected, but that isn't crucial right now
326+
# this doesn't work as expected, but that isn't crucial right now
323327
# - Blaise 2015.10.24
324-
self.plot_widget.set_labels('', '')
328+
self.plot_widget.set_labels('', '')
325329
self.plot_scatter.clear()
326330
self.plot_widget.update()
327331
self.plot_scatter.update()
@@ -339,21 +343,22 @@ def zero(self):
339343
self.launch()
340344
self.update_display()
341345

346+
342347
coset_hardwares = [] # list to contain all coset hardware objects
343348

344349

345350
### control ###################################################################
346351

347352

348353
class Control():
349-
354+
350355
def __init__(self):
351356
pass
352-
357+
353358
def launch(self):
354359
for coset_hardware in coset_hardwares:
355360
coset_hardware.launch()
356-
361+
357362
def zero(self, hardware_name):
358363
'''
359364
Offsets to zero forr all corrs based on current positions.
@@ -362,7 +367,8 @@ def zero(self, hardware_name):
362367
if coset_harware.hardware.name == hardware_name:
363368
coset_harware.zero()
364369
break
365-
370+
371+
366372
control = Control()
367373
g.hardware_waits.give_coset_control(control)
368374
g.coset_control.write(control)
@@ -375,7 +381,7 @@ class GUI(QtCore.QObject):
375381
def __init__(self):
376382
QtCore.QObject.__init__(self)
377383
self.create_frame()
378-
384+
379385
def create_frame(self):
380386
# get parent layout
381387
parent_widget = g.coset_widget.read()
@@ -397,7 +403,7 @@ def create_frame(self):
397403
if len(filters.hardwares) > 0:
398404
self.create_hardware_frame('Filters', filters.hardwares)
399405
parent_layout.addWidget(self.tabs)
400-
406+
401407
def create_hardware_frame(self, name, hardwares):
402408
container_widget = QtGui.QWidget()
403409
container_box = QtGui.QHBoxLayout()
@@ -411,7 +417,8 @@ def create_hardware_frame(self, name, hardwares):
411417
coset_hardware = CoSetHW(hardware)
412418
coset_hardwares.append(coset_hardware)
413419
tabs.addTab(coset_hardware.widget, hardware.name)
414-
420+
421+
415422
gui = GUI()
416423

417424

devices/InGaAs_array/Arduino_Program/Arduino_Program.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ volatile boolean pixel_ready = false;
2323
const int ds_address = 0xB0 >> 1; // DS1077 default address from its datasheet is 10110000,
2424
// or B0 but the wire library drops the read/write bit
2525
// and instead uses different read/write functions.
26-
int reset_time = 200;
26+
int reset_time = 1000;
2727
int runs_summed = 1;
2828
boolean running = false; // running ensures that the acquisitions won't begin until communication with labView is initiated
2929
String reset_string = "0000200";

0 commit comments

Comments
 (0)