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

replaced warning with error and helper message #205

Merged
merged 1 commit into from
Oct 17, 2024
Merged
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
15 changes: 14 additions & 1 deletion notebooks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ==========================================
Expand Down Expand Up @@ -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"]
Expand Down
Loading