Skip to content

✨ Enhance plasma loading features#26

Merged
munechika-koyo merged 78 commits intodevelopfrom
feature/split-bundles
Mar 22, 2026
Merged

✨ Enhance plasma loading features#26
munechika-koyo merged 78 commits intodevelopfrom
feature/split-bundles

Conversation

@munechika-koyo
Copy link
Member

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.

…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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_data support).
  • 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +7 to +23
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 ===")
# %%
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 67.31771% with 251 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.49%. Comparing base (27ec817) to head (b80d24b).
⚠️ Report is 111 commits behind head on develop.

Files with missing lines Patch % Lines
src/cherab/imas/ids/core_profiles/load_profiles.py 64.42% 40 Missing and 13 partials ⚠️
src/cherab/imas/ids/edge_profiles/load_profiles.py 63.30% 32 Missing and 19 partials ⚠️
src/cherab/imas/ids/common/species.py 74.65% 32 Missing and 5 partials ⚠️
src/cherab/imas/plasma/edge.py 55.55% 24 Missing and 12 partials ⚠️
src/cherab/imas/plasma/blend.py 62.19% 20 Missing and 11 partials ⚠️
src/cherab/imas/plasma/core.py 57.89% 14 Missing and 10 partials ⚠️
src/cherab/imas/ids/common/_model.py 69.69% 5 Missing and 5 partials ⚠️
src/cherab/imas/ids/equilibrium/load_field.py 28.57% 4 Missing and 1 partial ⚠️
src/cherab/imas/plasma/utility.py 91.89% 1 Missing and 2 partials ⚠️
src/cherab/imas/datasets/_fetchers.py 90.90% 0 Missing and 1 partial ⚠️
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.
📢 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.

@munechika-koyo
Copy link
Member Author

Ignore the CI test fail because pyrefly test need raysect/cherab-stubs released.

@munechika-koyo munechika-koyo merged commit 672c1c2 into develop Mar 22, 2026
12 of 13 checks passed
@munechika-koyo munechika-koyo deleted the feature/split-bundles branch March 23, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants