Skip to content

Commit

Permalink
Merge pull request #43 from gisce/fix_filter_min_magn
Browse files Browse the repository at this point in the history
Añadir validación de filtrado para magnitudes
  • Loading branch information
fcapallera authored Apr 15, 2024
2 parents 8e1f6e3 + 53a2dae commit 88c3e92
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions powerprofile/powerprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,23 @@ def min(self, magn, ret='value', magn_0=None, force_magn_gt_0=False):
:param ret: value or timestamp of minimum
:return: min magnitude value
"""
filtered = self.curve.copy()
if self._check_magn_is_valid(magn):
filtered = self.curve.copy()

if force_magn_gt_0:
filtered = filtered[self.curve[magn] > 0]
if magn_0 is not None:
filtered = filtered[self.curve[magn_0] == 0]
if force_magn_gt_0:
filtered = filtered[self.curve[magn] > 0]

if self._check_magn_is_valid(magn):
if ret == 'value':
return filtered[magn].min()
elif ret == 'timestamp':
idx_min = filtered[magn].idxmin()
return self[idx_min][self.datetime_field]
if magn_0 is not None and self._check_magn_is_valid(magn_0):
filtered = filtered[self.curve[magn_0] == 0]

if not filtered.empty:
if ret == 'value':
return filtered[magn].min()
elif ret == 'timestamp':
idx_min = filtered[magn].idxmin()
return self[idx_min][self.datetime_field]

return False
return False

def avg(self, magn):
"""
Expand Down

0 comments on commit 88c3e92

Please sign in to comment.