Skip to content

Series.spectral(): unevenly-spaced error lacks actionable guidance #698

Description

@CommonClimate

Part of #697.

Where

pyleoclim/utils/spectral.py, the evenly-spaced checks inside welch() (line ~199), mtm() (line ~312), and periodogram() (line ~701):

raise ValueError('For the Welch method, data should be evenly spaced')

Problem

Compare with Series.wavelet() (cwt), which raises with actionable guidance:

raise ValueError("The chosen method is cwt but the series is unevenly spaced. You can either interpolate/bin or set method='wwz'.")

The spectral.py errors are terse, raised deep inside the utils layer rather than at the Series.spectral() call site, and don't tell the user what to do next (interpolate? bin? pick a different method?).

Proposed fix

Move the evenly-spaced check up to Series.spectral() itself (consistent with how wavelet() does it) and raise with the same style of actionable message, naming the available fixes (.interp(), .bin(), or switching to method='wwz'/'lomb_scargle', whichever are actually unevenly-spaced-safe for that call).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions