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

Add spectrum_required=False to FormatXTC #674

Merged
merged 3 commits into from
Jan 19, 2024
Merged

Conversation

phyy-nx
Copy link
Contributor

@phyy-nx phyy-nx commented Dec 4, 2023

New parameter and updated behavior to account for occasional dropped spectra in the XTC stream, when spectra a used to produce a calibrated average wavelength. If spectrum_required=True, and the FEE spectrometer is not found in an event, get_spectrum will raise a RuntimeError. If spectrum_required = False and spectra calibration constants (spectrum_eV_per_pixel and spectrum_eV_offset) are provided, wavelength_offset can be used to apply a general correction for any events with a dropped spectrum. If the spectrum is present and calibration constants are provided, wavelength_offset is ignored.

New parameter and updated behavior to account for occasional dropped spectra in the XTC stream, when spectra a used to produce a calibrated average wavelength.  If spectrum_required=True, and the FEE spectrometer is not found in an event, get_spectrum will raise a RuntimeError. If spectrum_required = False and spectra calibration constants (spectrum_eV_per_pixel and spectrum_eV_offset) are provided, wavelength_offset can be used to apply a general correction for any events with a dropped spectrum. If the spectrum is present and calibration constants are provided, wavelength_offset is ignored.
@phyy-nx phyy-nx requested a review from dwpaley December 4, 2023 21:38
Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Merging #674 (1522982) into main (dbd7ede) will decrease coverage by 0.03%.
The diff coverage is 7.14%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #674      +/-   ##
==========================================
- Coverage   42.62%   42.60%   -0.03%     
==========================================
  Files         182      182              
  Lines       15924    15935      +11     
  Branches     3056     3058       +2     
==========================================
+ Hits         6788     6789       +1     
- Misses       8510     8520      +10     
  Partials      626      626              

@dwpaley
Copy link

dwpaley commented Jan 9, 2024

We've used this successfully a few times, so as such it LGTM. A couple comments that don't need to prevent merging:

  • This changes the handling of wavelength_offset in the case where the spectrum is present and calibration constants are provided. (namely it was applied before, and now it isn't.) Is there any existing use case for wavelength_offset where this change will break backwards compatibility? (I can't think of any)
  • It's starting to accumulate a maze of nested try/excepts in there, maybe this is a candidate for some mild refactoring. I'm sure we will have more time in a couple months :)

@phyy-nx
Copy link
Contributor Author

phyy-nx commented Jan 19, 2024

@dwpaley

This changes the handling of wavelength_offset in the case where the spectrum is present and calibration constants are provided. (namely it was applied before, and now it isn't.) Is there any existing use case for wavelength_offset where this change will break backwards compatibility? (I can't think of any)

No, we've never had a situation with both a calibrated spectrum and the need to apply wavelength_offset. If we did, we'd just add wavelength_offset to spectrum_eV_offset (adjusting the units).

@phyy-nx phyy-nx merged commit 5179420 into main Jan 19, 2024
20 checks passed
@phyy-nx phyy-nx deleted the xtc_spectrum_required branch January 19, 2024 00:40
graeme-winter pushed a commit that referenced this pull request Feb 5, 2024
New parameter and updated behavior to account for occasional dropped spectra in the XTC stream, when spectra a used to produce a calibrated average wavelength.  If spectrum_required=True, and the FEE spectrometer is not found in an event, get_spectrum will raise a RuntimeError. If spectrum_required = False and spectra calibration constants (spectrum_eV_per_pixel and spectrum_eV_offset) are provided, wavelength_offset can be used to apply a general correction for any events with a dropped spectrum. If the spectrum is present and calibration constants are provided, wavelength_offset is ignored.
toastisme pushed a commit to toastisme/dxtbx that referenced this pull request Jul 18, 2024
New parameter and updated behavior to account for occasional dropped spectra in the XTC stream, when spectra a used to produce a calibrated average wavelength.  If spectrum_required=True, and the FEE spectrometer is not found in an event, get_spectrum will raise a RuntimeError. If spectrum_required = False and spectra calibration constants (spectrum_eV_per_pixel and spectrum_eV_offset) are provided, wavelength_offset can be used to apply a general correction for any events with a dropped spectrum. If the spectrum is present and calibration constants are provided, wavelength_offset is ignored.
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