Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make conversion from tzone to minutes in hatyan.write_components() flexible #357

Closed
veenstrajelmer opened this issue Sep 20, 2024 · 0 comments · Fixed by #359
Closed

Make conversion from tzone to minutes in hatyan.write_components() flexible #357

veenstrajelmer opened this issue Sep 20, 2024 · 0 comments · Fixed by #359

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Sep 20, 2024

The code below raises "AttributeError: 'datetime.timezone' object has no attribute '_minutes'":

import hatyan
import ddlpy
import pytz
import matplotlib.pyplot as plt
plt.close('all')
 
start_dt  = "2022-01-01 00:00:00 +01:00"
end_dt  = "2022-03-31 23:50:00 +01:00"

locations = ddlpy.locations()		#retrieve metainfo about available locations/parameters		

bool_grootheid = locations['Grootheid.Code'].isin(['WATHTE']) # measured waterlevels (not astro)
bool_groepering = locations['Groepering.Code'].isin(['NVT']) # timeseries (not extremes)
bool_hoedanigheid = locations['Hoedanigheid.Code'].isin(['NAP']) # vertical reference, only NAP
locs_ddl = locations.loc[bool_grootheid & bool_groepering & bool_hoedanigheid]

donar_loccode = "VLISSGN"
print("   --> processing station:", donar_loccode)
locs_ddl_one = locs_ddl.loc[donar_loccode]
ddl_df = ddlpy.measurements(locs_ddl_one, start_date=start_dt, end_date=end_dt)
df_meas = hatyan.ddlpy_to_hatyan(ddl_df)
# df_meas = df_meas.tz_convert(pytz.FixedOffset(60))
ts_comp_nfac1_fualltimes0_xfac1_peryear0 = hatyan.analysis(ts=df_meas, const_list='month', nodalfactors=True, fu_alltimes=False, xfac=True, analysis_perperiod=False)
ts_comp_nfac1_fualltimes0_xfac1_peryear0.attrs['grootheid'] = "WATHTE"
ts_comp_nfac1_fualltimes0_xfac1_peryear0.attrs['eenheid'] = "cm"
ts_comp_nfac1_fualltimes0_xfac1_peryear0.attrs['vertref'] = "NAP"
ts_comp_nfac1_fualltimes0_xfac1_peryear0.attrs['station'] = donar_loccode
hatyan.write_components(ts_comp_nfac1_fualltimes0_xfac1_peryear0, filename='components_%.ana'%(donar_loccode))

It can be resolve by converting to a fixed offset timezone, but this is not per se desired. Make this more flexible and add a testcase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant