Skip to content

Commit

Permalink
Merge branch 'master' into datarate_dependent_compressor
Browse files Browse the repository at this point in the history
  • Loading branch information
JoranAngevaare authored Feb 8, 2021
2 parents 96364e9 + d4e3516 commit 0b50666
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 52 deletions.
19 changes: 5 additions & 14 deletions straxen/plugins/led_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ def compute(self, raw_records):
del rr, raw_records

temp = np.zeros(len(r), dtype=self.dtype)

temp['channel'] = r['channel']
temp['time'] = r['time']
temp['dt'] = r['dt']
temp['length'] = r['length']
strax.copy_to_buffer(r, temp, "_recs_to_temp_led")

on, off = get_amplitude(r, self.config['led_window'], self.config['noise_window'])
temp['amplitude_led'] = on['amplitude']
Expand Down Expand Up @@ -100,24 +96,19 @@ def get_records(raw_records, baseline_window):
(('Waveform data in raw ADC counts', 'data'), 'f4', (record_length,))]

records = np.zeros(len(raw_records), dtype=_dtype)
strax.copy_to_buffer(raw_records, records, "_rr_to_r_led")

records['time'] = raw_records['time']
records['length'] = raw_records['length']
records['dt'] = raw_records['dt']
records['pulse_length'] = raw_records['pulse_length']
records['record_i'] = raw_records['record_i']
records['channel'] = raw_records['channel']
records['data'] = raw_records['data']

mask = np.where((records['record_i']==0)&(records['length']==160))[0]
mask = np.where((records['record_i'] == 0) & (records['length'] == 160))[0]
records = records[mask]
bl = records['data'][:, baseline_window[0]:baseline_window[1]].mean(axis=1)
records['data'][:, :160] = -1. * (records['data'][:, :160].transpose() - bl[:]).transpose()
return records


_on_off_dtype = np.dtype([('channel', 'int16'),
('amplitude', 'float32')])


def get_amplitude(records, led_window, noise_window):
"""
Needed for the SPE computation.
Expand Down
39 changes: 1 addition & 38 deletions straxen/plugins/veto_hitlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,46 +132,9 @@ def compute(self, records_nv, start, end):

# Remove data field:
hitlets = np.zeros(len(temp_hitlets), dtype=strax.hitlet_dtype())
drop_data_field(temp_hitlets, hitlets)

strax.copy_to_buffer(temp_hitlets, hitlets, '_copy_hitlets')
return hitlets

@numba.njit
def drop_data_field(old_hitlets, new_hitlets):
"""
Function which copies everything except for the data field.
If anyone know a better and faster way please let me know....
:param old_hitlets:
:param new_hitlets:
:return:
"""
n_hitlets = len(old_hitlets)
for i in range(n_hitlets):
o = old_hitlets[i]
n = new_hitlets[i]

n['time'] = o['time']
n['length'] = o['length']
n['dt'] = o['dt']
n['channel'] = o['channel']
n['area'] = o['area']
n['amplitude'] = o['amplitude']
n['time_amplitude'] = o['time_amplitude']
n['entropy'] = o['entropy']
n['fwhm'] = o['fwhm']
n['fwtm'] = o['fwtm']
n['range_50p_area'] = o['range_50p_area']
n['range_80p_area'] = o['range_80p_area']
n['range_hdr_50p_area'] = o['range_hdr_50p_area']
n['range_hdr_80p_area'] = o['range_hdr_80p_area']
n['left'] = o['left']
n['low_left'] = o['low_left']
n['left_area'] = o['left_area']
n['low_left_area'] = o['low_left_area']
n['left_hdr'] = o['left_hdr']
n['low_left_hdr'] = o['low_left_hdr']


@export
@strax.takes_config(
Expand Down

0 comments on commit 0b50666

Please sign in to comment.