Deltares / hatyan

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

component splitting fails if `CS_comps_derive` components are in `const_list` #289

Closed veenstrajelmer closed 4 months ago

veenstrajelmer commented 4 months ago

cs_comps from example script fails in simple application. When we use const_list="month" it does work. However, we probably need to cover this case also, at least with a decent error message:

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)
cs_comps_valid = pd.DataFrame({'CS_comps_derive':['P1','NU2','LABDA2','K2','T2'],
                         'CS_comps_from':['K1','N2','2MN2','S2','S2'],
                         'CS_ampfacs':[0.36,0.38,0.44,0.30,0.07],
                         'CS_degincrs':[5,-22,180,3,-22]})
comp = hatyan.analysis(ts=ts_pd, const_list="year", cs_comps=cs_comps_valid)
# raises ValueError: "The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."

This probably happens because (part of) the components in CS_comps_derive are already in const_list=year.