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

Effective Area 3D #281

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

Conversation

luca-dib
Copy link

Adds two methods of calculating the effective area in bins of energy and two spacial dimensions. These methods differ in the coordinate frame used for the spacial dimensions.

  • calculate_effective_area_3d_polar uses a polar coordinate system with FOV pointing position offset and position angle coordinates
  • calculate_effective_area_3d_nominal uses a quasi-cartesian coordinate system with FOV longitude and latitude coordinates centred on the pointing position

Also adds respective functions to calculate the number of showers expected in the 3D bins from simulation info to the SimulatedEventsInfo class (calculate_n_showers_3d_polar, calculate_n_showers_3d_nominal), as well as a utility function to calculate the position angle w.r.t. the pointing from an event table (calculate_source_fov_position_angle).

Luca Di Bella and others added 9 commits February 12, 2024 17:35
…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
pyirf/irf/effective_area.py Outdated Show resolved Hide resolved
pyirf/irf/effective_area.py Outdated Show resolved Hide resolved
pyirf/irf/effective_area.py Outdated Show resolved Hide resolved
pyirf/simulations.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 15, 2024

Codecov Report

Attention: Patch coverage is 30.00000% with 21 lines in your changes are missing coverage. Please review.

Project coverage is 95.01%. Comparing base (c7db045) to head (34ecab9).
Report is 9 commits behind head on main.

Current head 34ecab9 differs from pull request most recent head af76243

Please upload reports for the commit af76243 to get more accurate results.

Files Patch % Lines
pyirf/simulations.py 31.25% 11 Missing ⚠️
pyirf/irf/effective_area.py 20.00% 8 Missing ⚠️
pyirf/utils.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #281      +/-   ##
==========================================
- Coverage   95.60%   95.01%   -0.60%     
==========================================
  Files          62       62              
  Lines        3278     3308      +30     
==========================================
+ Hits         3134     3143       +9     
- Misses        144      165      +21     

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

pyirf/simulations.py Outdated Show resolved Hide resolved
pyirf/simulations.py Outdated Show resolved Hide resolved
pyirf/simulations.py Outdated Show resolved Hide resolved
in the sky.
"""
phi = position_angle(
events["pointing_az"],
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure this definition matches the defintion in GADF given here:
https://gamma-astro-data-formats.readthedocs.io/en/v0.3/general/coordinates.html#field-of-view

Copy link
Member

Choose a reason for hiding this comment

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

Please add tests for that

fov_offset_bins: astropy.units.Quantity[angle]
The field of view radial bin edges in which to calculate effective area.
fov_position_angle_bins: astropy.units.Quantity[radian]
The field of view azimuthal bin edges in which to calculate effective area.
Copy link

@kosack kosack Feb 16, 2024

Choose a reason for hiding this comment

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

not sure if this could lead to confusion, but a 2D azimuthal coordinate and position angle are not quite the same: the polar azimuth starts on the positive X-axis and goes counter-clockwise, while position angle starts on the positive Y-axis and goes clockwise, so there is a 90 deg phase shift and different direction. Perhaps just to avoid this, say "Field-of-view azimuthal (from Y-axis, toward positive x) bin edges...". Probably this should be shown as a figure somewhere in the general PyIRF documentation...

Copy link
Member

Choose a reason for hiding this comment

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

This is going into the same direction as the comment above about being clear how we define these coordinate systems and adding tests for the cases spelled out by GADF.

One confusing thing here is that the position angle is defined relative to the original coordinate system axes (AltAz or RaDec) but the FoV lon has the opposite direction to the original lon. Which I think makes the polar angle go counter-clockwise when looking at in a common plot of field of view coordinates where the cartesian like axes are FoV lon/lat...

Copy link
Author

Choose a reason for hiding this comment

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

If I understand it correctly the GADF FOV position angle definition is exactly the same as the usual definition of the azimuthal angle in polar coordinates, right? (Angle increasing counter-clockwise)
So following this definition there shouldn't technically be a difference between the two, although I understand that just calling it the azimuthal angle here might still cause confusion.

Since we are following the GADF conventions anyways, would it be agreeable to just change "field of view azimuthal bin edges" to "field of view position angle bin edges" and maybe showing a figure somewhere to clarify as suggested?

pyirf/simulations.py Outdated Show resolved Hide resolved
pyirf/coordinates.py Outdated Show resolved Hide resolved
pyirf/simulations.py Outdated Show resolved Hide resolved
pyirf/coordinates.py Outdated Show resolved Hide resolved
pyirf/simulations.py Outdated Show resolved Hide resolved
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.

4 participants