diff --git a/lasp/lasp_measurement.py b/lasp/lasp_measurement.py index 3576f0f..53861b8 100644 --- a/lasp/lasp_measurement.py +++ b/lasp/lasp_measurement.py @@ -254,6 +254,7 @@ class Measurement: blocks = blocks.reshape(self.nblocks*self.blocksize, self.nchannels) + # Apply scaling (sensitivity, integer -> float) blocks = self.scaleBlock(blocks) return blocks @@ -323,7 +324,7 @@ class Measurement: if os.path.exists(fn) and not force: raise RuntimeError(f'File already exists: {fn}') with self.file() as f: - audio = self.f['audio'][:] + audio = f['audio'][:] if isinstance(audio.dtype, float): if sampwidth is None: diff --git a/lasp/lasp_record.py b/lasp/lasp_record.py index 1e36dc0..d6924e6 100644 --- a/lasp/lasp_record.py +++ b/lasp/lasp_record.py @@ -17,6 +17,10 @@ class Recording: def __init__(self, fn, stream, rectime=None): """ + Args: + fn: Filename to record to. extension is added + stream: AvStream instance to record from + rectime: Recording time, None for infinite """ ext = '.h5' if ext not in fn: @@ -58,6 +62,7 @@ class Recording: f.attrs['samplerate'] = stream.samplerate f.attrs['nchannels'] = stream.nchannels f.attrs['blocksize'] = stream.blocksize + f.attrs['sensitivity'] = stream.sensitivity f.attrs['time'] = time.time() self._running <<= True # Videothread is going to start diff --git a/scripts/lasp_playback b/scripts/lasp_playback index 333ff64..c43eaec 100755 --- a/scripts/lasp_playback +++ b/scripts/lasp_playback @@ -1,7 +1,11 @@ #!/usr/bin/python -import sys from lasp.lasp_playback import Playback +import argparse -fn = sys.argv[1] -p = Playback(fn) +parser = argparse.ArgumentParser( + description='Playback recorded measurement' +) +parser.add_argument('filename', help='Filename of measurement', type=str) +args = parser.parse_args() +p = Playback(args.filename) p.start() diff --git a/scripts/lasp_record b/scripts/lasp_record new file mode 100644 index 0000000..fe287bf --- /dev/null +++ b/scripts/lasp_record @@ -0,0 +1,21 @@ +#!/usr/bin/python +import argparse +from lasp.lasp_record import Recording +from lasp.lasp_avstream import AvStream + +parser = argparse.ArgumentParser( + description='Acquire data and store a measurement file' +) +parser.add_argument('filename', type=str, + help='File name to record to.' + ' Extension is automatically added.') +parser.add_argument('--duration', '-d', type=float, + help='The recording duration in [s]') +parser.add_argument('--comment', '-c', type=str, + help='Add a measurement comment, optionally') +args = parser.parse_args() + +stream = AvStream() +rec = Recording(args.filename, stream, args.duration) +rec.start() +stream.stop()