⚡ Enhance core functionality and documentation improvements - #38
Conversation
Separate blending function from plasma module and move it into math module
…m function to raise RuntimeError for missing rho_tor_norm
…ding functions for core and GGD emissivity
…sources and improve error handling
…iation_emitter function
… test coverage for radiation emitter
There was a problem hiding this comment.
Pull request overview
This PR expands CHERAB-IMAS radiation/emissivity loading and blending support by introducing reusable blending/grid utilities, improving radiation IDS parsing (core + GGD values, plus coefficient reconstruction), and adding a synthetic dataset + tests to exercise the new behavior.
Changes:
- Extend
load_radiation_emitter()to support dual IDS sources for emissivity values with duplicate-detection and improved validation/error messages. - Add new shared utilities:
math.blend.blend_core_edge_functions()andids.common.grid_radial(core grid +psi_normsupport). - Add a synthetic
iter_jintrac_radiation_valuesdataset plus tests and documentation touch-ups.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/emitter/test_radiation.py | Adds regression tests for values-based radiation loading (core/GGD completion, duplicates) and earlier validation. |
| tests/conftest.py | Adds session fixture for the new synthetic JINTRAC radiation-values dataset. |
| src/cherab/imas/plasma/equilibrium.py | Tightens load_equilibrium() contract when returning a psi interpolator (raise instead of returning None). |
| src/cherab/imas/plasma/core.py | Switches core grid + psi normalization utilities to the new ids.common.grid_radial module. |
| src/cherab/imas/plasma/blend.py | Uses new shared blend helper instead of local implementation. |
| src/cherab/imas/plasma/blend.py | Imports get_psi_norm/load_core_grid from ids.common.grid_radial to centralize grid logic. |
| src/cherab/imas/plasma/blend.py | Replaces private blending logic with blend_core_edge_functions(). |
| src/cherab/imas/math/blend.py | New public utility for blending scalar/vector core/edge functions with optional axisymmetric mapping. |
| src/cherab/imas/math/init.py | Re-exports blend_core_edge_functions from the new math submodule. |
| src/cherab/imas/ids/radiation/load_radiation.py | Refactors radiation emissivity loading into load_core_emissivity() / load_ggd_emissivity() and introduces EmissivityData. |
| src/cherab/imas/ids/radiation/init.py | Updates exports to the new emissivity loaders/dataclass. |
| src/cherab/imas/ids/core_profiles/load_profiles.py | Removes GridData/load_core_grid from core_profiles loader (moved to common grid module). |
| src/cherab/imas/ids/core_profiles/init.py | Updates public API exports after the grid refactor. |
| src/cherab/imas/ids/common/species.py | Adjusts element/isotope selection and atom count handling in get_elements(). |
| src/cherab/imas/ids/common/grid_radial.py | New shared GridData, load_core_grid(), and get_psi_norm() utilities. |
| src/cherab/imas/ids/common/ggd/load_unstruct_2d.py | Normalizes subset-id handling and casts IDS indices to int consistently. |
| src/cherab/imas/ids/common/ggd/load_data.py | New helper get_ggd_subset_data() for extracting values/coefficients on a subset. |
| src/cherab/imas/ids/common/ggd/init.py | Updates package purpose/exports to include non-grid GGD utilities. |
| src/cherab/imas/ids/common/_ids_numeric.py | New helper get_ids_numeric_field() to coerce IDS numeric fields to float64 arrays. |
| src/cherab/imas/ids/common/init.py | Re-exports new common utilities (grid_radial, get_ids_numeric_field). |
| src/cherab/imas/emitter/radiation.py | Major refactor: dual-source value loading (core + GGD), blending, and improved coefficient-path validation. |
| src/cherab/imas/datasets/_registry.py | Registers the new builtin dataset artifact. |
| src/cherab/imas/datasets/_builtin.py | Implements synthetic iter_jintrac_radiation_values() dataset generation. |
| src/cherab/imas/datasets/init.py | Exposes iter_jintrac_radiation_values() as a public dataset helper. |
| docs/source/index.md | Removes emoji from the toctree caption. |
| docs/source/contributing.md | Adds anchors, improves markdown links/URLs. |
| docs/source/api.md | Adds anchors and updates heading formatting. |
| docs/notebooks/radiation/radiation_3d.ipynb | Cleans up unused imports in the radiation 3D notebook. |
| CHANGELOG.md | Adds 0.5.1 entry documenting the new dataset + radiation emitter improvements. |
Comments suppressed due to low confidence (1)
src/cherab/imas/emitter/radiation.py:452
- The coefficients path unconditionally indexes
ids.grid_ggd[0]and ignores thegrid_ggd=override parameter. If the IDS has an emptygrid_ggdAOS, this will raiseIndexError; and callers cannot supply an alternative grid for coefficient reconstruction.
# Load GGD Grid
grid = load_grid(
ids.grid_ggd[0],
with_subsets=False,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #38 +/- ##
==========================================
+ Coverage 69.55% 71.39% +1.83%
==========================================
Files 52 56 +4
Lines 3291 3506 +215
Branches 526 558 +32
==========================================
+ Hits 2289 2503 +214
+ Misses 766 755 -11
- Partials 236 248 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…on_emitter function
…subset index in get_ggd_subset_data function
…adjust z_min/z_max logic
…d_core_edge_functions
…oad_unstruct_grid_2d function
Key changes include:
Added blending utilities and a new grid_radial module.
Introduced functions for loading GGD-related data and enhanced radiation loading capabilities.
Refactored cell subset ID handling and improved error handling in various functions.
Updated documentation for clarity and added tests for new features.
Removed unused classes and functions to streamline the codebase.