Skip to content

Commit

Permalink
Rename Zodipy to Model and get_emission_skycoord to evaluate.…
Browse files Browse the repository at this point in the history
… Remove all other methods.
  • Loading branch information
MetinSa committed May 1, 2024
1 parent 37366c9 commit 86114d2
Show file tree
Hide file tree
Showing 22 changed files with 333 additions and 667 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
rev: v1.10.0
hooks:
- id: mypy
exclude: tests/
exclude: '(tests|docs)/.*'
additional_dependencies: [numpy>=1.21.0]
hooks:
- id: poetry-export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
from astropy.time import Time

from zodipy import Zodipy
from zodipy import Model

nside = 128

Expand All @@ -18,7 +18,7 @@
plt.xlabel("Frequency [GHz]")
plt.ylabel("Weights")

model = Zodipy(model="planck18", n_proc=cpu_count())
model = Model(name="planck18", n_proc=cpu_count())

emission_central_freq = model.get_binned_emission_pix(
freq=center_freq,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from astropy.coordinates import BarycentricMeanEcliptic, SkyCoord
from astropy.time import Time

from zodipy import Zodipy
from zodipy import Model

model = Zodipy()
model = Model()

# Longitude and Latitude values corresponding to a scan through the eclitpic plane
lats = np.linspace(-90, 90, 100) * u.deg
Expand All @@ -22,7 +22,7 @@
obstime=obs_time,
)

emission = model.get_emission_skycoord(coords, freq=30 * u.micron)
emission = model.evaluate(coords, freq=30 * u.micron)

plt.plot(lats, emission)
plt.xlabel("Latitude [deg]")
Expand Down
30 changes: 0 additions & 30 deletions docs/examples/get_binned_emission.py

This file was deleted.

31 changes: 0 additions & 31 deletions docs/examples/get_binned_emission_solar_cutoff.py

This file was deleted.

31 changes: 0 additions & 31 deletions docs/examples/get_binned_gal_emission.py

This file was deleted.

34 changes: 0 additions & 34 deletions docs/examples/get_comp_binned_emission.py

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import numpy as np
from astropy.time import Time

from zodipy import Zodipy
from zodipy import Model

nside = 256
pixels = np.arange(hp.nside2npix(nside))
obs_time = Time("2020-01-01")
n_proc = cpu_count()

model = Zodipy()
model_parallel = Zodipy(n_proc=n_proc)
model = Model()
model_parallel = Model(n_proc=n_proc)

start = time.perf_counter()
emission = model.get_binned_emission_pix(
Expand Down
4 changes: 2 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In the following example we simulate what an observer on Earth is expected to se
DIRBE interplanetary dust model.

```python
{!examples/get_emission_ang.py!}
{!examples/evaluate.py!}
```

![Zodiacal emission timestream](img/timestream.png)
Expand Down Expand Up @@ -43,7 +43,7 @@ what the emission looks like over some instrument bandpass. ZodiPy will accept a
argument in addition to the corresponding bandpass weights to the `weights` argument and perform bandpass integration.
Note that the bandpass weights must be in spectral radiance units (Jy/sr), even though the weights them self are unitless. A top hat bandpass is assumed if a sequence of frequencies are used without providing weights.
```python hl_lines="11 12 13 31 32"
{!examples/get_bandpass_integrated_emission.py!}
{!examples/bandpass.py!}
```
![Generated Bandpass](img/bandpass.png)
![Center frequency emission](img/center_freq.png)
Expand Down
12 changes: 6 additions & 6 deletions tests/_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def normalize_array(


@composite
def obs_positions(draw: DrawFn, model: zodipy.Zodipy, obs_time: time.Time) -> str:
def obs_positions(draw: DrawFn, model: zodipy.Model, obs_time: time.Time) -> str:
def get_obs_dist(obs: str, obs_time: time.Time) -> u.Quantity[u.AU]:
if obs == "semb-l2":
obs_pos = (
Expand Down Expand Up @@ -238,12 +238,12 @@ def get_obs_dist(obs: str, obs_time: time.Time) -> u.Quantity[u.AU]:


@composite
def any_obs(draw: DrawFn, model: zodipy.Zodipy) -> str:
def any_obs(draw: DrawFn, model: zodipy.Model) -> str:
return draw(sampled_from(model.supported_observers))


@composite
def zodipy_models(draw: DrawFn, **static_params: dict[str, Any]) -> zodipy.Zodipy:
def zodipy_models(draw: DrawFn, **static_params: dict[str, Any]) -> zodipy.Model:
extrapolate = static_params.pop("extrapolate", draw(booleans()))
model = static_params.pop("model", draw(sampled_from(AVAILABLE_MODELS)))
ipd_model = model_registry.get_model(model)
Expand All @@ -264,9 +264,9 @@ def zodipy_models(draw: DrawFn, **static_params: dict[str, Any]) -> zodipy.Zodip
"gauss_quad_degree", draw(integers(min_value=1, max_value=200))
)

return zodipy.Zodipy(
freq=frequencies,
model=model,
return zodipy.Model(
x=frequencies,
name=model,
weights=w,
gauss_quad_degree=gauss_quad_degree,
extrapolate=extrapolate,
Expand Down
Loading

0 comments on commit 86114d2

Please sign in to comment.