Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate entries in continuum line list #2443

Merged
merged 8 commits into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tardis/plasma/properties/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,26 @@ def calculate(self, atomic_data):
level_idxs2line_idx = pd.Series(
np.arange(len(index)), index=index, name="lines_idx"
)

# Check for duplicate indices
Copy link
Member Author

Choose a reason for hiding this comment

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

We already get duplicate indices here, completely unrelated to the actual continuum lines. For now I added a ValueError to catch this early, but I'm not sure if we can simply drop the duplicate indices.

if level_idxs2line_idx.index.duplicated().any():
logger.warn(
"Duplicate indices in level_idxs2line_idx. "
"Dropping duplicates. "
"This is an issue with the atomic data & carsus. "
"Once fixed upstream, this warning will be removed. "
"This will raise an error in the future instead. "
"See https://github.com/tardis-sn/carsus/issues/384"
)
# This is necessary since pd.DataFrame.drop_duplicates()
# does not remove duplicates if the data is different
# and only the index is duplicated. See the example given
# in the pandas documentation:
# https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.drop_duplicates.html
level_idxs2line_idx = level_idxs2line_idx[
~level_idxs2line_idx.index.duplicated()
]

return level_idxs2line_idx


Expand Down
Loading