From f4d230323359503caf71aa9d93135d610716946c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Weber?= Date: Sun, 27 Oct 2024 20:43:11 +0100 Subject: [PATCH] introduce to_base_units equivalent to the pint method --- src/pymodaq_data/data.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pymodaq_data/data.py b/src/pymodaq_data/data.py index eb9d085e..e899599f 100644 --- a/src/pymodaq_data/data.py +++ b/src/pymodaq_data/data.py @@ -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