Add explicit check for missing j_phi in IMAS equilibrium loader#1935
Open
nytdevansh wants to merge 3 commits intogoogle-deepmind:mainfrom
Open
Add explicit check for missing j_phi in IMAS equilibrium loader#1935nytdevansh wants to merge 3 commits intogoogle-deepmind:mainfrom
nytdevansh wants to merge 3 commits intogoogle-deepmind:mainfrom
Conversation
Nush395
reviewed
Feb 3, 2026
| # spr = vpr * <1/R> / ( 2 * np.pi ) | ||
| # -> Ip_profile = integrate(y = spr * jtor, x= rhon, initial = 0.0) | ||
| jtor = -1 * IMAS_data.profiles_1d.j_phi | ||
| if not np.any(jtor): |
Collaborator
There was a problem hiding this comment.
what is jtor here if `the profile is missing?
Author
There was a problem hiding this comment.
If the profile is missing, Jtor will be an array of zeros multiplied by -1 which the line 172 checks for with np.any(jtor), after that if the jtor is all zeros than it will raise an ValueError. Hence , stopping the execution.
Collaborator
There was a problem hiding this comment.
I see, then I'd recommend validating the j_phi object directly to check if it is empty or not.
Author
There was a problem hiding this comment.
Thanks for the suggestion ! That makes sense, validating j_phi directly is a better and much cleaner approach. Should I check if it exists or is non-empty before the multiplication?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds an explicit availability check for the
profiles_1d.j_phifield when loading IMAS equilibrium data.
When
j_phiis missing, TORAX previously failed downstream with amisleading Pydantic broadcasting error. This change fails fast with a
clear, domain-specific error message instead.
Closes #1610