Skip to content

Commit

Permalink
Implement warning for very large zenith angles
Browse files Browse the repository at this point in the history
  • Loading branch information
gschwefer committed Apr 5, 2024
1 parent 6cc6b50 commit 5b95eb2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/ctapipe/atmosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

import abc
import warnings
from dataclasses import dataclass
from functools import partial
from typing import Dict
Expand All @@ -34,6 +35,13 @@
DENSITY_UNIT = u.g / u.cm**3


class SlantDepthZenithRangeWarning(UserWarning):
"""
Issued when the zenith angle of an event is beyond
the range where the slant depth computation is correct (approx. 70 deg)
"""


class AtmosphereDensityProfile(abc.ABC):
"""
Base class for models of atmosphere density.
Expand Down Expand Up @@ -83,8 +91,9 @@ def slant_depth_from_height(
r"""Line-of-sight integral from height to infinity, along
the direction specified by the zenith angle. This is sometimes called
the *slant depth*. The atmosphere here is assumed to be Cartesian, the
curvature of the Earth is not taken into account. Inverse of
height_from_slant_depth function.
curvature of the Earth is not taken into account. This approximation breaks down
for large zenith angles (>70 deg), in which case this function
does not give correct results. Inverse of height_from_slant_depth function.
.. math:: X(h, \Psi) = \int_{h}^{\infty} \rho(h') dh' / \cos{\Psi}
Expand All @@ -99,6 +108,12 @@ def slant_depth_from_height(
"""

if zenith_angle > 70 * u.deg:
warnings.warn(
"Zenith angle too high for accurate slant depth",
SlantDepthZenithRangeWarning,
)

return (self.integral(height) / np.cos(zenith_angle)).to(output_units)

def height_from_slant_depth(
Expand Down

0 comments on commit 5b95eb2

Please sign in to comment.