Skip to content

1442 hydrology model improve rainfall generation#1444

Merged
vgro merged 27 commits intodevelopfrom
1442-hydrology-model-improve-rainfall-generation
Mar 18, 2026
Merged

1442 hydrology model improve rainfall generation#1444
vgro merged 27 commits intodevelopfrom
1442-hydrology-model-improve-rainfall-generation

Conversation

@vgro
Copy link
Copy Markdown
Collaborator

@vgro vgro commented Mar 16, 2026

This PR replaces the random rainfall generator with a more realistic function. It also makes the hydrology_model tests a bit more generalised.

I haven't updated the docs as I wasn't sure if we have the new version released ye, so opened #1443.

Fixes #1442

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

@vgro vgro linked an issue Mar 16, 2026 that may be closed by this pull request
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.97%. Comparing base (b914a93) to head (04d4af2).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1444      +/-   ##
===========================================
+ Coverage    94.94%   94.97%   +0.02%     
===========================================
  Files           71       71              
  Lines         7460     7498      +38     
===========================================
+ Hits          7083     7121      +38     
  Misses         377      377              

☔ 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.

@vgro vgro marked this pull request as draft March 16, 2026 14:41
@vgro vgro marked this pull request as ready for review March 16, 2026 14:42
@vgro vgro requested review from jacobcook1995 and lelavathy March 16, 2026 14:42
@vgro
Copy link
Copy Markdown
Collaborator Author

vgro commented Mar 16, 2026

@jacobcook1995 is this error related to what you spoke about earlier ? If not have you come across this?

/home/runner/work/virtual_ecosystem/virtual_ecosystem/virtual_ecosystem/models/hydrology/model_config.py:docstring of virtual_ecosystem.models.hydrology.model_config.HydrologyConfiguration:1: WARNING: py:class reference target not found: 0.3 [ref.class]

Copy link
Copy Markdown
Collaborator

@jacobcook1995 jacobcook1995 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
Copy link
Copy Markdown
Collaborator

@jacobcook1995 is this error related to what you spoke about earlier ? If not have you come across this?

/home/runner/work/virtual_ecosystem/virtual_ecosystem/virtual_ecosystem/models/hydrology/model_config.py:docstring of virtual_ecosystem.models.hydrology.model_config.HydrologyConfiguration:1: WARNING: py:class reference target not found: 0.3 [ref.class]

I don't think so, no. I think this is one of the classic "haven't used the correct indent somewhere in your docstrings" cases

@davidorme
Copy link
Copy Markdown
Collaborator

@jacobcook1995 is this error related to what you spoke about earlier ? If not have you come across this?

/home/runner/work/virtual_ecosystem/virtual_ecosystem/virtual_ecosystem/models/hydrology/model_config.py:docstring of virtual_ecosystem.models.hydrology.model_config.HydrologyConfiguration:1: WARNING: py:class reference target not found: 0.3 [ref.class]

Oh gods. For some reason, something about creating links for the pydantic field values causes issues with sphinx. I'm not sure why these fields. I think there might be a way to extend the nitpicking using a regexp?

@vgro
Copy link
Copy Markdown
Collaborator Author

vgro commented Mar 16, 2026

@jacobcook1995 is this error related to what you spoke about earlier ? If not have you come across this?
/home/runner/work/virtual_ecosystem/virtual_ecosystem/virtual_ecosystem/models/hydrology/model_config.py:docstring of virtual_ecosystem.models.hydrology.model_config.HydrologyConfiguration:1: WARNING: py:class reference target not found: 0.3 [ref.class]

Oh gods. For some reason, something about creating links for the pydantic field values causes issues with sphinx. I'm not sure why these fields. I think there might be a way to extend the nitpicking using a regexp?

@jacobcook1995 is this error related to what you spoke about earlier ? If not have you come across this?
/home/runner/work/virtual_ecosystem/virtual_ecosystem/virtual_ecosystem/models/hydrology/model_config.py:docstring of virtual_ecosystem.models.hydrology.model_config.HydrologyConfiguration:1: WARNING: py:class reference target not found: 0.3 [ref.class]

Oh gods. For some reason, something about creating links for the pydantic field values causes issues with sphinx. I'm not sure why these fields. I think there might be a way to extend the nitpicking using a regexp?

haha, what? Could you point me to where I can find out about this?

@davidorme
Copy link
Copy Markdown
Collaborator

https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-nitpick_ignore_regex

I think we could use:

nitpick_ignore_regex = [
    (r"py:class", r'virtual_ecosystem.models..*.model_config..*') 
]

That would (possibly) mute all similar warnings on all models. There are a couple of packages that are specifically intended to help document pydantic objects better:

Comment on lines 178 to 185
p_wet_wet: float = 0.6
"""Probability a wet day follows a wet day."""
p_wet_dry: float = Field(ge=0.1, le=0.5, default=0.3)
p_wet_dry: float = 0.3
"""Probability a wet day follows a dry day."""
rainfall_shape_parameter: float = Field(ge=0.7, le=4.0, default=1.5)
rainfall_shape_parameter: float = 1.5
"""Shape parameter of the Gamma distribution controlling rainfall variability."""
rainfall_scale_parameter: float = Field(ge=0.1, le=2.0, default=1.0)
rainfall_scale_parameter: float = 1.0
"""Scale parameter of the Gamma distribution controlling magnitude of rainfall."""
Copy link
Copy Markdown
Collaborator

@davidorme davidorme Mar 16, 2026

Choose a reason for hiding this comment

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

Oh god, we shouldn't need to cripple the checking and validation just because sphinx is being shit. I mean, the example three lines above works fine. I really don't understand what the hell sphinx is doing here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree, I only removed it to see what happens before diving into nitpicking... like you say, the previous lines work so this makes no sense. @dalonsoa any immediate thoughts?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

After not being successful here, I created an issue #1450 and will merge this so I can move on with the science side of things.

@vgro vgro merged commit dec416d into develop Mar 18, 2026
13 checks passed
@vgro vgro deleted the 1442-hydrology-model-improve-rainfall-generation branch March 18, 2026 09:53
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.

Hydrology model: improve rainfall generation

5 participants