From b03a0d69153c75f5b4c439f70f915fafbfd36e42 Mon Sep 17 00:00:00 2001 From: Christina Butsko Date: Thu, 17 Oct 2024 10:03:43 +0200 Subject: [PATCH] replaced warning with error and helper message --- notebooks/utils.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/notebooks/utils.py b/notebooks/utils.py index 146a11fa..6bc2cd3e 100644 --- a/notebooks/utils.py +++ b/notebooks/utils.py @@ -176,6 +176,15 @@ def select_landcover(df: pd.DataFrame): def pick_croptypes(df: pd.DataFrame, samples_threshold: int = 100): import ipywidgets as widgets + from IPython.display import Markdown + + nodata_helper_message = """ + ### What to do? + 1. **Increase the buffer size**: Try increasing the buffer size by passing the `buffer` parameter to the `query_public_extractions` function (to a reasonable extent). + 2. **Consult the WorldCereal Reference Data Module portal**: Assess data density in the selected region by visiting the [WorldCereal Reference Data Module portal](https://ewoc-rdm-ui.iiasa.ac.at/map). + 3. **Pick another area**: Consult RDM portal (see above) to find areas with more data density. + 4. **Contribute data**: Collect some data and contribute to our global database! 🌍🌾 [Learn how to contribute here.](https://worldcereal.github.io/worldcereal-documentation/rdm/upload.html) + """ # CREATING A HIERARCHICAL LAYOUT OF OPTIONS # ========================================== @@ -240,9 +249,13 @@ def pick_croptypes(df: pd.DataFrame, samples_threshold: int = 100): ) if len(class_counts) == 1: - logger.warning( + logger.error( f"Only one class remained after aggregation with threshold {samples_threshold}. Consider lowering the threshold." ) + Markdown(nodata_helper_message) + raise ValueError( + "Only one class remained after aggregation. Please lower the threshold." + ) # Convert to a hierarchically arranged dictionary class_counts = class_counts[class_counts["label_level3"] != "other_temporary_crops"]