Skip to content

power: add flux calculation (number of points) #101

@srio

Description

@srio

See script in hercules tutorial

import numpy as np
from srxraylib.plot.gol import plot
import scipy.constants as codata
# this part is to read the incoming signals
energy = np.copy(in_object_1.get_contents("xoppy_data")[:,0])
pow_w_ev = np.copy(in_object_1.get_contents("xoppy_data")[:,-1])

#this transforms the power spectra in photons/s/eV
flux_in_bandwidth = (pow_w_ev/codata.e)/1000 
flux_ps_ev = flux_in_bandwidth / (energy / 1000)

#plotting part
plot(energy, flux_ps_ev, xlog=False, ylog=True, xtitle="Photon energy [eV]",ytitle="Flux", legend=["Flux(Ph/s/eV)"])
#calculation of the total number of photons/s
total_ph = np.trapz(flux_ps_ev, x=energy, axis = -1)

print(f'Total photons per second {total_ph:.5E} at 5000 eV')

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions