Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 4 additions & 48 deletions stixcore/products/level0/scienceL0.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ class Spectrogram(ScienceProduct):

In level 0 format.
"""
PRODUCT_PROCESSING_VERSION = 4

def __init__(self, *, service_type, service_subtype, ssid, control, data,
idb_versions=defaultdict(SCETimeRange), **kwargs):
Expand Down Expand Up @@ -770,54 +771,9 @@ def from_levelb(cls, levelb, parent=''):

closing_time_offset = packets.get_value('NIX00269')

centers = []
deltas = []
ind = 0
for i, nt in enumerate(num_times):
edge = np.hstack(
[delta_time[ind:ind + nt], delta_time[ind + nt - 1] + closing_time_offset[i]])
delta = np.diff(edge)
center = edge[:-1] + delta / 2
centers.append(center)
deltas.append(delta)

# if energy_unit[i] > 1:
# logger.debug('Spectrogram binned onboard re-binning to standard science channels')
#
# dl_energies = np.array([ENERGY_CHANNELS[chs].e_lower for chs in cids[i][:-1]]
# + [ENERGY_CHANNELS[cids[i][-2]].e_upper])
#
# sci_energies = np.array([ENERGY_CHANNELS[chs].e_lower for chs in range(32)]
# + [ENERGY_CHANNELS[31].e_upper])
#
# e_ch_start = 0
# e_ch_end = counts.shape[1]
#
# if e_min[i][0] == 0:
# counts[ind:ind + nt, 0] = counts[ind:ind + nt, 0]
# counts_var[ind:ind + nt, 0] = counts_var[ind:ind + nt, 0]
# e_ch_start +=1
# if e_max[i][-1] == 32:
# counts[ind:ind + nt, -1] = counts[ind:ind + nt, -1]
# counts_var[ind:ind + nt, -1] = counts[ind:ind + nt, -1]
# e_ch_end -= 1
#
# torebin = np.where((cids[i] >= 1) & (cids[i] <= 31))
# counts[ind:ind + nt, 1:-1] = np.apply_along_axis(
# rebin_proportional, 1, counts[ind:ind + nt, e_ch_start:e_ch_end],
# dl_energies[torebin], sci_energies[1:-1])
#
# counts_var[ind:ind + nt, 1:-1] = np.apply_along_axis(
# rebin_proportional, 1, counts_var[ind:ind + nt, e_ch_start:e_ch_end],
# dl_energies[torebin], sci_energies[1:-1])

ind += nt

# if counts.sum() != orig_counts_sum:
# raise ValueError('Original and rebinned count totals do not match')

centers = np.hstack(centers)
deltas = np.hstack(deltas)
time_edges = np.hstack([delta_time, delta_time[-1]+closing_time_offset[-1]])
deltas = np.diff(time_edges)
centers = time_edges[:-1] + 0.5 * deltas
deltas = SCETimeDelta(deltas)

Comment on lines 816 to 778
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that is not only a fix but also a good code cleanup!

pixel_masks_orig = _get_pixel_mask(packets)
Expand Down
1 change: 1 addition & 0 deletions stixcore/products/level1/scienceL1.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class Spectrogram(ScienceProduct, L1Mixin):

In level 1 format.
"""
PRODUCT_PROCESSING_VERSION = 4

def __init__(self, *, service_type, service_subtype, ssid, control,
data, idb_versions=defaultdict(SCETimeRange), **kwargs):
Expand Down
Loading