diff --git a/SciDataTool/Methods/DataFreq/get_FT_along.py b/SciDataTool/Methods/DataFreq/get_FT_along.py index 1db3be35..8048eacf 100644 --- a/SciDataTool/Methods/DataFreq/get_FT_along.py +++ b/SciDataTool/Methods/DataFreq/get_FT_along.py @@ -37,7 +37,6 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): for index, axis in enumerate(self.axes): if axis.name == axis_name: is_match = True - break if not is_match: sys.stderr.write( "WARNING: Requested axis [" @@ -46,7 +45,7 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): ) axes_list.remove(axis_requested) # Extract the requested axes (symmetries + unit) - for i, axis_requested in enumerate(axes_list): + for axis_requested in axes_list: if axis_requested[3] == "values": # Get original values of the axis axis_requested.append( @@ -73,7 +72,6 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): values = rebuild_symmetries( values, index, self.symmetries.get(axis.name) ) - break # Extract the slices of the field for index, axis in enumerate(self.axes): is_match = False @@ -82,7 +80,6 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): is_match = True if axis_requested[3] == "indices": values = take(values, axis_requested[4], axis=index) - break if not is_match: # Axis was not specified -> take slice at the first value values = take(values, [0], axis=index) # Eliminate dimensions=1 @@ -98,7 +95,6 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - break # Eliminate dimensions=1 values = squeeze(values) # Convert into right unit diff --git a/SciDataTool/Methods/DataFreq/get_along.py b/SciDataTool/Methods/DataFreq/get_along.py index f160a970..39be4f85 100644 --- a/SciDataTool/Methods/DataFreq/get_along.py +++ b/SciDataTool/Methods/DataFreq/get_along.py @@ -32,7 +32,7 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): args = args[0] # if called from another script with *args axes_list = read_input_strings(args, axis_data) # Extract the requested axes (symmetries + unit) - for i, axis_requested in enumerate(axes_list): + for axis_requested in axes_list: if axis_requested[3] == "values": # Get original values of the axis axis_requested.append(self.get_axis(axis_requested[0] + axis_requested[1])) @@ -61,7 +61,6 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): for index, axis in enumerate(self.axes): if axis.name == axis_name: is_match = True - break if not is_match: sys.stderr.write( "WARNING: Requested axis [" @@ -77,7 +76,6 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): values = rebuild_symmetries( values, index, self.symmetries.get(axis.name) ) - break # Perform Inverse Fourier Transform values = comp_ifft(values) # Extract the slices of the field (single values) @@ -88,14 +86,10 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): is_match = True if axis_requested[3] == "indices" and axis_requested[2] == "single": values = take(values, axis_requested[4], axis=index) - break if not is_match: # Axis was not specified -> take slice at the first value values = take(values, [0], axis=index) - # Eliminate dimensions=1 - values = squeeze(values) # Interpolate over axis values (single values) - index = 0 - for axis in self.axes: + for index, axis in enumerate(self.axes): for axis_requested in axes_list: if ( axis.name == axis_requested[0] @@ -109,23 +103,20 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - index += 1 - break # Eliminate dimensions=1 values = squeeze(values) # Extract slices again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: - if axis.name == axis_requested[0]: - if axis_requested[2] == "indices" and axis_requested[2] == "interval": - values = take(values, axis_requested[4], axis=index) - index += 1 - break + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: + if ( + axis.name == axis_requested[0] + and axis_requested[2] == "indices" + and axis_requested[2] == "interval" + ): + values = take(values, axis_requested[4], axis=index) # Interpolate over axis values again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: if ( axis.name == axis_requested[0] and axis_requested[3] == "values" @@ -138,8 +129,6 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - index += 1 - break # Convert into right unit if unit == self.unit or unit == "SI": if is_norm: diff --git a/SciDataTool/Methods/DataFreq/get_magnitude_along.py b/SciDataTool/Methods/DataFreq/get_magnitude_along.py index 9e3f0f9a..848eebb2 100644 --- a/SciDataTool/Methods/DataFreq/get_magnitude_along.py +++ b/SciDataTool/Methods/DataFreq/get_magnitude_along.py @@ -33,7 +33,7 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axes_list = read_input_strings(args, axis_data) is_FTslice = False # Extract the requested axes (symmetries + unit) - for i, axis_requested in enumerate(axes_list): + for axis_requested in axes_list: if axis_requested[3] == "values": # Get original values of the axis axis_requested.append( @@ -66,7 +66,6 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): for index, axis in enumerate(self.axes): if axis.name == axis_name: is_match = True - break if not is_match: sys.stderr.write( "WARNING: Requested axis [" @@ -82,7 +81,6 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): values = rebuild_symmetries( values, index, self.symmetries.get(axis.name) ) - break # If a slice at a given time or angle is requested, perform inverse FT, then slice, then FT if is_FTslice: values = comp_ifft(values) @@ -94,11 +92,8 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): is_match = True if axis_requested[3] == "indices" and axis_requested[2] == "single": values = take(values, axis_requested[4], axis=index) - break if not is_match: # Axis was not specified -> take slice at the first value values = take(values, [0], axis=index) - # Eliminate dimensions=1 - values = squeeze(values) # Interpolate over axis values (single values) for index, axis in enumerate(self.axes): for axis_requested in axes_list: @@ -114,27 +109,23 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - break - # Eliminate dimensions=1 - values = squeeze(values) # If a slice at a given time or angle is requested, perform inverse FT, then slice, then FT if is_FTslice: values = np_abs(comp_fft(values)) else: values = np_abs(values) # Extract slices again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: - if axis.name == axis_requested[0]: - if axis_requested[2] == "indices" and axis_requested[2] == "interval": - values = take(values, axis_requested[4], axis=index) - index += 1 - break + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: + if ( + axis.name == axis_requested[0] + and axis_requested[2] == "indices" + and axis_requested[2] == "interval" + ): + values = take(values, axis_requested[4], axis=index) # Interpolate over axis values again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: if ( axis.name == axis_requested[0] and axis_requested[3] == "values" @@ -147,8 +138,8 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - index += 1 - break + # Eliminate dimensions=1 + values = squeeze(values) # Convert into right unit if unit == self.unit or unit == "SI": if is_norm: diff --git a/SciDataTool/Methods/DataFreq/get_phase_along.py b/SciDataTool/Methods/DataFreq/get_phase_along.py index 532e541a..267bb593 100644 --- a/SciDataTool/Methods/DataFreq/get_phase_along.py +++ b/SciDataTool/Methods/DataFreq/get_phase_along.py @@ -33,7 +33,7 @@ def get_phase_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axes_list = read_input_strings(args, axis_data) is_FTslice = False # Extract the requested axes (symmetries + unit) - for i, axis_requested in enumerate(axes_list): + for axis_requested in axes_list: if axis_requested[3] == "values": # Get original values of the axis axis_requested.append( @@ -66,7 +66,6 @@ def get_phase_along(self, *args, unit="SI", is_norm=False, axis_data=[]): for index, axis in enumerate(self.axes): if axis.name == axis_name: is_match = True - break if not is_match: sys.stderr.write( "WARNING: Requested axis [" @@ -82,7 +81,6 @@ def get_phase_along(self, *args, unit="SI", is_norm=False, axis_data=[]): values = rebuild_symmetries( values, index, self.symmetries.get(axis.name) ) - break # If a slice at a given time or angle is requested, perform inverse FT, then slice, then FT if is_FTslice: values = comp_ifft(values) @@ -94,11 +92,8 @@ def get_phase_along(self, *args, unit="SI", is_norm=False, axis_data=[]): is_match = True if axis_requested[3] == "indices" and axis_requested[2] == "single": values = take(values, axis_requested[4], axis=index) - break if not is_match: # Axis was not specified -> take slice at the first value values = take(values, [0], axis=index) - # Eliminate dimensions=1 - values = squeeze(values) # Interpolate over axis values (single values) for index, axis in enumerate(self.axes): for axis_requested in axes_list: @@ -114,9 +109,6 @@ def get_phase_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - break - # Eliminate dimensions=1 - values = squeeze(values) # If a slice at a given time or angle is requested, perform inverse FT, then slice, then FT if is_FTslice: if unit == "°": @@ -129,18 +121,17 @@ def get_phase_along(self, *args, unit="SI", is_norm=False, axis_data=[]): else: values = np_angle(values) # Extract slices again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: - if axis.name == axis_requested[0]: - if axis_requested[2] == "indices" and axis_requested[2] == "interval": - values = take(values, axis_requested[4], axis=index) - index += 1 - break + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: + if ( + axis.name == axis_requested[0] + and axis_requested[2] == "indices" + and axis_requested[2] == "interval" + ): + values = take(values, axis_requested[4], axis=index) # Interpolate over axis values again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: if ( axis.name == axis_requested[0] and axis_requested[3] == "values" @@ -153,8 +144,8 @@ def get_phase_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - index += 1 - break + # Eliminate dimensions=1 + values = squeeze(values) # Convert into right unit if unit == self.unit or unit == "SI" or unit == "°": if is_norm: diff --git a/SciDataTool/Methods/DataTime/get_FT_along.py b/SciDataTool/Methods/DataTime/get_FT_along.py index b8b61429..3d447e91 100644 --- a/SciDataTool/Methods/DataTime/get_FT_along.py +++ b/SciDataTool/Methods/DataTime/get_FT_along.py @@ -32,7 +32,7 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): args = args[0] # if called from another script with *args axes_list = read_input_strings(args, axis_data) # Extract the requested axes (symmetries + unit) - for i, axis_requested in enumerate(axes_list): + for axis_requested in axes_list: if axis_requested[3] == "values": # Get original values of the axis axis_requested.append( @@ -63,7 +63,6 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): for index, axis in enumerate(self.axes): if axis.name == axis_name: is_match = True - break if not is_match: sys.stderr.write( "WARNING: Requested axis [" @@ -79,7 +78,6 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): values = rebuild_symmetries( values, index, self.symmetries.get(axis.name) ) - break # Extract the slices of the field (single values) for index, axis in enumerate(self.axes): is_match = False @@ -88,14 +86,10 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): is_match = True if axis_requested[3] == "indices" and axis_requested[2] == "single": values = take(values, axis_requested[4], axis=index) - break if not is_match: # Axis was not specified -> take slice at the first value values = take(values, [0], axis=index) - # Eliminate dimensions=1 - values = squeeze(values) # Interpolate over axis values (single values) - index = 0 - for axis in self.axes: + for index, axis in enumerate(self.axes): for axis_requested in axes_list: if ( axis.name == axis_requested[0] @@ -109,39 +103,30 @@ def get_FT_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - index += 1 - break - # Eliminate dimensions=1 - values = squeeze(values) # Perform Fourier Transform values = comp_fft(values) # Extract slices again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: if axis.name == axis_requested[0]: if axis_requested[2] == "indices" and axis_requested[2] == "interval": values = take(values, axis_requested[4], axis=index) - index += 1 - break # Interpolate over axis values again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: if ( axis.name == axis_requested[0] - and axis_requested[3] == "values" - and axis_requested[2] == "interval" - ): + and axis_requested[3] == "values" and axis_requested[2] == "interval" + ): values = apply_along_axis( get_interpolation, index, values, axis_requested[5], axis_requested[4], - ) - index += 1 - break + ) + # Eliminate dimensions=1 + values = squeeze(values) # Convert into right unit if unit == self.unit or unit == "SI": if is_norm: diff --git a/SciDataTool/Methods/DataTime/get_along.py b/SciDataTool/Methods/DataTime/get_along.py index e5ab771a..eeb81494 100644 --- a/SciDataTool/Methods/DataTime/get_along.py +++ b/SciDataTool/Methods/DataTime/get_along.py @@ -36,7 +36,6 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): for index, axis in enumerate(self.axes): if axis.name == axis_name: is_match = True - break if not is_match: print( "WARNING: Requested axis [" @@ -45,7 +44,7 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): ) axes_list.remove(axis_requested) # Extract the requested axes (symmetries + unit) - for i, axis_requested in enumerate(axes_list): + for axis_requested in axes_list: if axis_requested[3] == "values": # Get original values of the axis axis_requested.append(self.get_axis(axis_requested[0] + axis_requested[1])) @@ -70,7 +69,6 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): values = rebuild_symmetries( values, index, self.symmetries.get(axis.name) ) - break # Extract the slices of the field for index, axis in enumerate(self.axes): is_match = False @@ -79,16 +77,15 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): is_match = True if axis_requested[3] == "indices": values = take(values, axis_requested[4], axis=index) - break if not is_match: # Axis was not specified -> take slice at the first value values = take(values, [0], axis=index) - # Eliminate dimensions=1 - values = squeeze(values) # Interpolate over axis values - index = 0 - for axis in self.axes: + for index, axis in enumerate(self.axes): for axis_requested in axes_list: - if axis.name == axis_requested[0] and axis_requested[3] == "values": + if ( + axis.name == axis_requested[0] + and axis_requested[3] == "values" + ): values = apply_along_axis( get_interpolation, index, @@ -96,8 +93,6 @@ def get_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - index += 1 - break # Eliminate dimensions=1 values = squeeze(values) # Convert into right unit diff --git a/SciDataTool/Methods/DataTime/get_harmonics.py b/SciDataTool/Methods/DataTime/get_harmonics.py index 8f8194c7..ee0b1426 100644 --- a/SciDataTool/Methods/DataTime/get_harmonics.py +++ b/SciDataTool/Methods/DataTime/get_harmonics.py @@ -42,7 +42,7 @@ def get_harmonics(self, N_harm, *args, unit="SI", is_norm=False, is_flat=False): args = args[0] # if called from another script with *args axes_list = read_input_strings(args, []) # Extract the requested axes (symmetries + unit) - for i, axis_requested in enumerate(axes_list): + for axis_requested in axes_list: if axis_requested[3] == "values": # Get original values of the axis axis_requested.append( @@ -68,7 +68,6 @@ def get_harmonics(self, N_harm, *args, unit="SI", is_norm=False, is_flat=False): for index, axis in enumerate(self.axes): if axis.name == axis_name: is_match = True - break if not is_match: sys.stderr.write( "WARNING: Requested axis [" @@ -84,7 +83,6 @@ def get_harmonics(self, N_harm, *args, unit="SI", is_norm=False, is_flat=False): values = rebuild_symmetries( values, index, self.symmetries.get(axis.name) ) - break # Extract the slices of the field (single values) for index, axis in enumerate(self.axes): is_match = False @@ -93,11 +91,8 @@ def get_harmonics(self, N_harm, *args, unit="SI", is_norm=False, is_flat=False): is_match = True if axis_requested[3] == "indices" and axis_requested[2] == "single": values = take(values, axis_requested[4], axis=index) - break if not is_match: # Axis was not specified -> take slice at the first value values = take(values, [0], axis=index) - # Eliminate dimensions=1 - values = squeeze(values) # Interpolate over axis values (single values) for index, axis in enumerate(self.axes): for axis_requested in axes_list: @@ -113,38 +108,28 @@ def get_harmonics(self, N_harm, *args, unit="SI", is_norm=False, is_flat=False): axis_requested[5], axis_requested[4], ) - break - # Eliminate dimensions=1 - values = squeeze(values) # Perform Fourier Transform values = np_abs(comp_fft(values)) # Extract slices again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: if axis.name == axis_requested[0]: if axis_requested[2] == "indices" and axis_requested[2] == "interval": values = take(values, axis_requested[4], axis=index) - index += 1 - break # Interpolate over axis values again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: - if ( - axis.name == axis_requested[0] - and axis_requested[3] == "values" - and axis_requested[2] == "interval" - ): - values = apply_along_axis( - get_interpolation, - index, - values, - axis_requested[5], - axis_requested[4], - ) - index += 1 - break + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: + if axis.name == axis_requested[0]: + if axis_requested[3] == "values" and axis_requested[2] == "interval": + values = apply_along_axis( + get_interpolation, + index, + values, + axis_requested[5], + axis_requested[4], + ) + # Eliminate dimensions=1 + values = squeeze(values) # Test if data is 1D or 2D if len(values.shape) > 2: raise AxisError("ERROR: only 1D or 2D implemented") diff --git a/SciDataTool/Methods/DataTime/get_magnitude_along.py b/SciDataTool/Methods/DataTime/get_magnitude_along.py index c843d6ab..ccaa50a3 100644 --- a/SciDataTool/Methods/DataTime/get_magnitude_along.py +++ b/SciDataTool/Methods/DataTime/get_magnitude_along.py @@ -32,7 +32,7 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): args = args[0] # if called from another script with *args axes_list = read_input_strings(args, axis_data) # Extract the requested axes (symmetries + unit) - for i, axis_requested in enumerate(axes_list): + for axis_requested in axes_list: if axis_requested[3] == "values": # Get original values of the axis axis_requested.append( @@ -63,7 +63,6 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): for index, axis in enumerate(self.axes): if axis.name == axis_name: is_match = True - break if not is_match: sys.stderr.write( "WARNING: Requested axis [" @@ -79,8 +78,7 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): values = rebuild_symmetries( values, index, self.symmetries.get(axis.name) ) - break - # Extract the slices of the field (single values) + # Extract the slices of the field (single index) for index, axis in enumerate(self.axes): is_match = False for axis_requested in axes_list: @@ -88,14 +86,10 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): is_match = True if axis_requested[3] == "indices" and axis_requested[2] == "single": values = take(values, axis_requested[4], axis=index) - break if not is_match: # Axis was not specified -> take slice at the first value values = take(values, [0], axis=index) - # Eliminate dimensions=1 - values = squeeze(values) # Interpolate over axis values (single values) - index = 0 - for axis in self.axes: + for index, axis in enumerate(self.axes): for axis_requested in axes_list: if ( axis.name == axis_requested[0] @@ -109,36 +103,31 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - index += 1 - break - # Eliminate dimensions=1 - values = squeeze(values) # Perform Fourier Transform values = comp_magnitude(values) # Extract slices again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: if axis.name == axis_requested[0]: if axis_requested[2] == "indices" and axis_requested[2] == "interval": values = take(values, axis_requested[4], axis=index) - index += 1 - break # Interpolate over axis values again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: - if axis.name == axis_requested[0]: - if axis_requested[3] == "values" and axis_requested[2] == "interval": - values = apply_along_axis( - get_interpolation, - index, - values, - axis_requested[5], - axis_requested[4], - ) - index += 1 - break + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: + if ( + axis.name == axis_requested[0] + and axis_requested[3] == "values" + and axis_requested[2] == "interval" + ): + values = apply_along_axis( + get_interpolation, + index, + values, + axis_requested[5], + axis_requested[4], + ) + # Eliminate dimensions=1 + values = squeeze(values) # Convert into right unit if unit == self.unit or unit == "SI": if is_norm: diff --git a/SciDataTool/Methods/DataTime/get_phase_along.py b/SciDataTool/Methods/DataTime/get_phase_along.py index 06344bc3..072d801b 100644 --- a/SciDataTool/Methods/DataTime/get_phase_along.py +++ b/SciDataTool/Methods/DataTime/get_phase_along.py @@ -32,7 +32,7 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): args = args[0] # if called from another script with *args axes_list = read_input_strings(args, axis_data) # Extract the requested axes (symmetries + unit) - for i, axis_requested in enumerate(axes_list): + for axis_requested in axes_list: if axis_requested[3] == "values": # Get original values of the axis axis_requested.append( @@ -63,7 +63,6 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): for index, axis in enumerate(self.axes): if axis.name == axis_name: is_match = True - break if not is_match: sys.stderr.write( "WARNING: Requested axis [" @@ -79,7 +78,6 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): values = rebuild_symmetries( values, index, self.symmetries.get(axis.name) ) - break # Extract the slices of the field (single values) for index, axis in enumerate(self.axes): is_match = False @@ -88,14 +86,10 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): is_match = True if axis_requested[3] == "indices" and axis_requested[2] == "single": values = take(values, axis_requested[4], axis=index) - break if not is_match: # Axis was not specified -> take slice at the first value values = take(values, [0], axis=index) - # Eliminate dimensions=1 - values = squeeze(values) # Interpolate over axis values (single values) - index = 0 - for axis in self.axes: + for index, axis in enumerate(self.axes): for axis_requested in axes_list: if ( axis.name == axis_requested[0] @@ -109,25 +103,20 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - index += 1 - break - # Eliminate dimensions=1 - values = squeeze(values) # Perform Fourier Transform values = comp_phase(values) # Extract slices again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: - if axis.name == axis_requested[0]: - if axis_requested[2] == "indices" and axis_requested[2] == "interval": - values = take(values, axis_requested[4], axis=index) - index += 1 - break + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: + if ( + axis.name == axis_requested[0] + and axis_requested[2] == "indices" + and axis_requested[2] == "interval" + ): + values = take(values, axis_requested[4], axis=index) # Interpolate over axis values again (intervals) - index = 0 - for axis_requested in axes_list: - for axis in self.axes: + for index, axis in enumerate(self.axes): + for axis_requested in axes_list: if ( axis.name == axis_requested[0] and axis_requested[3] == "values" @@ -140,8 +129,8 @@ def get_magnitude_along(self, *args, unit="SI", is_norm=False, axis_data=[]): axis_requested[5], axis_requested[4], ) - index += 1 - break + # Eliminate dimensions=1 + values = squeeze(values) # Convert into right unit if unit == self.unit or unit == "SI": if is_norm: