Skip to content

Warn on detector components falling back to raw data#712

Merged
takluyver merged 1 commit intomasterfrom
feat/warn-raw-fallback
Jan 6, 2026
Merged

Warn on detector components falling back to raw data#712
takluyver merged 1 commit intomasterfrom
feat/warn-raw-fallback

Conversation

@takluyver
Copy link
Copy Markdown
Member

When instantiating a detector component, if raw= is not specified, it looks for corrected data first and then falls back to raw data if no corrected data is found. This was a compromise between having the defaults give people corrected data, and keeping existing code with open_run(..., data='raw') working the same way.

However, this fallback is an occasional source of confusion - if correction fails, or you open a run before the corrected files exist, or if code that works with recent (renamed sources) data is run on older data, you're suddenly trying to use raw data and getting garbage results. I'd like to remove the fallback and change the default to raw=False in time, but for now this adds a warning if the fallback occurs, pushing people towards specifying raw= explcitly.

We added the raw parameter and changed the default behaviour in open_run() - to combine raw & proc - in January 2025.

cc @turkot @philsmt

@takluyver takluyver added this to the 1.24 milestone Jan 5, 2026
@takluyver takluyver added the enhancement New feature or request label Jan 5, 2026
Copy link
Copy Markdown
Contributor

@philsmt philsmt left a comment

Choose a reason for hiding this comment

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

I would probably opt for a more aggressive break with backwards compatibility here in light on the upcoming removal of legacy sources, but I also don't mind the compromise.

LGTM.

Comment thread extra_data/components.py

if (raw is False) and any(cls._data_is_raw(data, s) for s in source_to_modno):
raise SourceNameError(f'{detector_name}/CORR/...')
if any(cls._data_is_raw(data, s) for s in source_to_modno):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

n.b. I was curious how this method is implemented and realized its check for image.data dtype can fail if photonization is used. I will open a PR for that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There's already an override for AGIPD for precisely that region. I think that's the only detector where we have photonisation so far? Of course, if we're changing that, we should update this. The obvious thing would be to check for one of the extra keys like image.mask, but it's possible to select that out of the data before making the component.

Copy link
Copy Markdown
Contributor

@philsmt philsmt Jan 6, 2026

Choose a reason for hiding this comment

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

I was thinking of an early

if '/CORR/' in source:
    return False

@takluyver
Copy link
Copy Markdown
Member Author

I'm figuring we can probably remove the fallback in another cycle or two. It is pretty easy to adapt with raw=True if you're using raw data. But every little breaking change someone hits can make them less willing to trust us.

@takluyver takluyver merged commit 74a505f into master Jan 6, 2026
10 checks passed
@takluyver takluyver deleted the feat/warn-raw-fallback branch January 6, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants