Spatial bfast output / relation to bfastSpatial
For ease of applicability, having bfast generate spatial maps rather than only pixel time series would be good to have. bfastSpatial has some of that functionality, specifically with bfmSpatial, but it only deals with bfastMonitor output. Also, bfastSpatial is useful as a generic preprocessing framework, the output does not necessarily have to be used with bfast.
So an idea would be to add something like bfSpatial for the core bfast function. Perhaps with coordination with Loïc.
It is actually already included in the documentation in ?bfastmonitor, so we could jsut make it an extra utility function.
See this for an implementation, also using stars: https://gist.github.com/GreatEmerald/d9269d2b8c270bf8e8a1ebe9462e54d5
there's 2 options: either we make a spatial* function for each bfast function, or we make a single spatial() function that accepts any bfast function as an output.
With the first option it's harder to maintain consistency, while with the latter it is harder to create consistency because of the different outputs of different bfast functions. E.g. bfast01 doesn't output a magnitude.
Both are reasonably doable, but I'm not sure which is the way to go.
Which would be your preferred way to go?
I'd go with the first option. In fact, we don't even need to define new functions, just new methods. If the input to bfastmonitor() is a Rast* or stars, run it on every pixel. For functions that give multiple outputs, it's more tricky.
even bfastmonitor doesn't only output magnitude and break, but also metadata with parameters used to get that specific result. Scientifically smart for reproducibility purposes, but everyone seems to drop it like it's hot.
Regardless of the decisions necessary for each bfast function, I agree that the best approach is to create spatial methods for each bfast function.
I guess the next question is what shall we support and what shall we use internally? For support, I guess it's not an issue to support raster, stars and terra as these formats are inter-convertible. Anything else? But what shall we use internally to actually calculate everything. Raster is on its way out, so stars and terra are the main candidates. I used stars and it's ok, but I don't know how it compares with terra. I propose we benchmark the 2 and hopefully one will be way faster than the other? What do you think?