Skip to content

Parse line_id from MDSplus - #434

Open
AreWeDreaming wants to merge 4 commits into
masterfrom
ssd/process_cer_line_id
Open

Parse line_id from MDSplus#434
AreWeDreaming wants to merge 4 commits into
masterfrom
ssd/process_cer_line_id

Conversation

@AreWeDreaming

Copy link
Copy Markdown
Collaborator

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Other (please describe):

Testing

Tested against imas_composer GA-FDP/imas_composer#94

Pre-Merge Checklist

  • OMFIT has been tested with this OMAS version and you will create a PR on OMFIT that updates the OMAS submodule once this has been merged.
  • Version number has been incremented if this is a major modification or important bug fix
    • To increment the version: Edit the version number in omas/version file
    • Follow semantic versioning: MAJOR.MINOR.PATCH (e.g., 0.94.20.94.3 for bug fixes, 0.94.20.95.0 for new features)
    • A GitHub release will be automatically created when this PR is merged if the version number has changed

Additional Notes

@AreWeDreaming
AreWeDreaming requested a review from torrinba August 5, 2026 03:47
Comment on lines +1604 to +1611
def roman_to_int(roman):
total = 0
highest = 0
for char in reversed(roman):
value = ROMAN_DIGITS[char]
total += value if value >= highest else -value
highest = max(highest, value)
return total

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there not a library that implements this?

I recommend adding a few tests for this function.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do tests that happen inside imas_composer suffice?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If they test this, that would be sufficient.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread omas/machine_mappings/d3d.py Outdated
Co-authored-by: Torrin <1843540+torrinba@users.noreply.github.com>
raise ValueError(f'{sub} channel {channel:02d}: cannot parse LINEID {lineid!r}')
z_n, a = CER_ELEMENTS[element]
z_ion = roman_to_int(roman)
symbol = 'H' if element == 'D' else element

@torrinba torrinba Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The IMAS DD specifically documents that the symbol "D" is allowed. So it doesn't seem like there is a need to change to "H" here.

IMAS also suggests the labels should be "D+", "He+2", "C+6", etc. so it seems like we should try to follow that syntax unless there are problems with it (in which case we should open an issue - this field has been changed to "name" in IMAS 4 so that would be worth keeping in mind there).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I would defer fixing this for now but open an issue to tackle this later. The reason for this is that we need to also change it in IDA.

@torrinba torrinba Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is the label essential in IDA? It seems like z_n and z_ion are all you need to filter the ions (and a if you care about isotopes)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's not how it is implemented. If the labeling is consistent this is easier: https://github.com/GA-IDA/IDA/blob/2d1b056d9a24fb1262d5b56a69616d3c56d5b251/config/models/charge_exchange.yaml#L19

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If the label is only used in IDA to distinguish the quantity being measured then it doesn't seem like the format should make any difference. It would only matter if you're parsing the label to extract the ion charge or mass (or have it hard coded anywhere like it is in the config)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Except that right now in IDA this specific label style is also used for the underlying parametrization.

@torrinba torrinba Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sure, but the names of the IDA parametrizations don't actually have to match the ion labels and could be selected based on z_n, z_ion, and a

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We should try to be consistent

Comment thread omas/machine_mappings/d3d.py Outdated
Co-authored-by: Torrin <1843540+torrinba@users.noreply.github.com>
@AreWeDreaming
AreWeDreaming requested a review from smithsp August 6, 2026 17:32
Comment on lines +1604 to +1611
def roman_to_int(roman):
total = 0
highest = 0
for char in reversed(roman):
value = ROMAN_DIGITS[char]
total += value if value >= highest else -value
highest = max(highest, value)
return total

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If they test this, that would be sufficient.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So all of this got migrated to its own CER omas fetching?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think everything got migrated but I bet that we can find a similar and probably better maintained script somewhere in OMFIT. This script relies on OMFIT in OMAS which is something we are trying to avoid.

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.

3 participants