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

Question about plotting energy spectrum #165

Open
zhangyujun08 opened this issue Dec 15, 2023 · 6 comments
Open

Question about plotting energy spectrum #165

zhangyujun08 opened this issue Dec 15, 2023 · 6 comments

Comments

@zhangyujun08
Copy link

I am a beginner of xrt and trying to demo a simple ray-tracing case. I constructed a beamline with a geometric source and a Si(111) DCM, and monitor the beam properties after the DCM by a screen called "beamFSM1". I had energy bandwidth of around 5eV at the source and expected the energy bandwidth to be reduced to around 1.6eV. This was confirmed by the energy FWHM value in a XYCplot of beamFSM1.
On the other hand, I used shine(withAmplitudes=True) to get the amplitude of the rays. Then I used raycing.get_energy(run_process(beamLine)["beamFSM1"]) and raycing.get_Es_amp(run_process(beamLine)["beamFSM1"]) to get arrays of beam energy and amplitude. I expected that the energy spectrum that the DCM produces could be obtained by plotting Es_amp against energy, but I only got random distribution of Es_amp in the energy axis.
I wonder why it is the case, and what is actually plotted in the energy spectrum of the XYCplot.
Thanks in advance!

@kklmn
Copy link
Owner

kklmn commented Dec 16, 2023

I hope you have seen the documentation on xrt plots.

What is plotted as 1D and 2D distributions are not the original beams but their histograms. If you want to directly work with beams, XYCPlot is useless, and inversely, if you want the facilities of XYCPlot, you shouldn't work directly with beams. The option withAmplitudes=True enables complex field amplitudes, this is only needed for special applications like wave propagation. What is histogrammed and plotted are intensities, not amplitudes.

If you have a defined idea on what you want to get and cannot get it, just ask again.

@zhangyujun08
Copy link
Author

zhangyujun08 commented Dec 18, 2023 via email

@kklmn
Copy link
Owner

kklmn commented Dec 18, 2023

See this part of documentation.

In particular, if you put your wanted property as c-axis (color axis), you get it as:
x = yourPlot.caxis.binCenters
y = yourPlot.caxis.total1D

You can find more usage examples if you search the supplied examples for afterScript.

@zhangyujun08
Copy link
Author

zhangyujun08 commented Dec 19, 2023 via email

@kklmn
Copy link
Owner

kklmn commented Dec 19, 2023

can I skip the plotting procedure of the XYCplot and directly extract the properties in it?

Yes, see the "Tip" here.

When I run the script in Spyder or Jupyter notebook, it shows empty plots.

See a paragraph about Spyder here.

Note also that the documentation is searchable.

@zhangyujun08
Copy link
Author

zhangyujun08 commented Dec 20, 2023 via email

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

No branches or pull requests

2 participants