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

Adding flux weighting option to the effective_area function of Weighter objects #47

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

jsaffer
Copy link

@jsaffer jsaffer commented Dec 12, 2024

Instead of weighting to a 1 GeV⁻¹ m⁻² sr⁻¹ flux, one can now chose to use any of the cosmic ray flux models available in simweights as well in order take into account the spectral shape and varying mass composition inside energy bins. The scalar flux is still possible and the default (1e-4).

The plots demonstrate the slight correction of effective area resulting from weighting with three common CR flux models vs the default (scalar flux) for

  • proton and iron together
  • proton primaries only
  • iron primaries only

simweights_weighting_demo_1
simweights_weighting_demo_2

…er objects

Instead of weighting to a 1 GeV⁻¹ m⁻² sr⁻¹ flux, one can now chose to use any of the cosmic ray flux models as well in order take into account the spectral shape and varying mass composition inside energy bins. The scalar flux is still possible and the default (1e-4).
@jsaffer jsaffer added enhancement New feature or request help wanted Extra attention is needed python Pull requests that update Python code labels Dec 12, 2024
@jsaffer jsaffer requested a review from kjmeagher December 12, 2024 18:50
Copy link

github-actions bot commented Dec 12, 2024

Test Results

  6 files  ±0    6 suites  ±0   2m 25s ⏱️ +4s
104 tests ±0  103 ✅ ±0  1 💤 ±0  0 ❌ ±0 
624 runs  ±0  618 ✅ ±0  6 💤 ±0  0 ❌ ±0 

Results for commit 4ad2c98. ± Comparison against base commit 23e4d3e.

♻️ This comment has been updated with latest results.

The new optional flux argument is now the last in the list of arguments. This way, confusion with the mask argument, which remains in 3rd place, is avoided.
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (23e4d3e) to head (4ad2c98).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #47   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines          799       807    +8     
=========================================
+ Hits           799       807    +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jsaffer and others added 5 commits December 13, 2024 11:53
This should fix C3001 (lambda expression replaced by def function definition), R1728 (using generator for sum of flux components), D417 (added description for flux argument), E731 (lambda -> def), N803 (E -> energy), TRY003 and EM101 (assigned error message to variable), also I changed the ValueError to a TypeError which should be more appropriate
Adding type annotations for flux_func function, and moving the return outside of the it/elif/else condition.
@kjmeagher
Copy link
Member

@jsaffer I cleaned up this commit for you, but you still need to provide unit tests for both the weighted flux and the type error

@jsaffer jsaffer assigned matthiasplum and unassigned kathrawlins Dec 18, 2024
jsaffer and others added 2 commits December 18, 2024 04:10
…r of invalid flux argument and the TypeError of a valid flux argument that is not supported yet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants