From 96fcd943f5ddb231f2d49293f2b2bf17be8c5230 Mon Sep 17 00:00:00 2001 From: Metin San Date: Tue, 10 Jan 2023 15:53:27 +0100 Subject: [PATCH] Add ruff as a dev tool --- poetry.lock | 11 +++- pyproject.toml | 20 +++++++- zodipy/_bandpass.py | 14 ++---- zodipy/_contour.py | 3 +- zodipy/_emission.py | 2 - zodipy/_interpolate_source.py | 5 +- zodipy/_ipd_dens_funcs.py | 95 ++++++++++++++--------------------- zodipy/_line_of_sight.py | 7 ++- zodipy/_sky_coords.py | 6 +-- zodipy/_source_funcs.py | 17 ++----- zodipy/_unit_vectors.py | 2 - zodipy/_validators.py | 4 -- zodipy/comps.py | 34 +++++++------ zodipy/zodipy.py | 15 +----- 14 files changed, 105 insertions(+), 130 deletions(-) diff --git a/poetry.lock b/poetry.lock index 7658ebd..cf6062a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -765,6 +765,14 @@ urllib3 = ">=1.21.1,<1.27" socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"] +[[package]] +name = "ruff" +version = "0.0.217" +description = "An extremely fast Python linter, written in Rust." +category = "dev" +optional = false +python-versions = ">=3.7" + [[package]] name = "scipy" version = "1.9.3" @@ -916,7 +924,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "flake8 (<5)", "pytest-co [metadata] lock-version = "1.1" python-versions = ">=3.8" -content-hash = "bf28e094c4b2fd19361726d6cc4a61f6a5aa5dc8246b5ff07d2e02763a6b8dbc" +content-hash = "d4ba77eab026fd7cc07def236882da8a68fecd948a0a854da3bff4497481ef68" [metadata.files] astropy = [] @@ -1167,6 +1175,7 @@ requests = [ {file = "requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"}, {file = "requests-2.27.1.tar.gz", hash = "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61"}, ] +ruff = [] scipy = [] setuptools-scm = [] six = [ diff --git a/pyproject.toml b/pyproject.toml index 624e641..6622686 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,7 @@ pytest-cov = "^3.0.0" mkdocs-material = "^9.0.1" mkdocstrings = "^0.19.1" mkdocstrings-python = "^0.8.2" +ruff = "^0.0.217" [build-system] requires = ["poetry-core>=1.0.0"] @@ -50,4 +51,21 @@ overrides = [ filterwarnings = [ "ignore::UserWarning", "ignore:.*overflow encountered in expm1.*", -] \ No newline at end of file +] + +[tool.isort] +profile = "black" + +[tool.ruff] +select = ["F", "D", "E", "W", "C", "B", "I001"] +line-length = 100 +ignore = [ + "B905", + "D100", + "D107", + "D104", + "D105", +] + +[tool.ruff.pydocstyle] +convention = "google" \ No newline at end of file diff --git a/zodipy/_bandpass.py b/zodipy/_bandpass.py index 86d65ba..261b819 100644 --- a/zodipy/_bandpass.py +++ b/zodipy/_bandpass.py @@ -7,15 +7,15 @@ import numpy as np import numpy.typing as npt -from zodipy._ipd_model import InterplanetaryDustModel -from zodipy._validators import validate_and_normalize_weights, validate_frequencies -from zodipy._source_funcs import get_blackbody_emission from zodipy._constants import ( - N_INTERPOLATION_POINTS, - MIN_INTERPOLATION_GRID_TEMPERATURE, MAX_INTERPOLATION_GRID_TEMPERATURE, + MIN_INTERPOLATION_GRID_TEMPERATURE, + N_INTERPOLATION_POINTS, ) +from zodipy._ipd_model import InterplanetaryDustModel +from zodipy._source_funcs import get_blackbody_emission from zodipy._types import FrequencyOrWavelength +from zodipy._validators import validate_and_normalize_weights, validate_frequencies @dataclass @@ -25,12 +25,10 @@ class Bandpass: def integrate(self, quantity: npt.NDArray[np.float64]) -> npt.NDArray[np.float64]: """Integrate a quantity over the bandpass.""" - return np.trapz(self.weights * quantity, self.frequencies.value, axis=-1) def switch_convention(self) -> None: """Switched the bandpass from frequency to wavelength or vice versa.""" - self.frequencies = self.frequencies.to( u.micron if self.frequencies.unit.is_equivalent(u.Hz) else u.Hz, equivalencies=u.spectral(), @@ -48,7 +46,6 @@ def validate_and_get_bandpass( extrapolate: bool, ) -> Bandpass: """Validate user inputted bandpass and return a Bandpass object.""" - validate_frequencies(freq, model, extrapolate) normalized_weights = validate_and_normalize_weights(weights, freq) @@ -62,7 +59,6 @@ def get_bandpass_interpolation_table( max_temp: float = MAX_INTERPOLATION_GRID_TEMPERATURE, ) -> npt.NDArray[np.float64]: """Pre-compute the bandpass integrated blackbody emission for a grid of temperatures.""" - # Prepare bandpass to be integrated in power units and in frequency convention. if not bandpass.frequencies.unit.is_equivalent(u.Hz): bandpass.switch_convention() diff --git a/zodipy/_contour.py b/zodipy/_contour.py index b406e0a..f6c6dff 100644 --- a/zodipy/_contour.py +++ b/zodipy/_contour.py @@ -28,12 +28,11 @@ def tabulate_density( earth_pos Position of the Earth in AU. - Returns + Returns: ------- density_grid The tabulated zodiacal component densities. """ - ipd_model = model_registry.get_model(model) if not isinstance(grid, np.ndarray): diff --git a/zodipy/_emission.py b/zodipy/_emission.py index 61264cb..02466a3 100644 --- a/zodipy/_emission.py +++ b/zodipy/_emission.py @@ -36,7 +36,6 @@ def kelsall( bp_interpolation_table: npt.NDArray[np.float64], ) -> npt.NDArray[np.float64]: """Kelsall uses common line of sight grid from obs to 5.2 AU.""" - # Convert the quadrature range from [-1, 1] to the true ecliptic positions R_los = ((stop - start) / 2) * r + (stop + start) / 2 X_los = R_los * u_los @@ -70,7 +69,6 @@ def rrm( bp_interpolation_table: npt.NDArray[np.float64], ) -> npt.NDArray[np.float64]: """RRM has component specific line of sight grids.""" - # Convert the quadrature range from [-1, 1] to the true ecliptic positions R_los = ((stop - start) / 2) * r + (stop + start) / 2 X_los = R_los * u_los diff --git a/zodipy/_interpolate_source.py b/zodipy/_interpolate_source.py index 16f280c..c34e398 100644 --- a/zodipy/_interpolate_source.py +++ b/zodipy/_interpolate_source.py @@ -9,14 +9,15 @@ from zodipy._bandpass import Bandpass from zodipy._constants import SPECIFIC_INTENSITY_UNITS -from zodipy._ipd_model import RRM, InterplanetaryDustModel, Kelsall from zodipy._ipd_comps import ComponentLabel +from zodipy._ipd_model import RRM, InterplanetaryDustModel, Kelsall InterplanetaryDustModelT = TypeVar( "InterplanetaryDustModelT", bound=InterplanetaryDustModel ) -"""Returns the source parameters for a given bandpass and model. Must match arguments in the emission fns.""" +"""Returns the source parameters for a given bandpass and model. +Must match arguments in the emission fns.""" GetSourceParametersFn = Callable[ [Bandpass, InterplanetaryDustModelT], Dict[Union[ComponentLabel, str], Any] ] diff --git a/zodipy/_ipd_dens_funcs.py b/zodipy/_ipd_dens_funcs.py index 294c37c..6a4be31 100644 --- a/zodipy/_ipd_dens_funcs.py +++ b/zodipy/_ipd_dens_funcs.py @@ -4,6 +4,7 @@ from dataclasses import asdict from functools import partial from typing import Any, Callable, Mapping, Protocol, Sequence + import numpy as np import numpy.typing as npt @@ -13,6 +14,7 @@ Cloud, Comet, Component, + ComponentLabel, Fan, Feature, FeatureRRM, @@ -21,7 +23,6 @@ Ring, RingRRM, ) -from zodipy._ipd_comps import ComponentLabel """The density functions for the different types of components. Common for all of these is that the first argument will be `X_helio` (the line of sight from the observer towards @@ -47,7 +48,6 @@ def compute_cloud_density( gamma: float, ) -> npt.NDArray[np.float64]: """Density of the diffuse cloud (see Eq (6). in K98).""" - X_cloud = X_helio - X_0 R_cloud = np.sqrt(X_cloud[0] ** 2 + X_cloud[1] ** 2 + X_cloud[2] ** 2) @@ -78,7 +78,6 @@ def compute_band_density( delta_r: float, ) -> npt.NDArray[np.float64]: """Density of the dust bands (see Eq. (8) in K98).""" - X_band = X_helio - X_0 R_band = np.sqrt(X_band[0] ** 2 + X_band[1] ** 2 + X_band[2] ** 2) @@ -115,7 +114,6 @@ def compute_ring_density( sigma_z: float, ) -> npt.NDArray[np.float64]: """Density of the circum-solar ring (see Eq. (9) in K98).""" - X_ring = X_helio - X_0 R_ring = np.sqrt(X_ring[0] ** 2 + X_ring[1] ** 2 + X_ring[2] ** 2) @@ -148,7 +146,6 @@ def compute_feature_density( sigma_theta_rad: float, ) -> npt.NDArray[np.float64]: """Density of the Earth-trailing feature (see Eq. (9) in K98).""" - X_feature = X_helio - X_0 R_feature = np.sqrt(X_feature[0] ** 2 + X_feature[1] ** 2 + X_feature[2] ** 2) @@ -190,7 +187,6 @@ def compute_fan_density( # * R_outer: float, ) -> npt.NDArray[np.float64]: """Density of the fan (see Eq (3). in RRM).""" - X_fan = X_helio - X_0 R_fan = np.sqrt(X_fan[0] ** 2 + X_fan[1] ** 2 + X_fan[2] ** 2) @@ -228,7 +224,6 @@ def compute_comet_density( R_outer: float, ) -> npt.NDArray[np.float64]: """Density of the fan (see Eq (3). in RRM).""" - X_comet = X_helio - X_0 R_comet = np.sqrt(X_comet[0] ** 2 + X_comet[1] ** 2 + X_comet[2] ** 2) @@ -272,7 +267,6 @@ def compute_narrow_band_density( R_outer: float, ) -> npt.NDArray[np.float64]: """Density of the fan (see Eq (4). in RRM).""" - X_nb = X_helio - X_0 R_nb = np.sqrt(X_nb[0] ** 2 + X_nb[1] ** 2 + X_nb[2] ** 2) @@ -314,7 +308,6 @@ def compute_broad_band_density( R_outer: float, ) -> npt.NDArray[np.float64]: """Density of the fan (see Eq (5). in RRM).""" - X_bb = X_helio - X_0 R_bb = np.sqrt(X_bb[0] ** 2 + X_bb[1] ** 2 + X_bb[2] ** 2) @@ -350,22 +343,17 @@ def compute_ring_density_rmm( sigma_z: float, A: float, ) -> npt.NDArray[np.float64]: - return ( - A - * compute_ring_density( - X_helio=X_helio, - X_0=X_0, - sin_Omega_rad=sin_Omega_rad, - cos_Omega_rad=cos_Omega_rad, - sin_i_rad=sin_i_rad, - cos_i_rad=cos_i_rad, - n_0=1, - R=R, - sigma_r=sigma_r, - sigma_z=sigma_z, - ) - # * 1e-6 - # / (1 * u.cm).to_value(u.AU) + return A * compute_ring_density( + X_helio=X_helio, + X_0=X_0, + sin_Omega_rad=sin_Omega_rad, + cos_Omega_rad=cos_Omega_rad, + sin_i_rad=sin_i_rad, + cos_i_rad=cos_i_rad, + n_0=n_0, + R=R, + sigma_r=sigma_r, + sigma_z=sigma_z, ) @@ -385,25 +373,20 @@ def compute_feature_density_rmm( sigma_theta_rad: float, A: float, ) -> npt.NDArray[np.float64]: - return ( - A - * compute_feature_density( - X_helio=X_helio, - X_0=X_0, - sin_Omega_rad=sin_Omega_rad, - cos_Omega_rad=cos_Omega_rad, - sin_i_rad=sin_i_rad, - cos_i_rad=cos_i_rad, - n_0=1, - R=R, - sigma_r=sigma_r, - sigma_z=sigma_z, - X_earth=X_earth, - sigma_theta_rad=sigma_theta_rad, - theta_rad=theta_rad, - ) - # * 1e-6 - # / (1 * u.cm).to_value(u.AU) + return A * compute_feature_density( + X_helio=X_helio, + X_0=X_0, + sin_Omega_rad=sin_Omega_rad, + cos_Omega_rad=cos_Omega_rad, + sin_i_rad=sin_i_rad, + cos_i_rad=cos_i_rad, + n_0=n_0, + R=R, + sigma_r=sigma_r, + sigma_z=sigma_z, + X_earth=X_earth, + sigma_theta_rad=sigma_theta_rad, + theta_rad=theta_rad, ) @@ -432,13 +415,12 @@ def construct_density_partials( comps: Sequence[Component], dynamic_params: dict[str, Any], ) -> tuple[ComponentDensityFn, ...]: - """ - Return a tuple of the density expressions above which has been prepopulated with model and - configuration parameters, leaving only the `X_helio` argument to be supplied. + """Return density partials for the components. + Return a tuple of the density expressions above which has been prepopulated with + model and configuration parameters, leaving only the `X_helio` argument to be supplied. Raises exception for incorrectly defined components or component density functions. """ - partial_density_funcs: list[ComponentDensityFn] = [] for comp in comps: comp_dict = asdict(comp) @@ -446,10 +428,10 @@ def construct_density_partials( residual_params = [key for key in func_params if key not in comp_dict.keys()] try: residual_params.remove("X_helio") - except ValueError: + except ValueError as err: raise ValueError( "X_helio must be be the first argument to the density function of a component." - ) + ) from err if residual_params: if residual_params - dynamic_params.keys(): @@ -474,13 +456,12 @@ def construct_density_partials_comps( comps: Mapping[ComponentLabel, Component], dynamic_params: dict[str, Any], ) -> dict[ComponentLabel, ComponentDensityFn]: - """ - Return a tuple of the density expressions above which has been prepopulated with model and - configuration parameters, leaving only the `X_helio` argument to be supplied. + """Construct density partials for components. - Raises exception for incorrectly defined components or component density functions. + Return a tuple of the density expressions above which has been prepopulated with model and + configuration parameters, leaving only the `X_helio` argument to be supplied. Raises exception + for incorrectly defined components or component density functions. """ - partial_density_funcs: dict[ComponentLabel, ComponentDensityFn] = {} for comp_label, comp in comps.items(): comp_dict = asdict(comp) @@ -488,10 +469,10 @@ def construct_density_partials_comps( residual_params = [key for key in func_params if key not in comp_dict.keys()] try: residual_params.remove("X_helio") - except ValueError: + except ValueError as err: raise ValueError( "X_helio must be be the first argument to the density function of a component." - ) + ) from err if residual_params: if residual_params - dynamic_params.keys(): diff --git a/zodipy/_line_of_sight.py b/zodipy/_line_of_sight.py index 16771c3..3dc6835 100644 --- a/zodipy/_line_of_sight.py +++ b/zodipy/_line_of_sight.py @@ -5,8 +5,7 @@ import numpy as np import numpy.typing as npt -from zodipy._constants import R_EARTH, R_JUPITER, R_KUIPER_BELT, R_0 - +from zodipy._constants import R_0, R_EARTH, R_JUPITER, R_KUIPER_BELT from zodipy._ipd_comps import ComponentLabel from zodipy.comps import RRM @@ -51,11 +50,11 @@ def get_sphere_intersection( unit_vectors: npt.NDArray[np.float64], cutoff: float | np.float64, ) -> npt.NDArray[np.float64]: - """ + """Get RMAX per pixel. + Given the observer position, return distance from the observer to the intersection between the line of sights and a heliocentric sphere with radius cutoff. """ - x, y, z = obs_pos.flatten() r_obs = np.sqrt(x**2 + y**2 + z**2) diff --git a/zodipy/_sky_coords.py b/zodipy/_sky_coords.py index d05a1e3..cf97aae 100644 --- a/zodipy/_sky_coords.py +++ b/zodipy/_sky_coords.py @@ -13,8 +13,7 @@ def get_obs_and_earth_positions( obs: str, obs_time: Time, obs_pos: Union[u.Quantity[u.AU], None] ) -> Tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]: - """Returns the position of the observer and the Earth in broadcastable shapes - (3, `n_pointing`, `n_gauss_quad_degree`). + """Returns the position of the observer and the Earth (3, `n_pointing`, `n_gauss_quad_degree`). The lagrange point SEMB-L2 is not included in any of the current available ephemerides. We implement an approximation to its position, assuming that @@ -35,7 +34,6 @@ def get_obs_and_earth_positions( def _get_earth_position(obs_time: Time) -> u.Quantity[u.AU]: """Returns the position of the Earth given an ephemeris and observation time.""" - earth_skycoordinate = get_body("earth", obs_time) earth_skycoordinate = earth_skycoordinate.transform_to(HeliocentricMeanEcliptic) @@ -46,7 +44,6 @@ def _get_observer_position( obs: str, obs_time: Time, earth_pos: u.Quantity[u.AU] ) -> u.Quantity[u.AU]: """Returns the position of the Earth and the observer.""" - if obs.lower() == "semb-l2": return _get_sun_earth_moon_barycenter(earth_pos) @@ -62,7 +59,6 @@ def _get_sun_earth_moon_barycenter( earth_position: u.Quantity[u.AU], ) -> u.Quantity[u.AU]: """Returns the approximated position of SEMB-L2 given Earth's position.""" - r_earth = np.linalg.norm(earth_position) earth_unit_vector = earth_position / r_earth diff --git a/zodipy/_source_funcs.py b/zodipy/_source_funcs.py index ee283ab..495ac41 100644 --- a/zodipy/_source_funcs.py +++ b/zodipy/_source_funcs.py @@ -21,11 +21,10 @@ def get_blackbody_emission( T Temperature of the blackbody [K]. - Returns + Returns: ------- Blackbody emission [W / m^2 Hz sr]. """ - term1 = (2 * h * freq**3) / c**2 term2 = np.expm1(((h * freq) / (k_B * T))) @@ -46,11 +45,10 @@ def get_dust_grain_temperature( delta Powerlaw index. - Returns + Returns: ------- Dust grain temperature [K]. """ - return T_0 * R**-delta @@ -60,9 +58,7 @@ def get_scattering_angle( X_los: npt.NDArray[np.float64], X_helio: npt.NDArray[np.float64], ) -> npt.NDArray[np.float64]: - """ - Returns the scattering angle between the Sun and a point along the - line of sight. + """Returns the scattering angle between the Sun and a point along the line of sight. Parameters ---------- @@ -75,11 +71,10 @@ def get_scattering_angle( X_helio Heliocentric position of point along the line of sight. - Returns + Returns: ------- Scattering angle. """ - cos_theta = (X_los * X_helio).sum(axis=0) / (R_los * R_helio) cos_theta = np.clip(cos_theta, -1, 1) @@ -98,11 +93,10 @@ def get_phase_function( coeffs Phase function parameters. - Returns + Returns: ------- The Phase funciton. """ - phase_normalization = _get_phase_normalization(C) return phase_normalization * (C[0] + C[1] * Theta + np.exp(C[2] * Theta)) @@ -111,7 +105,6 @@ def get_phase_function( @lru_cache def _get_phase_normalization(C: tuple[float, ...]) -> float: """Returns the analyitcal integral for the phase normalization factor N.""" - int_term1 = 2 * np.pi int_term2 = 2 * C[0] int_term3 = np.pi * C[1] diff --git a/zodipy/_unit_vectors.py b/zodipy/_unit_vectors.py index 139cb15..a60921d 100644 --- a/zodipy/_unit_vectors.py +++ b/zodipy/_unit_vectors.py @@ -12,7 +12,6 @@ def get_unit_vectors_from_pixels( coord_in: str, pixels: Sequence[int] | npt.NDArray[np.int64], nside: int ) -> npt.NDArray[np.float64]: """Returns ecliptic unit vectors from HEALPix pixels representing some pointing.""" - unit_vectors = np.asarray(hp.pix2vec(nside, pixels)) return np.asarray(hp.Rotator(coord=[coord_in, "E"])(unit_vectors)) @@ -25,7 +24,6 @@ def get_unit_vectors_from_ang( lonlat: bool = False, ) -> npt.NDArray[np.float64]: """Returns ecliptic unit vectors from sky angles representing some pointing.""" - unit_vectors = np.asarray(hp.ang2vec(theta, phi, lonlat=lonlat)).transpose() return np.asarray(hp.Rotator(coord=[coord_in, "E"])(unit_vectors)) diff --git a/zodipy/_validators.py b/zodipy/_validators.py index c053ecb..af41015 100644 --- a/zodipy/_validators.py +++ b/zodipy/_validators.py @@ -14,7 +14,6 @@ def validate_frequencies( freq: FrequencyOrWavelength, model: InterplanetaryDustModel, extrapolate: bool ) -> None: """Validate user inputted frequency.""" - if extrapolate: return @@ -44,7 +43,6 @@ def validate_and_normalize_weights( freq: FrequencyOrWavelength, ) -> npt.NDArray[np.float64]: """Validate user inputted weights.""" - if weights is None and freq.size > 1: raise ValueError( "Bandpass weights must be specified if more than one frequency is given." @@ -70,7 +68,6 @@ def validate_ang( theta: SkyAngles, phi: SkyAngles, lonlat: bool ) -> Tuple[SkyAngles, SkyAngles]: """Validate user inputted sky angles.""" - theta = theta.to(u.deg) if lonlat else theta.to(u.rad) phi = phi.to(u.deg) if lonlat else phi.to(u.rad) @@ -84,7 +81,6 @@ def validate_ang( def validate_pixels(pixels: Pixels, nside: int) -> Pixels: """Validate user inputted pixels.""" - if (np.max(pixels) > hp.nside2npix(nside)) or (np.min(pixels) < 0): raise ValueError("invalid pixel number given nside") diff --git a/zodipy/comps.py b/zodipy/comps.py index d0fd37a..6974fe6 100644 --- a/zodipy/comps.py +++ b/zodipy/comps.py @@ -1,5 +1,6 @@ from __future__ import annotations +from zodipy._constants import R_ASTEROID_BELT, R_KUIPER_BELT, R_MARS from zodipy._ipd_comps import ( Band, BroadBand, @@ -15,7 +16,6 @@ Ring, RingRRM, ) -from zodipy._constants import R_MARS, R_KUIPER_BELT, R_ASTEROID_BELT DIRBE: dict[ComponentLabel, Component] = { ComponentLabel.CLOUD: Cloud( @@ -119,7 +119,8 @@ A=0.032, # * #AMP1 gamma=1, # * beta_nb=1.42, # themis - G=0.5, # * + # beta_nb=9.35, # veritas + G=0.12, # * R_inner=R_MARS, # * R_outer=R_ASTEROID_BELT, # * ), @@ -132,7 +133,8 @@ A=0.04, # * #AMP2 gamma=1, # * beta_nb=9.35, # veritas - G=0.12, # * + # beta_nb=1.42, # themis + G=0.6, # * R_inner=R_MARS, # * R_outer=R_ASTEROID_BELT, # * ), @@ -174,25 +176,25 @@ x_0=0.0, y_0=0.0, z_0=0.0, - i=0.48707166006819241, - Omega=22.278979678854448, - n_0=1.8260527826501675e-08, - R=1.0281924326308751, - sigma_r=0.025000000372529030, - sigma_z=0.054068037356978099, + i=0.49, + Omega=22.3, + n_0=1, + R=1.03, + sigma_r=0.025, + sigma_z=0.054, ), ComponentLabel.FEATURE_RRM: FeatureRRM( A=0.065, x_0=0.0, y_0=0.0, z_0=0.0, - i=0.48707166006819241, - Omega=22.278979678854448, - n_0=2.0094267183590947e-08, - R=1.0579182694524214, - sigma_r=0.10287314662396611, - sigma_z=0.091442963768716023, + i=0.49, + Omega=22.3, + n_0=1, + R=1.06, + sigma_r=0.10, + sigma_z=0.091, theta=-10.0, - sigma_theta=12.115210933938741, + sigma_theta=12.1, ), } diff --git a/zodipy/zodipy.py b/zodipy/zodipy.py index 20068a8..70c5d30 100644 --- a/zodipy/zodipy.py +++ b/zodipy/zodipy.py @@ -9,18 +9,16 @@ import healpy as hp import numpy as np import numpy.typing as npt - from astropy.coordinates import solar_system_ephemeris from astropy.time import Time -from zodipy._bandpass import validate_and_get_bandpass, get_bandpass_interpolation_table +from zodipy._bandpass import get_bandpass_interpolation_table, validate_and_get_bandpass from zodipy._constants import SPECIFIC_INTENSITY_UNITS from zodipy._emission import EMISSION_MAPPING from zodipy._interpolate_source import SOURCE_PARAMS_MAPPING -from zodipy._ipd_dens_funcs import construct_density_partials_comps 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._sky_coords import get_obs_and_earth_positions from zodipy._types import FrequencyOrWavelength, Pixels, SkyAngles from zodipy._unit_vectors import get_unit_vectors_from_ang, get_unit_vectors_from_pixels @@ -99,12 +97,10 @@ def __init__( @property def supported_observers(self) -> list[str]: """Returns a list of available observers given an ephemeris.""" - return list(solar_system_ephemeris.bodies) + ["semb-l2"] def get_parameters(self) -> ParameterDict: """Returns a dictionary containing the interplanetary dust model parameters.""" - return self.ipd_model.to_dict() def update_parameters(self, parameters: ParameterDict) -> None: @@ -116,7 +112,6 @@ def update_parameters(self, parameters: ParameterDict) -> None: of an existing model, use `Zodipy("dirbe").get_parameters()`. """ - _dict = parameters.copy() _dict["comps"] = {} for key, value in parameters.items(): @@ -176,7 +171,6 @@ def get_emission_ang( emission: Simulated zodiacal emission in units of 'MJy/sr'. """ - theta, phi = validate_ang(theta=theta, phi=phi, lonlat=lonlat) unique_angles, indicies = np.unique( @@ -239,7 +233,6 @@ def get_emission_pix( emission: Simulated zodiacal emission in units of 'MJy/sr'. """ - pixels = validate_pixels(pixels=pixels, nside=nside) unique_pixels, indicies = np.unique(pixels, return_inverse=True) @@ -311,7 +304,6 @@ def get_binned_emission_ang( emission: Simulated zodiacal emission in units of 'MJy/sr'. """ - theta, phi = validate_ang(theta=theta, phi=phi, lonlat=lonlat) unique_angles, counts = np.unique( @@ -379,7 +371,6 @@ def get_binned_emission_pix( emission: Simulated zodiacal emission in units of 'MJy/sr'. """ - pixels = validate_pixels(pixels=pixels, nside=nside) unique_pixels, counts = np.unique(pixels, return_counts=True) @@ -418,7 +409,6 @@ def _compute_emission( return_comps: bool = False, ) -> u.Quantity[u.MJy / u.sr]: """Computes the component-wise zodiacal emission.""" - bandpass = validate_and_get_bandpass( freq=freq, weights=weights, @@ -586,5 +576,4 @@ def _integrate_gauss_quad( weights: npt.NDArray[np.float64], ) -> npt.NDArray[np.float64]: """Integrate the emission from a component using Gauss-Legendre quadrature.""" - return np.squeeze(sum(fn(point) * weight for point, weight in zip(points, weights)))