Deltares / hatyan

Harmonic tidal analysis and prediction
https://deltares.github.io/hatyan/
GNU General Public License v3.0
13 stars 2 forks source link

analysis not possible for 1018 timeseries #287

Closed veenstrajelmer closed 4 months ago

veenstrajelmer commented 4 months ago

Might be a chance to align code, but might also not be important enough.

This code raises TypeError: "unsupported operand type(s) for -: 'numpy.ndarray' and 'Timestamp'". When replacing 1018 with 2009, the code does work as expected.

import os
import pandas as pd
import hatyan

dir_testdata = r"c:\DATA\hatyan\tests\data_unitsystemtests"

file_dia = os.path.join(dir_testdata,'VLISSGN_obs1.txt')
ts_pd = hatyan.read_dia(file_dia)

# convert to year 1018
ts_pd.index = pd.date_range('1018-01-01 00:00:00+01:00', '1018-12-31 23:00:00+01:00', freq="60min", unit="us")

#prediction
comp = hatyan.analysis(ts=ts_pd, const_list="year")

It happens not immediately and might be avoidable, since this does work (although maybe not on py3.8:

pd.date_range("1018-07-02 12:00:00", "1018-07-02 12:00:00", 1, unit="us")
Out  [20]: DatetimeIndex(['1018-07-02 12:00:00'], dtype='datetime64[us]', freq=None)

(output is DatetimeIndex, not Index anymore)