Skip to content

Commit

Permalink
Merge pull request #274 from kujaku11/fix_mt_metadata_issue_239
Browse files Browse the repository at this point in the history
update fourier coefficient method for checking fc parameters
  • Loading branch information
kujaku11 authored Jan 3, 2025
2 parents 8f2addf + c33bcc0 commit 992e7b2
Show file tree
Hide file tree
Showing 6 changed files with 446 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
conda install pytest=7.1.2
conda install pytest-cov
conda install pytest-subtests
pip install git+https://github.com/kujaku11/mt_metadata.git@main
pip install git+https://github.com/kujaku11/mt_metadata.git@features
- name: Install Our Package
shell: bash
Expand Down
11 changes: 7 additions & 4 deletions mth5/groups/fourier_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ def supports_aurora_processing_config(self, processing_config, remote) -> bool:
"""
pre_existing_fc_decimation_ids_to_check = self.groups_list
levels_present = np.full(processing_config.num_decimation_levels, False)
for i, dec_level in enumerate(processing_config.decimations):

for i, aurora_decimation_level in enumerate(processing_config.decimations):

# Quit checking if dec_level wasn't there
if (i > 0):
Expand All @@ -263,8 +264,10 @@ def supports_aurora_processing_config(self, processing_config, remote) -> bool:
for fc_decimation_id in pre_existing_fc_decimation_ids_to_check:
fc_dec_group = self.get_decimation_level(fc_decimation_id)
fc_decimation = fc_dec_group.metadata
levels_present[i] = fc_decimation.has_fcs_for_aurora_processing(dec_level, remote)

levels_present[i] = aurora_decimation_level.is_consistent_with_archived_fc_parameters(
fc_decimation=fc_decimation,
remote=remote
)
if levels_present[i]:
pre_existing_fc_decimation_ids_to_check.remove(fc_decimation_id) # no need to check this one again
break # break inner for-loop over decimations
Expand Down Expand Up @@ -292,7 +295,7 @@ class FCDecimationGroup(BaseGroup):
- method (FFT, wavelet, ...)
- anti alias filter
- prewhitening type
- extra_pre_fft_detrend_type
- per_window_detrend_type
- recoloring (True | False)
- harmonics_kept (index values of harmonics kept (list) | 'all')
- window parameters
Expand Down
15 changes: 10 additions & 5 deletions mth5/timeseries/scipy_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import warnings
from fractions import Fraction
from loguru import logger
from typing import Optional, Union
import xarray as xr
import scipy.signal
import numpy as np
Expand Down Expand Up @@ -407,7 +408,12 @@ def bandstop(darray, f_low, f_high, *args, **kwargs):
# bx = signal.filtfilt(b, a, bx)


def decimate(darray, target_sample_rate, n_order=8, dim=None):
def decimate(
darray: Union[xr.Dataset, xr.DataArray],
target_sample_rate: float,
n_order: int = 8,
dim: Optional[str] = None
):
"""
Decimate data following the method of scipy.signal.decimate.
Expand All @@ -421,13 +427,12 @@ def decimate(darray, target_sample_rate, n_order=8, dim=None):
:type darray: :class:`xr.DataArray` or :class:`xr.Dataset`
:param target_sample_rate: new sample rate in samples per second or samples
per space
:type target_sample_rate: integer
:type target_sample_rate: float
:param n_order: Order of the Cheby1 filter, defaults to 8
:type n_order: integer, optional
:param dim: dimension to decimate along, defaults to None
:type dim: string, optional
:param **kwargs: DESCRIPTION
:type **kwargs: TYPE
:return: DESCRIPTION
:rtype: TYPE
Expand Down Expand Up @@ -496,7 +501,7 @@ def resample_poly(darray, new_sample_rate, dim=None, pad_type="mean"):
if new_step % 1 == 0:
q = int(np.rint(new_step))
# directly downsample without AAF on dimension
# this only works if q is an integer, otherwise to
# this only works if q is an integer, otherwise to
# the index gets messed up from fractional spacing
new_dim = darray[dim].values[slice(None, None, q)]

Expand Down
Loading

0 comments on commit 992e7b2

Please sign in to comment.