Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ thiserror = "1.0"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.145"
rand = "0.8"
nalgebra = "0.32"

[dev-dependencies]
approx = "0.5"
Expand Down
26 changes: 21 additions & 5 deletions python/eo_processor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
binary_erosion as _binary_erosion,
binary_opening as _binary_opening,
binary_closing as _binary_closing,
detect_breakpoints as _detect_breakpoints,
bfast_monitor as _bfast_monitor,
complex_classification as _complex_classification,
random_forest_predict as _random_forest_predict,
random_forest_train as _random_forest_train,
Expand Down Expand Up @@ -131,7 +131,7 @@
"binary_erosion",
"binary_opening",
"binary_closing",
"detect_breakpoints",
"bfast_monitor",
"complex_classification",
"haralick_features",
"random_forest_predict",
Expand Down Expand Up @@ -164,11 +164,27 @@ def random_forest_predict(model_json, features):
return _random_forest_predict(model_json, features)


def detect_breakpoints(stack, dates, threshold):
def bfast_monitor(
stack,
dates,
history_start_date,
monitor_start_date,
order=1,
h=0.25,
alpha=0.05,
):
"""
Scaffold for a time-series breakpoint detection workflow (e.g., BFAST-like).
BFAST Monitor workflow for change detection.
"""
return _detect_breakpoints(stack, dates, threshold)
return _bfast_monitor(
stack,
dates,
history_start_date,
monitor_start_date,
order,
h,
alpha,
)


def complex_classification(blue, green, red, nir, swir1, swir2, temp):
Expand Down
11 changes: 11 additions & 0 deletions python/eo_processor/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,15 @@ def binary_closing(
input: NDArray[np.uint8], kernel_size: int = ...
) -> NDArray[np.uint8]: ...

# Workflows
def bfast_monitor(
stack: NumericArray,
dates: Sequence[int],
history_start_date: int,
monitor_start_date: int,
order: int = ...,
h: float = ...,
alpha: float = ...,
) -> NDArray[np.float64]: ...

# Raises ValueError if p < 1.0
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ pub enum CoreError {
InvalidArgument(String),
#[error("Computation error: {0}")]
ComputationError(String),
#[error("Not enough data: {0}")]
NotEnoughData(String),
}

impl From<CoreError> for PyErr {
fn from(err: CoreError) -> PyErr {
match err {
CoreError::InvalidArgument(msg) => PyValueError::new_err(msg),
CoreError::ComputationError(msg) => PyValueError::new_err(msg),
CoreError::NotEnoughData(msg) => PyValueError::new_err(msg),
}
}
}
Expand Down Expand Up @@ -95,7 +98,7 @@ fn _core(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(morphology::binary_closing, m)?)?;

// --- Workflows ---
m.add_function(wrap_pyfunction!(workflows::detect_breakpoints, m)?)?;
m.add_function(wrap_pyfunction!(workflows::bfast_monitor, m)?)?;
m.add_function(wrap_pyfunction!(workflows::complex_classification, m)?)?;

// --- Texture ---
Expand Down
2 changes: 1 addition & 1 deletion src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ pub fn haralick_features_py(
homogeneity_out.into_pyarray(py).to_owned(),
entropy_out.into_pyarray(py).to_owned(),
))
}
}
Loading