✨ Enhance plasma loading features#26
Conversation
…ta, and SpeciesComposition dataclasses; refactor get_ion_state and get_neutral_state functions for improved clarity and functionality.
…ion calculation in coronal equilibrium; update `__init__.py` to include the new function.
…oved structure and clarity; enhance documentation and streamline data handling.
…tion` dataclass for improved type safety and clarity; enhance parameter documentation.
…ators; enhance `load_core_plasma` function to support atomic data and improve species distribution handling.
…aise a RuntimeError if the toroidal component of the magnetic field is not found; add fallback logic to DDv3
…es; enhance `ProfileData` to include velocity data.
…eper structure retrieval; improve handling of `IDSNumericArray` and add return type checks.
…e handling; remove unused `ProfileInterporater` dataclass and improve error checks for electron properties.
…ture, and velocity interpolating functions; improve warning messages for unsupported species.
…utilize `ProfileData` and `SpeciesComposition` dataclasses; enhance profile loading logic and streamline data handling for species and velocities.
…g and streamline species distribution logic; enhance profile interpolation with `ProfileInterporater` dataclass.
Use data from dataclasses implemented before
To improve plotting functions and add functionality for splitting bundled species profiles
…intract for consistency
… Vector3DFunction2D
…asma loading and documentation
There was a problem hiding this comment.
Pull request overview
This PR refactors IMAS plasma loading to use dataclass-based species/profile models, adds optional ion-bundle splitting via a coronal-equilibrium solver, and updates tests + documentation/tooling to match the new APIs and workflows.
Changes:
- Introduces new species/profile dataclasses and updates core/edge/blended plasma loaders to use them (including
split_ion_bundles+atomic_datasupport). - Adds
solve_coronal_equilibrium()and uses it to split bundled ion species into individual charge states. - Updates tests, docs notebooks, and developer tooling (pixi/lefthook/Sphinx) for the new behavior and workflows.
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/plasma/test_equilibrium.py | Updates expected magnetic-field function type. |
| tests/plasma/test_edge.py | Aligns edge-plasma tests with new API and ion-bundle splitting behavior. |
| tests/plasma/test_core.py | Aligns core-plasma tests with new API and ion-bundle splitting behavior. |
| tests/plasma/test_blend.py | Aligns blended-plasma tests with new API and ion-bundle splitting behavior. |
| tests/plasma/conftest.py | Adds dataset fixtures for SOLPS/JOREK; updates imports. |
| tests/conftest.py | Adds session autouse OpenADAS repository population for tests. |
| src/cherab/imas/plasma/utility.py | Adds ProfileInterpolator dataclass and shared constants/utilities. |
| src/cherab/imas/plasma/equilibrium.py | Updates interpolator imports/types and magnetic-field return type. |
| src/cherab/imas/plasma/edge.py | Refactors edge plasma loading around dataclasses; adds splitting/atomic-data options. |
| src/cherab/imas/plasma/core.py | Refactors core plasma loading around dataclasses; adds splitting/atomic-data options. |
| src/cherab/imas/plasma/blend.py | Refactors blended plasma loading; adds splitting/atomic-data options and new blending logic. |
| src/cherab/imas/math/functions/vector_functions.pyx | Minor docstring grammar tweak. |
| src/cherab/imas/math/functions/vector_functions.pyi | Mirrors docstring grammar tweak in stubs. |
| src/cherab/imas/ids/equilibrium/load_field.py | Adds b_field_tor fallback with deprecation warning. |
| src/cherab/imas/ids/edge_profiles/load_profiles.py | Refactors edge species/profile extraction to dataclasses; implements ion-bundle splitting. |
| src/cherab/imas/ids/core_profiles/load_profiles.py | Refactors core species/profile extraction to dataclasses; implements ion-bundle splitting; adds GridData. |
| src/cherab/imas/ids/core_profiles/init.py | Exposes GridData in the public core_profiles loader API. |
| src/cherab/imas/ids/common/species.py | Introduces common dataclasses/enums for species/profile modeling across IDS loaders. |
| src/cherab/imas/ids/common/_model.py | Adds coronal-equilibrium solver used for ion-bundle splitting. |
| src/cherab/imas/ids/common/init.py | Re-exports solve_coronal_equilibrium. |
| src/cherab/imas/ggd/unstruct_2d_extend_mesh.py | Docstring “See Also” placement tweak. |
| src/cherab/imas/datasets/_registry.py | Updates dataset registry/method mapping for modified JINTRAC workflow. |
| src/cherab/imas/datasets/_patch.py | Adds JINTRAC patching utility to adjust bundled species metadata. |
| src/cherab/imas/datasets/_fetchers.py | Applies JINTRAC patching automatically in iter_jintrac(). |
| pixi.toml | Adjusts tasks/features; adds nbstripout tool; reorganizes doc-clean under tools. |
| docs/source/conf.py | Minor Sphinx configuration cleanup (napoleon_use_rtype, html_title). |
| docs/notebooks/plasma/full_plasma.ipynb | Updates notebook content to document ADAS downloads and improved plotting. |
| docs/notebooks/plasma/emission.ipynb | Refactors emission notebook flow; adds atomic-data setup and banded spectra approach. |
| docs/notebooks/plasma/edge_plasma.ipynb | Updates edge-plasma notebook to new dataclass composition API and adds bundle-splitting demo. |
| docs/notebooks/misc/fractional_ abundances.ipynb | Adds new notebook demonstrating fractional abundances via coronal equilibrium. |
| CHANGELOG.md | Records new functionality/refactors/tooling updates for the next release. |
| .lefthook.yaml | Updates pre-commit pipeline (ordering, pyrefly, nbstripout, CI behavior). |
| .github/workflows/docs.yml | Removes pixi-version pin. |
| .github/workflows/ci.yaml | Removes pixi-version pin. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ent passing in exception handling
… dataset filename
…profile interpolation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 35 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def fix_jintrac(path_in: str, path_out: str) -> None: | ||
| """Fix the JINTRAC IDS. | ||
|
|
||
| This function modifies the JINTRAC IDS by updating the `z_min` and `z_max` values for the ion | ||
| states of Neon and Tungsten in the `core_profiles` IDS. | ||
|
|
||
| The modified IDS is then saved to a new file with a "_mod" suffix. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| path_in | ||
| The file path to the original JINTRAC IDS. | ||
| path_out | ||
| The file path to save the modified IDS. | ||
| """ | ||
| print("=== Apply patch to fix ===") | ||
| # %% |
There was a problem hiding this comment.
fix_jintrac() prints unconditionally, and iter_jintrac() will invoke it on first download. This introduces noisy stdout in library usage and in downstream tooling. Consider replacing print() with logging (debug/info) or warnings.warn, or make patching optional/explicit so consumers can opt out.
…prove profile loading logic
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #26 +/- ##
===========================================
+ Coverage 48.57% 50.49% +1.91%
===========================================
Files 43 45 +2
Lines 2077 2646 +569
Branches 341 452 +111
===========================================
+ Hits 1009 1336 +327
- Misses 948 1133 +185
- Partials 120 177 +57 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add test for calling magnetic field function
|
Ignore the CI test fail because pyrefly test need raysect/cherab-stubs released. |
Key changes include:
Introduced new dataclasses for improved species and profile data handling.
Enhanced core and edge plasma loading functions for better structure and clarity.
Updated documentation and Sphinx configuration for clarity and consistency.
Implemented splitting ion bundles in plasma loading functions.
Improved error handling and type safety across various functions.