3 Stuff to deal with MicroBooNE specific noise things and such. 6 from wirecell
import units, util
14 Load a noise spectra file in format 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]> ... 24 Also ignore lines starting with '#' or empty 27 with
open(filename)
as fp:
28 for line
in fp.readlines():
32 if line.startswith(
"#"):
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:]]
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)
51 for iwire
in range(nwires):
53 planes[iwire], wirelens[iwire],
54 consts[iwire], list(freq), list(amps[iwire]))
56 if planes[iwire] == 1:
59 consts[iwire], list(freq), list(amps[iwire]))
62 noises.sort(key =
lambda s: 100*(s.plane+1) + s.wirelen/units.meter)
def load_noise_spectra_v1(filename)
int open(const char *, int)
Opens a file descriptor.
void split(std::string const &s, char c, OutIter dest)