Skip to content

Commit

Permalink
changed set temp to try except clause
Browse files Browse the repository at this point in the history
  • Loading branch information
wrf committed Oct 7, 2020
1 parent c5fcd7a commit 85c6a5e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions brizzy/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def plot_spectrum(x, y, filename, yhat=False):
def animate(frameno, inttime, monitor, prefix):
devices = sb.list_devices()
spec = sb.Spectrometer(devices[0])

spec_model = spec._dev._model
spec.integration_time_micros(inttime)
x = spec.wavelengths()
y = spec.intensities()
Expand All @@ -101,7 +101,7 @@ def animate(frameno, inttime, monitor, prefix):
a, delimiter = ',',
header = "wavelength,intensity",
fmt = '%.14f',
comments="#integration time: {0} ms\n#{0}\n".format(inttime/1000))
comments="#model: {0}\n#integration time: {1} ms\n".format( spec_model, inttime/1000) )
return line,

def run(args):
Expand All @@ -122,8 +122,14 @@ def run(args):
of unplugging things and plugging them in again.""")
print("Found this device: {}".format(devices[0]))
spec = sb.Spectrometer(devices[0])
spec.tec_set_enable(True)
spec.tec_set_temperature_C(4)

target_temp = 4
try: # this will not work on all models of Ocean Optics spectrophotometers
spec.tec_set_enable(True)
spec.tec_set_temperature_C(target_temp)
print("Setting temperature to {}C".format(target_temp) )
except AttributeError: # option not available for this model
print("Cannot set temperature on this device, skipping")

spec.integration_time_micros(int(args.integration_time * 1000))

Expand Down

0 comments on commit 85c6a5e

Please sign in to comment.