Skip to content

Commit

Permalink
Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
MetinSa committed May 2, 2024
1 parent 86114d2 commit 688a920
Show file tree
Hide file tree
Showing 15 changed files with 176 additions and 147 deletions.
2 changes: 1 addition & 1 deletion tests/_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)

import zodipy
from zodipy._line_of_sight import COMPONENT_CUTOFFS
from zodipy.line_of_sight import COMPONENT_CUTOFFS
from zodipy.model_registry import model_registry

MIN_FREQ = u.Quantity(10, u.GHz)
Expand Down
2 changes: 1 addition & 1 deletion zodipy/_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import astropy.units as u
import numpy as np

from zodipy._ipd_dens_funcs import construct_density_partials
from zodipy.model_registry import model_registry
from zodipy.number_density import construct_density_partials

if TYPE_CHECKING:
import numpy.typing as npt
Expand Down
17 changes: 17 additions & 0 deletions zodipy/blackbody.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@
blackbody = BlackBody(temperatures)


def get_dust_grain_temperature(
R: npt.NDArray[np.float64], T_0: float, delta: float
) -> npt.NDArray[np.float64]:
"""Return the dust grain temperature given a radial distance from the Sun.
Args:
R: Radial distance from the sun in ecliptic heliocentric coordinates [AU / 1AU].
T_0: Temperature of dust grains located 1 AU from the Sun [K].
delta: Powerlaw index.
Returns:
Dust grain temperature [K].
"""
return T_0 * R**-delta


def tabulate_center_wavelength_bnu(wavelength: units.Quantity) -> npt.NDArray[np.float64]:
"""Tabulate blackbody specific intensity for a center wavelength."""
return np.asarray(
Expand Down
28 changes: 12 additions & 16 deletions zodipy/_emission.py → zodipy/brightness.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,27 @@
import numpy as np
import numpy.typing as npt

from zodipy._ipd_model import RRM, InterplanetaryDustModel, Kelsall
from zodipy._source_funcs import (
get_dust_grain_temperature,
get_phase_function,
get_scattering_angle,
)
from zodipy.blackbody import get_dust_grain_temperature
from zodipy.scattering import get_phase_function, get_scattering_angle

if TYPE_CHECKING:
from zodipy._ipd_dens_funcs import ComponentDensityFn
from zodipy.number_density import ComponentNumberDensityCallable

"""
Function that return the zodiacal emission at a step along all lines of sight given
a zodiacal model.
"""
GetCompEmissionAtStepFn = Callable[..., npt.NDArray[np.float64]]
BrightnessAtStepCallable = Callable[..., npt.NDArray[np.float64]]


def kelsall(
def kelsall_brightness_at_step(
r: npt.NDArray[np.float64],
start: np.float64,
stop: npt.NDArray[np.float64],
X_obs: npt.NDArray[np.float64],
u_los: npt.NDArray[np.float64],
bp_interpolation_table: npt.NDArray[np.float64],
get_density_function: ComponentDensityFn,
get_density_function: ComponentNumberDensityCallable,
T_0: float,
delta: float,
emissivity: np.float64,
Expand Down Expand Up @@ -59,14 +55,14 @@ def kelsall(
return emission * get_density_function(X_helio)


def rrm(
def rrm_brightness_at_step(
r: npt.NDArray[np.float64],
start: npt.NDArray[np.float64],
stop: npt.NDArray[np.float64],
X_obs: npt.NDArray[np.float64],
u_los: npt.NDArray[np.float64],
bp_interpolation_table: npt.NDArray[np.float64],
get_density_function: ComponentDensityFn,
get_density_function: ComponentNumberDensityCallable,
T_0: float,
delta: float,
calibration: np.float64,
Expand All @@ -84,7 +80,7 @@ def rrm(
return blackbody_emission * get_density_function(X_helio) * calibration


EMISSION_MAPPING: dict[type[InterplanetaryDustModel], GetCompEmissionAtStepFn] = {
Kelsall: kelsall,
RRM: rrm,
}
# EMISSION_MAPPING: dict[type[InterplanetaryDustModel], GetCompEmissionAtStepFn] = {
# Kelsall: kelsall,
# RRM: rrm,
# }
8 changes: 4 additions & 4 deletions zodipy/comps.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from __future__ import annotations

from zodipy._constants import R_ASTEROID_BELT, R_KUIPER_BELT, R_MARS
from zodipy._ipd_comps import (
from zodipy.zodiacal_component import (
Band,
BroadBand,
Cloud,
Comet,
Component,
ComponentLabel,
Fan,
Feature,
Expand All @@ -15,9 +14,10 @@
NarrowBand,
Ring,
RingRRM,
ZodiacalComponent,
)

DIRBE: dict[ComponentLabel, Component] = {
DIRBE: dict[ComponentLabel, ZodiacalComponent] = {
ComponentLabel.CLOUD: Cloud(
x_0=0.011887800744346281,
y_0=0.0054765064662263777,
Expand Down Expand Up @@ -97,7 +97,7 @@
PLANCK.pop(ComponentLabel.FEATURE)


RRM: dict[ComponentLabel, Component] = {
RRM: dict[ComponentLabel, ZodiacalComponent] = {
ComponentLabel.FAN: Fan(
x_0=0.0,
y_0=0.0,
Expand Down
8 changes: 4 additions & 4 deletions zodipy/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from astropy import units
from scipy import integrate

from zodipy._ipd_model import RRM, InterplanetaryDustModel, Kelsall
from zodipy.comps import ComponentLabel
from zodipy.zodiacal_light_model import RRM, Kelsall, ZodiacalLightModel

CompParamDict = dict[ComponentLabel, dict[str, Any]]
CommonParamDict = dict[str, Any]
Expand Down Expand Up @@ -121,20 +121,20 @@ def interpolate_spectral_parameter(
return interpolated_parameter


T = TypeVar("T", contravariant=True, bound=InterplanetaryDustModel)
T = TypeVar("T", contravariant=True, bound=ZodiacalLightModel)
CallableModelToDicts = Callable[
[units.Quantity, Union[units.Quantity, None], T], tuple[CompParamDict, CommonParamDict]
]


MODEL_INTERPOLATION_MAPPING: dict[type[InterplanetaryDustModel], CallableModelToDicts] = {
MODEL_INTERPOLATION_MAPPING: dict[type[ZodiacalLightModel], CallableModelToDicts] = {
Kelsall: kelsall_params_to_dicts,
RRM: rrm_params_to_dicts,
}


def get_model_to_dicts_callable(
model: InterplanetaryDustModel,
model: ZodiacalLightModel,
) -> CallableModelToDicts:
"""Get the appropriate parameter unpacker for the model."""
return MODEL_INTERPOLATION_MAPPING[type(model)]
13 changes: 11 additions & 2 deletions zodipy/_line_of_sight.py → zodipy/line_of_sight.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Iterable
from typing import TYPE_CHECKING, Callable, Iterable

import numpy as np

from zodipy._constants import R_0, R_EARTH, R_JUPITER, R_KUIPER_BELT
from zodipy._ipd_comps import ComponentLabel
from zodipy.comps import RRM
from zodipy.zodiacal_component import ComponentLabel

if TYPE_CHECKING:
import numpy.typing as npt
Expand Down Expand Up @@ -47,6 +47,15 @@
COMPONENT_CUTOFFS = {**DIRBE_CUTOFFS, **RRM_CUTOFFS}


def integrate_gauss_legendre(
fn: Callable[[float], npt.NDArray[np.float64]],
points: npt.NDArray[np.float64],
weights: npt.NDArray[np.float64],
) -> npt.NDArray[np.float64]:
"""Integrate a function using Gauss-Legendre quadrature."""
return np.squeeze(sum(fn(x) * w for x, w in zip(points, weights)))


def get_sphere_intersection(
obs_pos: npt.NDArray[np.float64],
unit_vectors: npt.NDArray[np.float64],
Expand Down
2 changes: 1 addition & 1 deletion zodipy/model_registry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from zodipy import comps, source_params
from zodipy._ipd_model import RRM, Kelsall, model_registry
from zodipy.zodiacal_light_model import RRM, Kelsall, model_registry

model_registry.register_model(
name="dirbe",
Expand Down
Loading

0 comments on commit 688a920

Please sign in to comment.