Skip to content

Resample time series for coherence calculation when sampling rates di…

Created by: asouthgate

Addresses: #1493

A new arg is added to _scipy.py::coherence. When sampling frequencies differ, the series with the higher timeseries.sample_rate is downsampled using timeseries.resample. By default, a warning is emitted. If downsample=False is specified, an exception is raised on differing rates. If downsample=True, downsampling is performed but no warning is emitted.

Fortunately @duncanmmacleod, in the examples, sampling frequencies are the same for compared timeseries, so the examples do not have this issue.

Edit: to add: I chose to address resampling in the coherence function itself, instead of in timeseries.coherence method since it is part of public interface which can be used by itself. It may be that elsewhere also needs the same treatment. We talked about cross correlation.

Merge request reports