feat(projects): add weather diagnostics toolkit#71
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fffb0709de
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| dlat = np.gradient(np.deg2rad(lat)) | ||
| dlon = np.gradient(np.deg2rad(lon)) | ||
| dy = EARTH_RADIUS_M * dlat | ||
| dx = EARTH_RADIUS_M * np.cos(np.deg2rad(lat))[:, None] * dlon[None, :] |
There was a problem hiding this comment.
Handle polar latitudes before dividing by dx
When latitude includes ±90° (common in ERA5-style grids), np.cos(np.deg2rad(lat)) becomes zero, so dx is zero and gradient_on_latlon divides by zero, producing inf/nan derivatives at the pole rows. This propagates directly into relative_vorticity and horizontal_advection, corrupting diagnostics for full-domain datasets that include poles. Please mask pole rows, exclude poles, or enforce a minimum nonzero zonal spacing before the division.
Useful? React with 👍 / 👎.
|
Addressed the polar-latitude diagnostic comment in follow-up commit 78942f9. Exact pole rows now mask undefined zonal gradients as NaN, with a regression test covering +/-90 degree latitude rows and updated calculation-method notes. |
Summary
projects/python-weather-diagnostics-toolkit, a public-safe Python mini-lab for ERA5-style weather-field diagnostics.sbom-diff-and-riskas the flagship release surface.Validation
python -m pip install -e .[dev]python -m pytest-> 9 passedpython -m compileall src scriptspython -m ruff check .run_thermodynamic_check.py,run_dynamics_summary.py, andrun_synthetic_ensemble.pyoutputs/Privacy and Data Boundary