Skip to content

Commit

Permalink
introduce to_base_units
Browse files Browse the repository at this point in the history
equivalent to the pint method
  • Loading branch information
seb5g committed Oct 27, 2024
1 parent 9faa00e commit f4d2303
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pymodaq_data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,13 @@ def force_units(self, units: str):
""" Change immediately the units to whatever else. Use this with care!"""
self._units = units

def to_base_units(self):
dwa = self.deepcopy()
data_quantities = [quantity.to_base_units() for quantity in self.quantities]
dwa.data = [quantity.magnitude for quantity in data_quantities]
dwa.force_units(str(data_quantities[0].units))
return dwa

def value(self, units: str = None) -> float:
"""Returns the underlying float value (of the first elt in the data list) if this data
holds only a float otherwise returns a mean of the underlying data
Expand Down

0 comments on commit f4d2303

Please sign in to comment.