Add conversion to eV in UndulatorEnergyGap lut - #202
Merged
Conversation
jacob-williamson
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, looks good to me. A couple comments in the code
| ) -> list[list[float]]: | ||
| if units_from_table.lower() == default_energy_unit.lower(): | ||
| return rows | ||
| converted_rows = [[row[0] * 1000, row[1]] for row in rows] |
Collaborator
There was a problem hiding this comment.
Could: explicitly check the if the units from the table are keV, in case some people have weird units. Something like
if units_from_table.lower() == "kev":
return [[row[0] * 1000, row[1]] for row in rows]
else:
raise ValueError(f"No conversion implemented for units: {units_from_table}")
Collaborator
Author
There was a problem hiding this comment.
Yeah, fair enough
| def get_units_from_lut( | ||
| contents: str, | ||
| default_units: list[str], | ||
| units_lines: tuple[str, str] = DEFAULT_IGNORE_LINES_STARTING_WITH[:2], |
Collaborator
There was a problem hiding this comment.
I think DEFAULT_IGNORE_LINES_STARTING_WITH could be added to/re-ordered which would have the unintended side affect of breaking this. Maybe a new constant DEFAULT_UNITS_LINES would be better, and DEFAULT_IGNORE_LINES_STARTING_WITH could become DEFAULT_UNITS_LINES + ("ScannableNames",)
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.
On some beamlines, the lookup table for the UndulatorEnergyGap has the energies in KeV instead of eV, leading to incorrect calculations down the line. This change adds a conversion to the
UndulatorEnergyGapLookupTableso that is a table has the units in KeV its rows will be converted to eV.In case there is no
Unitsline in the lookup table file,eVis assumed as the default and no conversion is done.