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

Add basic facilities for 3D background irfs #276

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

Conversation

Tobychev
Copy link
Contributor

Add functions for making a 3D background using square bins, this requires that the event tables have the two columns reco_fov_lat and reco_fov_lon.

Copy link

codecov bot commented Jan 16, 2024

Codecov Report

Attention: Patch coverage is 15.62500% with 27 lines in your changes missing coverage. Please review.

Project coverage is 94.83%. Comparing base (cb92eef) to head (7c6d158).
Report is 11 commits behind head on main.

Files Patch % Lines
pyirf/io/gadf.py 12.50% 14 Missing ⚠️
pyirf/irf/background.py 13.33% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #276      +/-   ##
==========================================
- Coverage   95.60%   94.83%   -0.78%     
==========================================
  Files          62       62              
  Lines        3278     3308      +30     
==========================================
+ Hits         3134     3137       +3     
- Misses        144      171      +27     

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

def create_background_3d_hdu(
background_3d,
reco_energy_bins,
fov_offset_bins,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have fov_lon_bins / fov_lat_bins

background_3d,
reco_energy_bins,
fov_offset_bins,
extname="BACKGROUND",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to define the alignment

header["HDUCLAS2"] = "BKG"
header["HDUCLAS3"] = "FULL-ENCLOSURE"
header["HDUCLAS4"] = "BKG_2D"
header["FOVALIGN"] = "ALTAZ"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an argument, not hard-coded

@maxnoe maxnoe mentioned this pull request Feb 19, 2024
per_energy = (hist.T / bin_width_energy).T

# divide by solid angle in each fov bin and the observation time
bin_solid_angle = np.diff(fov_offset_bins)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The solid angle of the bins is not just the difference of the bin edges.

@luca-dib implemented the proper code here: #281 but it's not yet a proper function there but just computed inline

@Tobychev
Copy link
Contributor Author

Tobychev commented Nov 8, 2024

@maxnoe Pushed the requested fixes, added a test. Latest version now depends on the rectangle_solid_angle that only exists in #281 for the moment.

@maxnoe
Copy link
Member

maxnoe commented Nov 8, 2024

@Tobychev #281 was merged yesterday

pyirf/io/gadf.py Outdated Show resolved Hide resolved
pyirf/io/gadf.py Outdated Show resolved Hide resolved
pyirf/irf/background.py Outdated Show resolved Hide resolved
pyirf/irf/background.py Outdated Show resolved Hide resolved
pyirf/irf/background.py Outdated Show resolved Hide resolved
pyirf/irf/background.py Outdated Show resolved Hide resolved
LukasBeiske and others added 28 commits November 8, 2024 18:33
…ensions

The different methods use binning in different coordinate systems
 - effective_area_3D_polar uses a polar coordinate system with radial FOV offset and azimuthal FOV position angle bins
 - effective_area_3D_nominal uses a nominal coordinate system with FOV longitude and FOV latitude bins
These calculate the number of showers in each bin for different coordinate systems
 - calculate_n_showers_3D_polar uses a polar coordinate system with radial FOV offset bins and azimuthal FOV position angle bins
 - calculate_n_showers_3D_nominal uses a nominal coordinate system with FOV longitude and latitude bins
Remove stale debugging code

Add news fragment

Update energy_dispersion_to_migration

- divide by the migration bin widths before resampling
- minor style and format changes

Fix pdf conversion to probability,  remove final norm
Simplify normalization code for migra matrix
Fix test_energy_dispersion_to_migration
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants