コード例 #1
0
def run(threshold=0.003,
        nchannels=500,
        vmax=2000.,
        scale=5400.,
        runtime=None,
        outfile=None,
        log=True,
        do_plot=True,
        input_device_name="",
        inputfile=None,
        realtime=True,
        fitpulse=False,
        fit_threshold=0.95):

    if inputfile is not None:
        source = FileReplay(filename=inputfile, realtime=realtime)
    else:
        source = SoundCard(input_device_name=input_device_name)
    convert = Raw2Float()
    if fitpulse:
        detect = FittedPulseDetection(threshold=threshold,
                                      fit_threshold=fit_threshold)
    else:
        detect = PulseDetection(threshold=threshold)

    count = Count(outfile=None)
    calibrate = Scale(scale=scale)
    histogram = AggregateHistogram(nchannels=int(nchannels * vmax / 1000.),
                                   vmin=0,
                                   vmax=vmax,
                                   outfile=outfile)

    source.plugs_into(convert)

    convert.plugs_into(detect)
    detect.plugs_into(count)
    detect.plugs_into(calibrate)
    calibrate.plugs_into(histogram)

    if do_plot:
        plothistogram = PlotHistogram(xmin=0,
                                      xmax=vmax,
                                      outfile=outfile,
                                      log=log)
        histogram.plugs_into(plothistogram)

    main(runtime)
コード例 #2
0
def run(input_device_name="", runtime=None, list_input_devices=False):
    if list_input_devices:
        for name, id_ in SoundCard.devices().items():
            print("{0}: {1}".format(name, id_))
        exit(0)

    source = SoundCard(input_device_name=input_device_name)

    monitor = Monitor()
    convert = Raw2Float()
    downsample = DownSampleMaxed(factor=16)

    source.plugs_into(convert)
    convert.plugs_into(downsample)
    downsample.plugs_into(monitor)

    main(runtime)
コード例 #3
0
ファイル: histogram.py プロジェクト: shoghicp/gammalab
import matplotlib
matplotlib.use('TkAgg')

from gammalab import main
from gammalab.acquisition import SoundCard
from gammalab.backend import Monitor
from gammalab.transform import Raw2Float, DownSampleMaxed, Scale
from gammalab.analysis import PulseDetection
from gammalab.analysis import AggregateHistogram
from gammalab.analysis import Count
from gammalab.backend import Playback, PlotHistogram

source = SoundCard()
monitor = Monitor(vmin=-0.01, vmax=0.1)
convert = Raw2Float()
downsample = DownSampleMaxed(factor=8)
detect = PulseDetection(threshold=0.003)
count = Count()
playback = Playback()
calibrate = Scale(scale=5400.)
histogram = AggregateHistogram(nchannels=5000, vmax=5400)
plothistogram = PlotHistogram(xmin=0, xmax=2000, log=False)

source.plugs_into(playback)
source.plugs_into(convert)

convert.plugs_into(detect)
detect.plugs_into(count)
detect.plugs_into(calibrate)
calibrate.plugs_into(histogram)
histogram.plugs_into(plothistogram)