Skip to content

536 add check for nan values before running the soil model#1004

Merged
jacobcook1995 merged 3 commits intodevelopfrom
536-add-check-for-nan-values-before-running-the-soil-model
Aug 20, 2025
Merged

536 add check for nan values before running the soil model#1004
jacobcook1995 merged 3 commits intodevelopfrom
536-add-check-for-nan-values-before-running-the-soil-model

Conversation

@jacobcook1995
Copy link
Copy Markdown
Collaborator

Description

This PR adds a step to check for unexpected NaN values (which can stall the soil model integration) before the soil model integration starts. If NaNs are detected the an error is raised, informing the user which variables contain unexpected NaN values.

For variables that don't have a layer structure, unexpected NaN values are any NaN values. For variables that pertain to the soil layers, they are NaN values in any soil layer For the soil_temperature (the only above ground variable the soil model cares about), unexpected NaN values are any NaN values in the surface layer.

Fixes #536

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works
  • Relevant documentation reviewed and updated

@jacobcook1995 jacobcook1995 linked an issue Aug 20, 2025 that may be closed by this pull request
@jacobcook1995 jacobcook1995 requested a review from vgro August 20, 2025 08:03
@jacobcook1995
Copy link
Copy Markdown
Collaborator Author

If you run ve_run with abiotic rather than abiotic_simple, the soil model raises the following error several steps in

ValueError: Soil model integration cannot proceed because the following variables have unexpected NaN values: {'air_temperature', 'litter_C_mineralisation_rate', 'root_carbohydrate_exudation', 'soil_temperature', 'plant_symbiote_carbon_supply', 'litter_N_mineralisation_rate', 'litter_P_mineralisation_rate'}

This is a meaningful improvement as previously the soil model integration would just stall, and this error message gives information as to what the bad input is

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.91%. Comparing base (bd49341) to head (981e29b).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1004      +/-   ##
===========================================
+ Coverage    94.90%   94.91%   +0.01%     
===========================================
  Files           80       80              
  Lines         6616     6632      +16     
===========================================
+ Hits          6279     6295      +16     
  Misses         337      337              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@vgro vgro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jacobcook1995 jacobcook1995 merged commit 8e4416d into develop Aug 20, 2025
13 checks passed
@jacobcook1995 jacobcook1995 deleted the 536-add-check-for-nan-values-before-running-the-soil-model branch August 20, 2025 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add check for nan values before running the soil model

3 participants