diff --git a/aurora/pipelines/process_mth5.py b/aurora/pipelines/process_mth5.py index 49f41244..f737caed 100644 --- a/aurora/pipelines/process_mth5.py +++ b/aurora/pipelines/process_mth5.py @@ -278,7 +278,7 @@ def load_stft_obj_from_mth5( """ Load stft_obj from mth5 (instead of compute) - Note #1: See note #1 in time_series.frequency_band_helpers.extract_band + Note #1: See note #1 in mth5.timeseries.spectre.spectrogram.py in extract_band function. Parameters ---------- diff --git a/aurora/time_series/frequency_band_helpers.py b/aurora/time_series/frequency_band_helpers.py index e80c80ed..c4b34d45 100644 --- a/aurora/time_series/frequency_band_helpers.py +++ b/aurora/time_series/frequency_band_helpers.py @@ -6,6 +6,7 @@ from mt_metadata.transfer_functions.processing.aurora import ( DecimationLevel as AuroraDecimationLevel, ) +from mth5.timeseries.spectre.spectrogram import extract_band def get_band_for_tf_estimate( @@ -52,50 +53,6 @@ def get_band_for_tf_estimate( return X, Y, RR - -def extract_band(frequency_band, fft_obj, channels=[], epsilon=1e-7): - """ - Extracts a frequency band from xr.DataArray representing a spectrogram. - - Stand alone version of the method that is used by WIP Spectrogram class. - - Development Notes: - #1: 20230902 - TODO: Decide if base dataset object should be a xr.DataArray (not xr.Dataset) - - drop=True does not play nice with h5py and Dataset, results in a type error. - File "stringsource", line 2, in h5py.h5r.Reference.__reduce_cython__ - TypeError: no default __reduce__ due to non-trivial __cinit__ - However, it works OK with DataArray, so maybe use data array in general - - Parameters - ---------- - frequency_band: mt_metadata.transfer_functions.processing.aurora.band.Band - Specifies interval corresponding to a frequency band - fft_obj: xarray.core.dataset.Dataset - To be replaced with an fft_obj() class in future - epsilon: float - Use this when you are worried about missing a frequency due to - round off error. This is in general not needed if we use a df/2 pad - around true harmonics. - - Returns - ------- - band: xr.DataArray - The frequencies within the band passed into this function - """ - cond1 = fft_obj.frequency >= frequency_band.lower_bound - epsilon - cond2 = fft_obj.frequency <= frequency_band.upper_bound + epsilon - try: - band = fft_obj.where(cond1 & cond2, drop=True) - except TypeError: # see Note #1 - tmp = fft_obj.to_array() - band = tmp.where(cond1 & cond2, drop=True) - band = band.to_dataset("variable") - if channels: - band = band[channels] - return band - - def check_time_axes_synched(X, Y): """ Utility function for checking that time axes agree.