Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/conformer preprocessor #109

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions massdash/structs/Data1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,23 @@ def adjust_length(self, length):
(new_data, new_intensity) : tuple of padded/truncated data and intensity

"""

#### need to slice the array
if length == len(self.data):
new_data = self.data
new_intensity = self.intensity
elif length < len(self.data):
if length % 2 == 0:
slice_left = slice_right = length // 2
excess_length = len(self.data) - length
if excess_length % 2 == 0:
slice_left = slice_right = excess_length // 2
else: # length % 2 == 1
slice_left = length // 2 + 1
slice_right = length // 2
slice_left = excess_length // 2
slice_right = excess_length + 1 // 2
singjc marked this conversation as resolved.
Show resolved Hide resolved
new_data = self.data[slice_left:-slice_right]
new_intensity = self.intensity[slice_left:-slice_right]
else: # length > len(self.data):
### infer the chromatogram step size
step = self.data[1] - self.data[0]

both_even_or_odd = length % 2 == len(self.data) % 2
if both_even_or_odd:
pad_left = pad_right = (length - len(self.data)) // 2
Expand Down