Add unpolarized unbinned source injector capability [Yong2Sheng's]#499
Open
israelmcmc wants to merge 1 commit intocositools:developfrom
Open
Add unpolarized unbinned source injector capability [Yong2Sheng's]#499israelmcmc wants to merge 1 commit intocositools:developfrom
israelmcmc wants to merge 1 commit intocositools:developfrom
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Contributor
|
I will add the unit tests after the changes have been reviewed and approved. I’d like to avoid adding them too early, since they may need to be updated if the code changes during review. |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm bringing @Yong2Sheng from my fork to develop, now that the interfaces branch is merged.
Summary
This PR introduces an initial implementation for unpolarized unbinned continuum point source injector in the spacecraft frame. It follows the existing line injector workflow, but with additional steps to (1) compute the integrated detected rate across an energy band and (2) sample detected photon energies across that band.
Compute incident photons and simulate events
1) Define a continuum spectrum (differential photon flux)
A power-law spectrum is used as the working example in the tutorial:
where$K$ is the normalization (differential flux at the pivot energy $\mathrm{piv}$ ).
2) Convolve the spectrum with effective area
The detected count-rate density is
3) Integrate$w(E)$ to get the total detected rate and total counts
The integrated detected photon rate is
In practice, the spectrum might not be analytical. And the effective area is also usually not analytical as well. So we do not perform the integral directly. Instead, we will use a very fine energy grid to obtain the integral by trapezoids.
The expected detected counts is
and the realized detected counts are sampled as
4) Build an inverse-CDF sampler to draw detected photon energies
scipy.interpolate.interp1dwith linear interpolation.5) Simulate each sampled energy
Feed the sampled photon energies (and their multiplicities, although they should show up only once) into
UnpolarizedIdealComptonIRF.random_events(...)to produce the event list.Implementation notes
RandomEventDataFromContinuumInSCFrameis responsible for continuum injection.@cached_property:energy_gridunpolarized_aeffunpol_countsincident_photonsunpol_counts) bookkeeping:UnpolCountsSummary(rate_density, rate, total_expected_counts)What is not included yet