icecube / FIRESONG

FIRst Extragalactic Simulation Of Neutrino and Gamma-ray
Other
18 stars 8 forks source link

Interaction between fluxnorm and zmin #59

Closed JostMigenda closed 3 years ago

JostMigenda commented 3 years ago

[As part of the JOSS review.]

Here’s a usage example:

from firesong.Firesong import firesong_simulation

sim = firesong_simulation(None, filename=None,
                                density=1e-10,
                                Evolution='MD2014SFR',
                                zmin=0.0005,  # <-- Default value
                                verbose=False)
print("=== zmin = 0.0005 ===")
print(f"Expected flux: {sim['header']['fluxnorm']}")
print(f"Actual flux of {len(sim['sources']['flux'])} sources: {sim['total_flux']}")

sim = firesong_simulation(None, filename=None,
                                density=1e-10,
                                Evolution='MD2014SFR',
                                zmin=4,  # <-- Note this non-default value!
                                verbose=False)
print("=== zmin = 4 ===")
print(f"Expected flux: {sim['header']['fluxnorm']}")
print(f"Actual flux of {len(sim['sources']['flux'])} sources: {sim['total_flux']}")

And this is the output I got:

=== zmin = 0.0005 === Expected flux: 1.44e-08 Actual flux of 1329 sources: 1.528777753275981e-08 === zmin = 4 === Expected flux: 1.44e-08 Actual flux of 1329 sources: 5.704090191660857e-10

The actual flux will vary randomly but is usually between 1e-8 and 2e-8 for zmin=-0.0005 (comparable to the expected flux normalization) while it is between 5.5e-10 and 6e-10 for zmin=4 (i.e. more than 20 times smaller than the expected flux normalization). The number of sources is constant across runs.

I would have expected one of two things:

  1. The flux normalization describes the flux from sources in the selected redshift range, between zmin and zmax. (This would imply that the actual flux should always be close to the flux normalization.)
  2. The flux normalization describes the flux integrated over all redshifts (starting at 0.0), but the code outputs only the fraction of sources that are between zmin and zmax. (This would imply that selecting a smaller z range should result in fewer sources being generated.)

Neither option appears to be the case. Am I misunderstanding something or is this a bug?

JostMigenda commented 3 years ago

To add to this: When I vary zmax instead of zmin, the number of sources does change as I would expect in the second case. So it looks like number 2 is the correct option and there is simply a bug related to zmin?

ChrisCFTung commented 3 years ago

Hi @JostMigenda,

Sorry for the late reply. Actually zmin was not supposed to be an option for the user. The reason is that the neutrino flux generated depends on the local density of the source, so the minimum distance to the source can not be at zmin. It is therefore a bug.

I am working on an update that will remove this option.

ChrisCFTung commented 3 years ago

zmin has been removed in #65