Skip to content

Conversation

@MateoBell
Copy link
Collaborator

@MateoBell MateoBell commented Oct 8, 2025

Add validators for the IMAS function to check that the required fields are properly filled in the input IDS and if not provide a clear warning.
Closes #1610.

Validation functions:

  • for profile_conditions
  • for plasma_composition
  • for geometry

Integration

  • Testing
  • see where to be called

@MateoBell MateoBell reopened this Oct 8, 2025
import torax._src.constants as constants

_PROFILE_CONDITIONS_REQUIRED_FIELDS = {
"gloabl_quantities": ["ip", "v_loop"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

are there any constants from the imas-python library that can be referred to here instead of us using literal strings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mikesndrs can I ask your input on this ? Do you know if it exists in imas-python ?

for field in _PROFILE_CONDITIONS_REQUIRED_FIELDS["gloabl_quantities"]:
if not getattr(global_quantities, field):
# Warning or critical ?
logging.critical(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we'd want to raise an error here with an informative error message that the expected field is missing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not entirely sure about this. For geometry loader I think we'd want to raise an error but with core_profiles not necessarily. There might be cases where we want to load partially some profiles but not all from an IDS, like only electrons ones or ions ones and get the rest from elsewhere / prescribe it. In this case, it does not matter that the other fields are empty in the input IDS. Do you agree ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah ok, yeah that makes sense. I think it would be good to converge on a minimal set of required attributes for using the profile_conditions_from_IMAS function though as that makes assumptions on certain fields being present?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add check that required terms are present in IMAS on load

2 participants