spex-xray / spex-help

These are the help and manual pages for the SPEX X-ray spectral fitting package.
1 stars 1 forks source link

[PYSPEX] Getting the total flux from a model #30

Closed jdeplaa closed 1 year ago

jdeplaa commented 1 year ago

Question from @drogantini in issue #29:

I am trying to get the total flux for a model. I understand that pyspex only gets the flux of single components. Therefore, is the following small script the easy/quick way to get the total flux?

flux = numpy.array(0.0)
# loop over all the components 
for i in range(s.mod.sect[0].ncomp):
    # check if it is additive component
    if s.mod.sect[0].comp[i].add == True:
        # sum the flux
        flux += numpy.array(s.flux_get(1,i+1).photlum)
jdeplaa commented 1 year ago

Hi @drogantini,

The fluxes are indeed calculated per component. The numbers that you get in pyspex are the same as the numbers that you get in the par show command in the classic SPEX interface. It is important to note that the luminosities are calculated at the source and are not absorbed, so the photlum variable contains the photon luminosity of the component at the source, without any absorption applied. The flux parameters photflux and enerflux provide the photon and energy flux at the telescope and they are corrected for absorption (if there is an absorption model present and related to this component).

The above means that summing the luminosities only works if you do not have intrinsic absorption in the source. If you do have intrinsic absorption, it becomes a bit more complicated, especially if you have a Galactic absorption component as well. Let me know if you want to know more about this.

drogantini commented 1 year ago

Thanks!