Skip to content

Commit

Permalink
[BC] remember original unit to correctly sum in dB
Browse files Browse the repository at this point in the history
  • Loading branch information
helene-t committed Feb 2, 2022
1 parent ae31abe commit 2369587
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
6 changes: 4 additions & 2 deletions SciDataTool/Methods/DataDual/get_along.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ def get_along(
is_norm=False,
axis_data=[],
is_squeeze=True,
is_magnitude=False
is_magnitude=False,
corr_unit=None,
):
"""Returns the ndarray of the field, using conversions and symmetries if needed.
Parameters
Expand Down Expand Up @@ -55,5 +56,6 @@ def get_along(
is_norm=is_norm,
axis_data=axis_data,
is_squeeze=is_squeeze,
is_magnitude=is_magnitude
is_magnitude=is_magnitude,
corr_unit=corr_unit,
)
6 changes: 3 additions & 3 deletions SciDataTool/Methods/DataND/_apply_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)


def _apply_operations(self, values, axes_list, is_magnitude, unit):
def _apply_operations(self, values, axes_list, is_magnitude, unit, corr_unit):
"""Returns the values of the field transformed or converted
Parameters
----------
Expand Down Expand Up @@ -64,7 +64,7 @@ def _apply_operations(self, values, axes_list, is_magnitude, unit):
# sum over sum axes
elif extension in "sum":
values = my_sum(
values, index, Nper, is_aper, unit, is_fft, corr_unit=self.unit
values, index, Nper, is_aper, unit, is_fft, corr_unit=corr_unit
)
# root sum square over rss axes
elif extension == "rss":
Expand All @@ -77,7 +77,7 @@ def _apply_operations(self, values, axes_list, is_magnitude, unit):
is_phys,
unit,
is_fft,
corr_unit=self.unit,
corr_unit=corr_unit,
)
# mean value over mean axes
elif extension == "mean":
Expand Down
7 changes: 5 additions & 2 deletions SciDataTool/Methods/DataND/get_along.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def get_along(
is_norm=False,
axis_data=[],
is_squeeze=True,
is_magnitude=False
is_magnitude=False,
corr_unit=None,
):
"""Returns the ndarray of the field, using conversions and symmetries if needed.
Parameters
Expand Down Expand Up @@ -78,7 +79,9 @@ def get_along(
# Interpolate over axis values
values = self._interpolate(values, axes_list)
# Apply operations such as sum, integration, derivations etc.
values = self._apply_operations(values, axes_list, is_magnitude, unit=self.unit)
values = self._apply_operations(
values, axes_list, is_magnitude, unit=self.unit, corr_unit=corr_unit
)
# Conversions
values = self._convert(values, unit, is_norm, is_squeeze, axes_list)
# Return axes and values
Expand Down
24 changes: 21 additions & 3 deletions SciDataTool/Methods/DataND/get_magnitude_along.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@


def get_magnitude_along(
self, *args, unit="SI", is_norm=False, axis_data=[], is_squeeze=True, is_sum=True
self,
*args,
unit="SI",
is_norm=False,
axis_data=[],
is_squeeze=True,
is_sum=True,
corr_unit=None
):
"""Returns the ndarray of the magnitude of the FT, using conversions and symmetries if needed.
Parameters
Expand Down Expand Up @@ -56,7 +63,11 @@ def get_magnitude_along(
*new_args, axis_data=axis_data, unit=unit
) # Extract first along freqs axis
return data.get_magnitude_along(
*[args[index_freq]], unit=unit, is_squeeze=is_squeeze, is_sum=False
*[args[index_freq]],
unit=unit,
is_squeeze=is_squeeze,
is_sum=False,
corr_unit=self.unit,
) # Then sum on freqs axis
else: # Try speed/order
is_match = 0
Expand Down Expand Up @@ -108,6 +119,7 @@ def get_magnitude_along(
unit=unit,
is_squeeze=is_squeeze,
is_sum=False,
corr_unit=self.unit,
) # Then sum on order axis
elif index_order is None: # Sum on speed axis
data = self.get_data_along(
Expand All @@ -118,6 +130,7 @@ def get_magnitude_along(
unit=unit,
is_squeeze=is_squeeze,
is_sum=False,
corr_unit=self.unit,
) # Then sum on speed axis
else: # Sum on speed and order axes
data = self.get_data_along(
Expand All @@ -128,12 +141,17 @@ def get_magnitude_along(
unit=unit,
is_squeeze=is_squeeze,
is_sum=False,
corr_unit=self.unit,
) # Then sum on speed and order axes

else:

return_dict = self.get_along(
*args, axis_data=axis_data, is_squeeze=is_squeeze, is_magnitude=True
*args,
axis_data=axis_data,
is_squeeze=is_squeeze,
is_magnitude=True,
corr_unit=corr_unit,
)
values = return_dict[self.symbol]

Expand Down

0 comments on commit 2369587

Please sign in to comment.