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

Per shot wavelength, second try #717

Merged
merged 3 commits into from
Jan 23, 2020
Merged

Per shot wavelength, second try #717

merged 3 commits into from
Jan 23, 2020

Conversation

phyy-nx
Copy link
Contributor

@phyy-nx phyy-nx commented Jan 23, 2020

Extend incident_wavelength to allow per-shot variation

  • Specify how to do monochromatic shot-to-shot variation
  • Specify how to do polychromatic shot-to-shot variation
  • Include shot-to-shot variation in wavelength spread

Also, py2 bug in nxdl2rst.py.

Fixes #667

-Specify how to do monochromatic shot-to-shot variation
-Specify how to do polychromatic shot-to-shot variation
-Include shot-to-shot variation in wacelength spread
- Remove TODO
- detector element -> detector module.
- Typos
- Extend flux and total_flux to allow shot-to-shot variation
- Remove non-required items from NXSource and reference that they can be found in the base class documentation

Thanks @benajamin, @yayahjb, @PeterC-DLS, @prjemian for the review. Yay code camp!
@PeterC-DLS
Copy link
Contributor

This fixes #696

@phyy-nx phyy-nx merged commit 194ffc0 into master Jan 23, 2020
@phyy-nx phyy-nx deleted the per_shot_wavelength_redo branch January 23, 2020 00:55
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request Apr 3, 2020
SpectrumBeam has these methods:
set_spectrum(flex.double energies, flex.double weights)
get_spectrum_energies()
get_spectrum_weights()
get_weighted_wavelength()

Two flex arrays, energies (eV) and weights (dimensionless), represent the spectrum as a scatter plot.  This follows the conventions set up in nexusformat/definitions#717. The new function get_weighted_wavelength uses a simple weighted mean to determine a wavelength.

It is ok if the SpectrumBeam has a wavelength != get_weighted_wavelength.  This represents a calibrated wavelength determined from processing the spectrum.

is_similar_to tests get_weighted_wavelength between the two beams.

Includes tests.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request Apr 3, 2020
Uses the unofficial key incident_wavelength_calculated, but otherwise implements nexusformat/definitions#717.
phyy-nx added a commit to cctbx/cctbx_project that referenced this pull request Apr 3, 2020
Uses the convention of nexusformat/definitions#717 with the addition of a yet-unofficial field, incident_wavelength_calculated, to store the calculated wavelength SwissFEL provides. This wavelength comes from a smoothed, fitted processing of the spectra.  As it can be considered derived information, so is in a separate dataset.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request Apr 3, 2020
Uses the unofficial key incident_wavelength_calculated, but otherwise implements nexusformat/definitions#717.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request Apr 8, 2020
Adds these methods:
set_spectrum(flex.double energies, flex.double weights)
get_spectrum_energies()
get_spectrum_weights()
get_weighted_wavelength()

Two flex arrays, energies (eV) and weights (dimensionless), represent the spectrum as a scatter plot.  This follows the conventions set up in nexusformat/definitions#717. The new function get_weighted_wavelength uses a simple weighted mean to determine a wavelength.

It is ok if the beam has a wavelength != get_weighted_wavelength.  This represents a calibrated wavelength determined from processing the spectrum.

is_similar_to tests get_weighted_wavelength between the two beams, if a spectrum is present.

Includes tests.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request Apr 9, 2020
Adds these methods:
set_spectrum(flex.double energies, flex.double weights)
get_spectrum_energies()
get_spectrum_weights()
get_weighted_wavelength()

Two flex arrays, energies (eV) and weights (dimensionless), represent the spectrum as a scatter plot.  This follows the conventions set up in nexusformat/definitions#717. The new function get_weighted_wavelength uses a simple weighted mean to determine a wavelength.

It is ok if the beam has a wavelength != get_weighted_wavelength.  This represents a calibrated wavelength determined from processing the spectrum.

is_similar_to tests get_weighted_wavelength between the two beams, if a spectrum is present.

Includes tests.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request Apr 9, 2020
Uses the unofficial key incident_wavelength_calculated, but otherwise implements nexusformat/definitions#717
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request Apr 9, 2020
Adds these methods:
set_spectrum(flex.double energies, flex.double weights)
get_spectrum_energies()
get_spectrum_weights()
get_weighted_wavelength()

Two flex arrays, energies (eV) and weights (dimensionless), represent the spectrum as a scatter plot.  This follows the conventions set up in nexusformat/definitions#717. The new function get_weighted_wavelength uses a simple weighted mean to determine a wavelength.

It is ok if the beam has a wavelength != get_weighted_wavelength.  This represents a calibrated wavelength determined from processing the spectrum.

is_similar_to tests get_weighted_wavelength between the two beams, if a spectrum is present.

Includes tests.
phyy-nx added a commit to cctbx/cctbx_project that referenced this pull request Apr 14, 2020
Uses the convention of nexusformat/definitions#717 with the addition of a yet-unofficial field, incident_wavelength_calculated, to store the calculated wavelength SwissFEL provides. This wavelength comes from a smoothed, fitted processing of the spectra.  As it can be considered derived information, so is in a separate dataset.
phyy-nx added a commit to cctbx/cctbx_project that referenced this pull request Apr 15, 2020
Uses the convention of nexusformat/definitions#717 with the addition of a yet-unofficial field, incident_wavelength_calculated, to store the calculated wavelength SwissFEL provides. This wavelength comes from a smoothed, fitted processing of the spectra.  As it can be considered derived information, so is in a separate dataset.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request May 4, 2020
Adds these methods:
set_spectrum(flex.double energies, flex.double weights)
get_spectrum_energies()
get_spectrum_weights()
get_weighted_wavelength()

Two flex arrays, energies (eV) and weights (dimensionless), represent the spectrum as a scatter plot.  This follows the conventions set up in nexusformat/definitions#717. The new function get_weighted_wavelength uses a simple weighted mean to determine a wavelength.

It is ok if the beam has a wavelength != get_weighted_wavelength.  This represents a calibrated wavelength determined from processing the spectrum.

is_similar_to tests get_weighted_wavelength between the two beams, if a spectrum is present.

Includes tests.
phyy-nx added a commit to cctbx/cctbx_project that referenced this pull request May 5, 2020
Uses the convention of nexusformat/definitions#717 with the addition of a yet-unofficial field, incident_wavelength_calculated, to store the calculated wavelength SwissFEL provides. This wavelength comes from a smoothed, fitted processing of the spectra.  As it can be considered derived information, so is in a separate dataset.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request May 5, 2020
Uses the unofficial key incident_wavelength_calculated, but otherwise implements nexusformat/definitions#717
phyy-nx added a commit to cctbx/cctbx_project that referenced this pull request May 12, 2020
Uses the convention of nexusformat/definitions#717 with the addition of a yet-unofficial field, incident_wavelength_calculated, to store the calculated wavelength SwissFEL provides. This wavelength comes from a smoothed, fitted processing of the spectra.  As it can be considered derived information, so is in a separate dataset.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request May 19, 2020
Uses the unofficial key incident_wavelength_calculated, but otherwise implements nexusformat/definitions#717
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request May 21, 2020
Uses the unofficial key incident_wavelength_calculated, but otherwise implements nexusformat/definitions#717
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request May 28, 2020
Adds these methods:
set_spectrum(flex.double energies, flex.double weights)
get_spectrum_energies()
get_spectrum_weights()
get_weighted_wavelength()

Two flex arrays, energies (eV) and weights (dimensionless), represent the spectrum as a scatter plot.  This follows the conventions set up in nexusformat/definitions#717. The new function get_weighted_wavelength uses a simple weighted mean to determine a wavelength.

It is ok if the beam has a wavelength != get_weighted_wavelength.  This represents a calibrated wavelength determined from processing the spectrum.

is_similar_to tests get_weighted_wavelength between the two beams, if a spectrum is present.

Includes tests.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request May 28, 2020
Uses the unofficial key incident_wavelength_calculated, but otherwise implements nexusformat/definitions#717
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request May 29, 2020
Adds these methods:
set_spectrum(flex.double energies, flex.double weights)
get_spectrum_energies()
get_spectrum_weights()
get_weighted_wavelength()

Two flex arrays, energies (eV) and weights (dimensionless), represent the spectrum as a scatter plot.  This follows the conventions set up in nexusformat/definitions#717. The new function get_weighted_wavelength uses a simple weighted mean to determine a wavelength.

It is ok if the beam has a wavelength != get_weighted_wavelength.  This represents a calibrated wavelength determined from processing the spectrum.

is_similar_to tests get_weighted_wavelength between the two beams, if a spectrum is present.

Includes tests.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request May 29, 2020
Uses the unofficial key incident_wavelength_calculated, but otherwise implements nexusformat/definitions#717
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request Jul 27, 2020
Details:
- Add Spectrum C++ object that implements methods get_energies (eV), get_weights (unitless), and get_weighted_wavelenth (angstroms). Spectrum can only be set from constructor.
- Add get_spectrum method to Format and FormatMultiImage
- Add get_spectrum method to ImageSet. Does not cache it like it does for detector, beam, etc.
- Implement get_spectrum in NeXus.  Specifically implements nexusformat/definitions#717, using optional variants to specify a calibrated wavelength and a spectrum.
phyy-nx added a commit to cctbx/dxtbx that referenced this pull request Jul 29, 2020
* Add Spectrum as a read-only class obtainable from an imageset

Details:
- Add Spectrum C++ object that implements methods get_energies_eV (eV), get_weights (unitless), and get_weighted_wavelenth (angstroms). Spectrum can only be set from constructor.
- Add get_spectrum method to Format and FormatMultiImage
- Add get_spectrum method to ImageSet. Does not cache it like it does for detector, beam, etc.
- Implement get_spectrum in NeXus.  Specifically implements nexusformat/definitions#717, using optional variants to specify a calibrated wavelength and a spectrum.
- Add test for c++ spectrum object
- Add bandwidth calculation. Computes: emin_ev = 1% on CDF and emax_ev = 99% on CDF so 98% or more of the
spectrum is within the range. Added a test for this, which has a computed approximation to a real SwissFEL spectrum (so could be useful in other tests)
- Add weighted energy variance. Recover the weighted variance around the weighted mean. Add test which makes
a clean Gaussian and recovers the same parameters.

Co-authored-by: Graeme Winter <graeme.winter@gmail.com>
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.

How to specify per-shot wavelength
2 participants