diff --git a/README.md b/README.md index 4e5e002..215824c 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ ZodiPy is installed using `pip install zodipy`. ## Dependencies ZodiPy supports all Python versions >= 3.9, and has the following dependencies: - [Astropy](https://www.astropy.org/) (>=5.0.1) +- [Astropy-healpix](https://astropy-healpix.readthedocs.io/en/latest/) - [NumPy](https://numpy.org/) -- [healpy](https://healpy.readthedocs.io/en/latest/) - [jplephem](https://pypi.org/project/jplephem/) - [SciPy](https://scipy.org/) @@ -67,6 +67,7 @@ Contributing developers will need to download the following additional dependenc - pytest - pytest-cov - hypothesis +- healpy - coverage - ruff - mypy diff --git a/docs/install.md b/docs/install.md index 179e612..3a405f4 100644 --- a/docs/install.md +++ b/docs/install.md @@ -13,7 +13,7 @@ pip install zodipy ZodiPy has the following dependencies (these are automatically downloaded alongside ZodiPy): - [Astropy](https://www.astropy.org) (>= 5.0.1) +- [Astropy-healpix](https://astropy-healpix.readthedocs.io/en/latest/) - [NumPy](https://numpy.org) -- [healpy](https://healpy.readthedocs.io/en/latest/) - [jplehem](https://pypi.org/project/jplephem/) - [SciPy](https://scipy.org/) diff --git a/zodipy/_line_of_sight.py b/zodipy/_line_of_sight.py index 7f55a4a..19efb27 100644 --- a/zodipy/_line_of_sight.py +++ b/zodipy/_line_of_sight.py @@ -11,8 +11,9 @@ if TYPE_CHECKING: import numpy.typing as npt + from zodipy._types import Float -DIRBE_CUTOFFS: dict[ComponentLabel, tuple[float | np.float64, float]] = { +DIRBE_CUTOFFS: dict[ComponentLabel, tuple[Float, Float]] = { ComponentLabel.CLOUD: (R_0, R_JUPITER), ComponentLabel.BAND1: (R_0, R_JUPITER), ComponentLabel.BAND2: (R_0, R_JUPITER), @@ -21,7 +22,7 @@ ComponentLabel.FEATURE: (R_EARTH - 0.2, R_EARTH + 0.2), } -RRM_CUTOFFS: dict[ComponentLabel, tuple[float | np.float64, float]] = { +RRM_CUTOFFS: dict[ComponentLabel, tuple[Float, Float]] = { ComponentLabel.FAN: (R_0, RRM[ComponentLabel.FAN].R_outer), # type: ignore ComponentLabel.INNER_NARROW_BAND: ( RRM[ComponentLabel.INNER_NARROW_BAND].R_inner, # type: ignore @@ -78,7 +79,7 @@ def get_sphere_intersection( return np.maximum(q, c / q) -def get_line_of_sight_start_and_stop_distances( +def get_line_of_sight_range( components: Iterable[ComponentLabel], unit_vectors: npt.NDArray[np.float64], obs_pos: npt.NDArray[np.float64], diff --git a/zodipy/_types.py b/zodipy/_types.py index 61014ff..c887a5a 100644 --- a/zodipy/_types.py +++ b/zodipy/_types.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import Sequence, Union import astropy.units as u @@ -8,3 +10,4 @@ SkyAngles = Union[u.Quantity[u.deg], u.Quantity[u.rad]] FrequencyOrWavelength = Union[u.Quantity[u.Hz], u.Quantity[u.m]] ParameterDict = dict +Float = Union[float, np.floating] diff --git a/zodipy/zodipy.py b/zodipy/zodipy.py index 52d2efb..3474fa4 100644 --- a/zodipy/zodipy.py +++ b/zodipy/zodipy.py @@ -18,7 +18,7 @@ from zodipy._interpolate_source import SOURCE_PARAMS_MAPPING from zodipy._ipd_comps import ComponentLabel from zodipy._ipd_dens_funcs import construct_density_partials_comps -from zodipy._line_of_sight import get_line_of_sight_start_and_stop_distances +from zodipy._line_of_sight import get_line_of_sight_range from zodipy._validators import get_validated_ang from zodipy.model_registry import model_registry @@ -136,9 +136,9 @@ def get_emission_skycoord( must be strictly increasing. weights: Bandpass weights corresponding the the frequencies in `freq`. The weights are assumed to be given in spectral radiance units (Jy/sr). - obs_pos: The heliocentric ecliptic position of the observer in AU, or a string - representing an observer in the `astropy.coordinates.solar_system_ephemeris`. - This should correspond to a single position. Defaults to 'earth'. + obs_pos: The heliocentric ecliptic position of the observer, or a string representing + an observer in the `astropy.coordinates.solar_system_ephemeris`. This should + correspond to a single position. Defaults to 'earth'. return_comps: If True, the emission is returned component-wise. Defaults to False. Returns: @@ -151,7 +151,10 @@ def get_emission_skycoord( axis=1, ) coord = coords.SkyCoord( - unique_lon * units.deg, unique_lat * units.deg, frame=coord.frame, obstime=coord.obstime + unique_lon * units.deg, + unique_lat * units.deg, + frame=coord.frame, + obstime=coord.obstime, ) return self._compute_emission( @@ -195,9 +198,9 @@ def get_emission_ang( a bandpass over which to evaluate the zodiacal emission. The frequencies must be strictly increasing. obs_time: Time of observation. This should be a single observational time. - obs_pos: The heliocentric ecliptic position of the observer in AU, or a string - representing an observer in the `astropy.coordinates.solar_system_ephemeris`. - This should correspond to a single position. Defaults to 'earth'. + obs_pos: The heliocentric ecliptic position of the observer, or a string representing + an observer in the `astropy.coordinates.solar_system_ephemeris`. This should + correspond to a single position. Defaults to 'earth'. coord_in: Coordinate frame of the input pointing. Assumes 'E' (ecliptic coordinates) by default. weights: Bandpass weights corresponding the the frequencies in `freq`. The weights @@ -248,9 +251,9 @@ def get_emission_pix( a bandpass over which to evaluate the zodiacal emission. The frequencies must be strictly increasing. obs_time: Time of observation. This should be a single observational time. - obs_pos: The heliocentric ecliptic position of the observer in AU, or a string - representing an observer in the `astropy.coordinates.solar_system_ephemeris`. - This should correspond to a single position. Defaults to 'earth'. + obs_pos: The heliocentric ecliptic position of the observer, or a string representing + an observer in the `astropy.coordinates.solar_system_ephemeris`. This should + correspond to a single position. Defaults to 'earth'. coord_in: Coordinate frame of the input pointing. Assumes 'E' (ecliptic coordinates) by default. weights: Bandpass weights corresponding the the frequencies in `freq`. The weights @@ -302,9 +305,9 @@ def get_binned_emission_skycoord( must be strictly increasing. weights: Bandpass weights corresponding the the frequencies in `freq`. The weights are assumed to be given in spectral radiance units (Jy/sr). - obs_pos: The heliocentric ecliptic position of the observer in AU, or a string - representing an observer in the `astropy.coordinates.solar_system_ephemeris`. - This should correspond to a single position. Defaults to 'earth'. + obs_pos: The heliocentric ecliptic position of the observer, or a string representing + an observer in the `astropy.coordinates.solar_system_ephemeris`. This should + correspond to a single position. Defaults to 'earth'. return_comps: If True, the emission is returned component-wise. Defaults to False. solar_cut: Cutoff angle from the sun. The emission for all the pointing with angular distance between the sun smaller than `solar_cut` are masked. Defaults to `None`. @@ -319,7 +322,10 @@ def get_binned_emission_skycoord( axis=1, ) coord = coords.SkyCoord( - unique_lon * units.deg, unique_lat * units.deg, frame=coord.frame, obstime=coord.obstime + unique_lon * units.deg, + unique_lat * units.deg, + frame=coord.frame, + obstime=coord.obstime, ) healpix = hp.HEALPix(nside, order="ring", frame=coord.frame) return self._compute_emission( @@ -343,7 +349,7 @@ def get_binned_emission_ang( nside: int, freq: units.Quantity, obs_time: time.Time, - obs_pos: units.Quantity[units.AU] | str = "earth", + obs_pos: units.Quantity | str = "earth", coord_in: Literal["E", "G", "C"] = "E", weights: npt.ArrayLike | None = None, return_comps: bool = False, @@ -367,9 +373,9 @@ def get_binned_emission_ang( a bandpass over which to evaluate the zodiacal emission. The frequencies must be strictly increasing. obs_time: Time of observation. This should be a single observational time. - obs_pos: The heliocentric ecliptic position of the observer in AU, or a string - representing an observer in the `astropy.coordinates.solar_system_ephemeris`. - This should correspond to a single position. Defaults to 'earth'. + obs_pos: The heliocentric ecliptic position of the observer, or a string representing + an observer in the `astropy.coordinates.solar_system_ephemeris`. This should + correspond to a single position. Defaults to 'earth'. coord_in: Coordinate frame of the input pointing. Assumes 'E' (ecliptic coordinates) by default. weights: Bandpass weights corresponding the the frequencies in `freq`. The weights @@ -432,9 +438,9 @@ def get_binned_emission_pix( a bandpass over which to evaluate the zodiacal emission. The frequencies must be strictly increasing. obs_time: Time of observation. This should be a single observational time. - obs_pos: The heliocentric ecliptic position of the observer in AU, or a string - representing an observer in the `astropy.coordinates.solar_system_ephemeris`. - This should correspond to a single position. Defaults to 'earth'. + obs_pos: The heliocentric ecliptic position of the observer, or a string representing + an observer in the `astropy.coordinates.solar_system_ephemeris`. This should + correspond to a single position. Defaults to 'earth'. coord_in: Coordinate frame of the input pointing. Assumes 'E' (ecliptic coordinates) by default. weights: Bandpass weights corresponding the the frequencies in `freq`. The weights @@ -499,7 +505,7 @@ def _compute_emission( # Get the integration limits for each zodiacal component (which may be # different or the same depending on the model) along all line of sights. - start, stop = get_line_of_sight_start_and_stop_distances( + start, stop = get_line_of_sight_range( components=self._ipd_model.comps.keys(), unit_vectors=unit_vectors, obs_pos=obs_skycoord.cartesian.xyz.value,