Skip to content

Commit

Permalink
Update per changes in mt_metadata
Browse files Browse the repository at this point in the history
- rename extra_pre_fft_detrend_type to per_window_detrend_type
- add explicit assignment of per_window_detrend_type="linear" in config creator
  • Loading branch information
kkappler committed Dec 29, 2024
1 parent 503758b commit 6e69bca
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
16 changes: 7 additions & 9 deletions aurora/config/config_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ def determine_band_specification_style(self) -> None:
logger.info(msg)
self._emtf_band_file = BANDS_DEFAULT_FILE
self._band_specification_style = "EMTF"
elif (self._emtf_band_file is not None) & (
self._band_edges is not None
):
elif (self._emtf_band_file is not None) & (self._band_edges is not None):
msg = "Bands defined twice, and possibly inconsistently"
logger.error(msg)
raise ValueError(msg)
Expand Down Expand Up @@ -152,6 +150,8 @@ def create_from_kernel_dataset(
Theoretically, you could also use the number of decimations implied by bands_dict but this is sloppy, because it would assume the decimation factor.
3. 2024-12-29 Added setting of decimation_obj.stft.per_window_detrend_type = "linear"
This makes tests pass following a refactoring of mt_metadata. Could use more testing.
Parameters
----------
Expand All @@ -178,9 +178,7 @@ def create_from_kernel_dataset(
Object storing the processing parameters.
"""

processing_obj = Processing(
id=kernel_dataset.processing_id
) # , **kwargs)
processing_obj = Processing(id=kernel_dataset.processing_id) # , **kwargs)

# pack station and run info into processing object
processing_obj.stations.from_dataset_dataframe(kernel_dataset.df)
Expand Down Expand Up @@ -209,9 +207,7 @@ def create_from_kernel_dataset(
decimation_factors[0] = 1
if num_samples_window is None:
default_window = Window()
num_samples_window = num_decimations * [
default_window.num_samples
]
num_samples_window = num_decimations * [default_window.num_samples]
elif isinstance(num_samples_window, int):
num_samples_window = num_decimations * [num_samples_window]
# now you can define the frequency bands
Expand Down Expand Up @@ -248,4 +244,6 @@ def create_from_kernel_dataset(
decimation_obj.estimator.engine = estimator["engine"]
except KeyError:
pass
decimation_obj.stft.per_window_detrend_type = "linear"

return processing_obj
2 changes: 1 addition & 1 deletion aurora/pipelines/fourier_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"decimation.level": 2,
"decimation.method": "default",
"decimation.sample_rate": 0.0625,
"extra_pre_fft_detrend_type": "linear",
"per_window_detrend_type": "linear",
"prewhitening_type": "first difference",
"window.clock_zero_type": "ignore",
"window.num_samples": 128,
Expand Down
2 changes: 1 addition & 1 deletion aurora/pipelines/time_series_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def run_ts_to_stft(
data=tapered_obj,
sample_rate=windowing_scheme.sample_rate,
spectral_density_correction=windowing_scheme.linear_spectral_density_calibration_factor,
detrend_type=decimation_obj.extra_pre_fft_detrend_type,
detrend_type=decimation_obj.stft.per_window_detrend_type,
)

if decimation_obj.stft.recoloring:
Expand Down
6 changes: 2 additions & 4 deletions tests/synthetic/test_stft_methods_agree.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ def test_stft_methods_agree():
run_ts = run_obj.to_runts(start=None, end=None)
local_run_xrts = run_ts.dataset
else:
local_run_xrts = prototype_decimate(
dec_config.decimation, local_run_xrts
)
local_run_xrts = prototype_decimate(dec_config.decimation, local_run_xrts)

dec_config.extra_pre_fft_detrend_type = "constant"
dec_config.stft.per_window_detrend_type = "constant"
local_stft_obj = run_ts_to_stft(dec_config, local_run_xrts)
local_stft_obj2 = run_ts_to_stft_scipy(dec_config, local_run_xrts)
stft_difference = local_stft_obj - local_stft_obj2
Expand Down

0 comments on commit 6e69bca

Please sign in to comment.