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

index out of bounds error if cpi on data containing partial days #1

Open
Kristof-K opened this issue Aug 27, 2021 · 5 comments
Open

Comments

@Kristof-K
Copy link

If I use cpi on data that doesn't comprise an integer length of days (e.g. 7.5 days) _calc_energy_per_day throws an index-out-of-bounds error. I could correct that by changing line 151 in cpi.py to

daily = np.zeros(int(np.ceil(power.shape[0] / self.vpd)))

and wanted to pose a pull request, but could not push my local branch.

With my current understanding processing data, that contains partial days is no problem for cpi, but of course that should also be thought through (maybe that leads to other problems).

@moritz-weber
Copy link
Collaborator

Thank you for your feedback. This is currently not handled as we just used data that starts and ends with whole days.
I guess starting with half a day would lead to even more problems. So this is more serious than just an index out of bounds error.
As for contributing to this repository, you should be able to fork the project and create pull requests from your forked version.

@Kristof-K
Copy link
Author

Kristof-K commented Aug 27, 2021

Yeah right, now I see that half days are actually not useful for cpi at all. A quickfix would be filling start and end with nans to integer length, applying cpi and discarding the imputed start and end provided there are missing values in the start and end partial days that should be imputed

@Kristof-K Kristof-K changed the title index out of bounds erro if cpi on data containing partial days index out of bounds error if cpi on data containing partial days Aug 27, 2021
@Kristof-K
Copy link
Author

Kristof-K commented Sep 2, 2021

It would be helpful to output a warning in the console and stop the algorithm if one tries to apply CPI on data containing partial days:

e.g. in cpi.py fit method line 45 after vpd is determined:

if ets.shape[0] % self.vpd != 0:
logger = logging.getLogger("Log")
logger.addHandler(logging.StreamHandler())
logger.info("Warning, ...")

plus "import logging" at the beginning

(And I could not push to your repo due to git discrepancy on my side)

@Kristof-K
Copy link
Author

Kristof-K commented Sep 3, 2021

Implementing logger outputs, another reasonable measure is to output whether the given energy time series is non-decreasing and not flawed: e.g. you also could add in the fit method in cpi.py after line 46 (energy was assigned)

for i in range(1, energy.size):
if energy[i] < energy[i-1]:
log warning

@moritz-weber
Copy link
Collaborator

Thank you for your suggestions. I looked into the mentioned problems and started implementing your suggested solutions.
However, they only lead to more edge cases that break other parts of the code.
In it's current form, the implementation makes some strong assumptions about the data input that are hard to work around.

I think, a rewrite with those edge cases in mind would result in a more useful package for more users. I can't give an estimate on the time frame on that tough.

For now, I'll add a paragraph to the readme.

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

No branches or pull requests

2 participants