ttide_py
ttide_py copied to clipboard
lsq=best fails for long timeseries
Hi:
I realized that when lsq=best
falls back to lsq=normal
which fails when we pass a long timeseries with missing values. Here is the reproducer:
import ttide
import matplotlib.pyplot as plt
import numpy as np
def main():
N = 1_000_200
# time is in minutes
dt = 1.
T = 12 * 60.
t = np.arange(0, N * dt, dt)
h = np.sin(2 * np.pi / T * t)
h[10:20] = np.nan
con = ttide.t_tide(h, dt = 1. / 60.)
# print(con)
nshow = 100
plt.figure()
plt.plot(t[:nshow] / 60., h[:nshow])
plt.plot(t[:nshow] / 60., con["xout"][:nshow])
plt.show()
if __name__ == "__main__":
main()
I get the following exception
/home/huziy/Python/anaconda3/envs/py3.10/bin/python /home/huziy/Python/Projects/test-ttide/src/test.py
Traceback (most recent call last):
File "/home/huziy/Python/Projects/test-ttide/src/test.py", line 35, in <module>
main()
File "/home/huziy/Python/Projects/test-ttide/src/test.py", line 22, in main
con = ttide.t_tide(h, dt = 1. / 60.)
File "/home/huziy/Python/anaconda3/envs/py3.10/lib/python3.10/site-packages/ttide/t_tide.py", line 493, in t_tide
xr = tu.fixgaps(xres)
File "/home/huziy/Python/anaconda3/envs/py3.10/lib/python3.10/site-packages/ttide/t_utils.py", line 168, in fixgaps
bd[:gd.min()]=False
File "/home/huziy/Python/anaconda3/envs/py3.10/lib/python3.10/site-packages/numpy/core/_methods.py", line 44, in _amin
return umr_minimum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation minimum which has no identity
ttide version
In [2]: ttide.__version__
Out[2]: '0.3lfk'