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

add attrs in ddlpy_to_hatyan() #358

Closed
3 tasks done
veenstrajelmer opened this issue Oct 30, 2024 · 0 comments · Fixed by #360
Closed
3 tasks done

add attrs in ddlpy_to_hatyan() #358

veenstrajelmer opened this issue Oct 30, 2024 · 0 comments · Fixed by #360

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Oct 30, 2024

hatyan.ddlpy_to_hatyan() does not include metadata in the returned dataframe. The example below raises KeyError: 'grootheid', while it works if we manually set all the required attributes:

import hatyan
import ddlpy
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)

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))

Todo:

  • add attrs
  • update test_ddlpy_to_components, also include issue numbers in header
  • update changelog
@veenstrajelmer veenstrajelmer changed the title improve ddlpy_to_hatyan improve ddlpy_to_hatyan() Oct 30, 2024
@veenstrajelmer veenstrajelmer changed the title improve ddlpy_to_hatyan() add attrs in ddlpy_to_hatyan() Oct 30, 2024
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