Jacob-Stevens-Haas / gen-experiments

Pysindy experiments. Composable and extensible
MIT License
1 stars 2 forks source link

Issues with the max_amplitude function #29

Closed yb6599 closed 1 month ago

yb6599 commented 1 month ago

Hey @Jacob-Stevens-Haas , this is about the max amplitude function we changed. it is written as

def _max_amplitude(signal: np.ndarray, axis: int) -> float:
    return np.abs(scipy.fft.rfft(signal, axis=axis)[1:]).max() / np.sqrt(
        signal.shape[axis]
    )

I don't understand the significance of [1:], but the error I am getting originates there, which is

ValueError: zero-size array to reduction operation maximum which has no identity

where scipy.fft.rfft(signal, axis=axis) is an array of shape (1, 51, 256), so scipy.fft.rfft(signal, axis=axis)[1:] returns an empty array I am assuming that since we have ODEs shaped as (t, x) and PDEs shaped as (x, t, d), for PDE purposes, should it be [:, 1:, :], or something else?

Jacob-Stevens-Haas commented 1 month ago

To clarify, have ODEs shaped as [n_time, n_coord] and PDEs shaped as [*n_spatial, n_time, n_coord]. I believe the signal you have should be shaped as (51, 256, 1) or (256, 51, 1)

The :1 is to drop the constant term, since the 0th element of the Fourier transform is the constant term.

yb6599 commented 1 month ago

Alright, got it.