Functions
wirecell.sigproc.noise.microboone Namespace Reference

Functions

def load_noise_spectra_v1 (filename)
 

Detailed Description

Stuff to deal with MicroBooNE specific noise things and such.

Function Documentation

def wirecell.sigproc.noise.microboone.load_noise_spectra_v1 (   filename)
Load a noise spectra file in format

<sampfreq> <frequnits> <number> Ticks <gain> <gainunits> <shaping> <timeunit>
Freq  <wirelenghtincm1>  <wirelenghtincm2> ...
Plane <       planeid1>  <       planeid2> ...
-1    <  constantterm1>  <  constantterm1> ...
<freq0> <amplitude1[0]>  <  amplitude2[0]> ...
<freq1> <amplitude1[1]>  <  amplitude2[1]> ...
<freqN> <amplitude1[N]>  <  amplitude2[N]> ...

Also ignore lines starting with '#' or empty

Definition at line 12 of file microboone.py.

12 def load_noise_spectra_v1(filename):
13  '''
14  Load a noise spectra file in format
15 
16  <sampfreq> <frequnits> <number> Ticks <gain> <gainunits> <shaping> <timeunit>
17  Freq <wirelenghtincm1> <wirelenghtincm2> ...
18  Plane < planeid1> < planeid2> ...
19  -1 < constantterm1> < constantterm1> ...
20  <freq0> <amplitude1[0]> < amplitude2[0]> ...
21  <freq1> <amplitude1[1]> < amplitude2[1]> ...
22  <freqN> <amplitude1[N]> < amplitude2[N]> ...
23 
24  Also ignore lines starting with '#' or empty
25  '''
26  lines=list()
27  with open(filename) as fp:
28  for line in fp.readlines():
29  line = line.strip()
30  if not line:
31  continue
32  if line.startswith("#"):
33  continue
34  lines.append(line)
35  meta = lines[0].split()
36  period = 1.0/util.unitify(meta[0], meta[1])
37  nsamples = int(meta[2])
38  gain = util.unitify(meta[4], meta[5])
39  shaping = util.unitify(meta[6], meta[7])
40  wirelens = [float(v)*units.cm for v in lines[1].split()[1:]]
41  planes = [int(v) for v in lines[2].split()[1:]]
42  consts = [float(v)*units.mV for v in lines[3].split()[1:]]
43  data = list()
44  for line in lines[4:]:
45  data.append([float(v) for v in line.split()])
46  data = numpy.asarray(data)
47  freq = data[:,0]*util.unitify("1.0", meta[1])
48  amps = data[:,1:].T*units.mV
49  nwires = len(wirelens)
50  noises = list ()
51  for iwire in range(nwires):
52  ns = schema.NoiseSpectrum(period, nsamples, gain, shaping,
53  planes[iwire], wirelens[iwire],
54  consts[iwire], list(freq), list(amps[iwire]))
55  noises.append(ns)
56  if planes[iwire] == 1: # v1 implicitly equates U and V planes but only provides plane=1 data
57  ns0 = schema.NoiseSpectrum(period, nsamples, gain, shaping,
58  0, wirelens[iwire],
59  consts[iwire], list(freq), list(amps[iwire]))
60 
61  noises.append(ns0)
62  noises.sort(key = lambda s: 100*(s.plane+1) + s.wirelen/units.meter)
63  return noises
64 
int open(const char *, int)
Opens a file descriptor.
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35