diku-dk / bfast

GPU Implementation for BFAST
GNU General Public License v3.0
37 stars 17 forks source link

IndexError when datetime is used with hour != 0 #50

Open oceanites opened 1 year ago

oceanites commented 1 year ago

Whenever one of the dates fed to model.fit() has the hour or minute set to something else then 0, the error IndexError: boolean index did not match indexed array along dimension 1; dimension is 151 but corresponding boolean dimension is 152 is thrown.

This works also for the example code, when one value is modified like:

i = 34
di = dates_example[i]
dates_example[i] = datetime(di.year, di.month, di.day, 0, 34)

The error occurs in map_indices https://github.com/diku-dk/bfast/blob/4fd0c1727ec6ac309966d0ecfeef67e3ef02776b/bfast/monitor/utils.py#L477 where an empty array with shape (0, ) is returned, because ~np.isnan(ts).to_numpy() is False for every element.

A fix workaround for me is to use date instead of datetime objects. I can also try to come up with a better fix, but that would need some time.