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

clearer error messages for slotgem #82

Closed
veenstrajelmer opened this issue Jun 20, 2024 · 0 comments · Fixed by #89
Closed

clearer error messages for slotgem #82

veenstrajelmer opened this issue Jun 20, 2024 · 0 comments · Fixed by #89

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Jun 20, 2024

The code below raises "ValueError: zero-size array to reduction operation maximum which has no identity", derive the problem and raise a clear error message.

import os
import pandas as pd
import hatyan
import kenmerkendewaarden as kw

# set logging level to INFO to get log messages
import logging
logging.getLogger("kenmerkendewaarden").setLevel(level="INFO")

tstop_dt = pd.Timestamp(2021,1,1, tz="UTC+01:00")

dir_base = r'p:\11210325-005-kenmerkende-waarden\work'
dir_meas = os.path.join(dir_base,'measurements_wl_18700101_20240101')
# TODO: move to full data folder (otherwise overschrijding and slotgemiddelde is completely wrong)
# dir_meas = os.path.join(dir_base,'measurements_wl_20101201_20220201') # when using this, we get `TypeError: 'NoneType' object is not subscriptable`

current_station = 'HANSWT'

print("loading meas")
data_pd_meas_all = kw.read_measurements(dir_output=dir_meas, station=current_station, extremes=False)
data_pd_HWLW_all = kw.read_measurements(dir_output=dir_meas, station=current_station, extremes=True)
data_pd_HWLW_all_12 = hatyan.calc_HWLW12345to12(data_pd_HWLW_all) #convert 12345 to 12 by taking minimum of 345 as 2 (laagste laagwater)

print("slotgem")
# this works
slotgemiddelden_all = kw.calc_slotgemiddelden(df_meas=data_pd_meas_all.loc[:tstop_dt], 
                                              df_ext=data_pd_HWLW_all_12.loc[:tstop_dt], 
                                              min_coverage=0, clip_physical_break=True)
# this fails with `ValueError: zero-size array to reduction operation maximum which has no identity`
slotgemiddelden_valid = kw.calc_slotgemiddelden(df_meas=data_pd_meas_all.loc[:tstop_dt], 
                                                df_ext=data_pd_HWLW_all_12.loc[:tstop_dt], 
                                                min_coverage=1, clip_physical_break=True)

The error occurred since too much yearly averages were incorrectly seen as invalid with a min_coverage of 100%, this will be picked up in a follow-up issue: #88

@veenstrajelmer veenstrajelmer mentioned this issue Jun 20, 2024
48 tasks
@veenstrajelmer veenstrajelmer linked a pull request Jun 20, 2024 that will close this issue
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