本文整理汇总了Python中detector.Detector.measure_spectrum方法的典型用法代码示例。如果您正苦于以下问题:Python Detector.measure_spectrum方法的具体用法?Python Detector.measure_spectrum怎么用?Python Detector.measure_spectrum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类detector.Detector
的用法示例。
在下文中一共展示了Detector.measure_spectrum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Spectrometer
# 需要导入模块: from detector import Detector [as 别名]
# 或者: from detector.Detector import measure_spectrum [as 别名]
class Spectrometer(object):
'''This class represents the whole spectrometer.
It bundles the detector and source in one object.
:params detector: the selected detector (0 - builtin, default)
:type detector: int
:params source: the selected light source ('blue' is default)
:type source: str
'''
def __init__(self, **kwargs):
self.init_components(**kwargs)
def init_components(self, **kwargs):
print('Setting up spectrometer')
source = kwargs.get('source', 'blue')
detector = kwargs.get('detector', 0)
assert isinstance(source, str)
assert isinstance(detector, int)
self.source = Source(source)
self.detector = Detector(detector)
def measure(self, num_frames, num_dropped_frames, kind, **kwargs):
'''Executes a measurment.
:params num_frames: number of captured frames
:type num_frames: int
:params num_dropped_frames: number of frames to drop before collecting spectrum frames
:type num_dropped_frames: int
:params kind: The type of measurment. Choices are: 'background', 'spectrum', 'stream'
:type kind: str
'''
if kind == 'spectrum':
#self.source_on()
self.detector.measure_spectrum(num_frames, num_dropped_frames, **kwargs)
#self.source_off()
elif kind == 'background':
#self.source_on()
self.detector.measure_background(num_frames, num_dropped_frames, **kwargs)
#self.source_off()
elif kind == 'stream':
#self.source_on()
self.detector.stream()
#self.source_off()
else:
sys.exit('Measurment type unknow.')
示例2: Detector
# 需要导入模块: from detector import Detector [as 别名]
# 或者: from detector.Detector import measure_spectrum [as 别名]
from detector import Detector
from spectrum import Spectrum, write, load
from processor import Processor
d = Detector(0)
p = Processor()
b = d.measure_background(1, 10, kind='background', name='background')
write(b)
b.show()
s = d.measure_spectrum(1, 10, kind='background2', name='background2')
write(s)
s.show()
s.subtract(b)
write(s)
s.show()
p.load('spectrum.npy')
p.process(10)
p.write('spectrum.csv')
p.show()
#import os
#import time
#from spectrometer import Spectrometer
示例3: write
# 需要导入模块: from detector import Detector [as 别名]
# 或者: from detector.Detector import measure_spectrum [as 别名]
def write(spec, filename=None):
'''Writes the spectrum object to file.
'''
if not filename:
filename = spec.name + '.pks'
with open(filename, 'wb') as outf:
pickle.dump(spec, outf, pickle.HIGHEST_PROTOCOL)
print('Wrote spectrum file: {}'.format(filename))
def load(filename):
'''Loads the pickled spectrum object from file.
'''
with open(filename, 'rb') as inf:
spec = pickle.load(inf)
return spec
if __name__ == '__main__':
from detector import Detector
d = Detector()
b = d.measure_background(1, 1, kind='background', name='test')
s = d.measure_spectrum(10, 1, kind='spectrum', name='test')
s.process(10)
#write(s)
s.show()
#s.show_raw()