-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Thomas Morris
committed
Sep 28, 2024
1 parent
6e54fb1
commit d4aa75e
Showing
15 changed files
with
243 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,58 @@ | ||
maria | ||
===== | ||
|
||
.. image:: https://github.com/thomaswmorris/maria/actions/workflows/testing.yml/badge.svg | ||
:target: https://github.com/thomaswmorris/maria/actions/workflows/testing.yml | ||
|
||
.. image:: https://img.shields.io/pypi/v/maria.svg | ||
:target: https://pypi.python.org/pypi/maria | ||
|
||
.. image:: ./docs/source/_static/cloud.gif | ||
:width: 256px | ||
:alt: StreamPlayer | ||
|
||
`Oh, maria blows the stars around / and sends the clouds | ||
a-flyin’ <https://youtu.be/qKxgfnoz2pk>`_ | ||
|
||
``maria`` is a python-based package that simulates turbulent atmospheric | ||
emission using a auto-regressive Gaussian process framework, for | ||
applications in observational astronomy. Tutorials for installation and | ||
usage can be found in the `documentation <https://www.thomaswmorris.com/maria>`_. | ||
|
||
Background | ||
---------- | ||
|
||
Atmospheric modeling is an important step in both experiment design and | ||
subsequent data analysis for ground-based cosmological telescopes | ||
observing the cosmic microwave background (CMB). The next generation of | ||
ground-based CMB experiments will be marked by a huge increase in data | ||
acquisition: telescopes like `AtLAST <https://www.atlast.uio.no>`_ and | ||
`CMB-S4 <https://cmb-s4.org>`_ will consist of hundreds of thousands of | ||
superconducting polarization-sensitive bolometers sampling the sky. This | ||
necessitates new methods of efficiently modeling and simulating | ||
atmospheric emission at small angular resolutions, with algorithms than | ||
can keep up with the high throughput of modern telescopes. | ||
|
||
maria simulates layers of turbulent atmospheric emission according to a | ||
statistical model derived from observations of the atmosphere in the | ||
Atacama Desert, from the `Atacama Cosmology Telescope | ||
(ACT) <https://lambda.gsfc.nasa.gov/product/act/>`_ and the `Atacama | ||
B-Mode Search (ABS) <https://lambda.gsfc.nasa.gov/product/abs/>`_. It | ||
uses a sparse-precision auto-regressive Gaussian process algorithm that | ||
allows for both fast simulation of high-resolution atmosphere, as well | ||
as the ability to simulate arbitrarily long periods of atmospheric | ||
evolution. | ||
|
||
Methodology | ||
----------- | ||
|
||
``maria`` auto-regressively simulates an multi-layeed two-dimensional | ||
“integrated” atmospheric model that is much cheaper to compute than a | ||
three-dimensional model, which can effectively describe time-evolving | ||
atmospheric emission. maria can thus effectively simulate correlated | ||
atmospheric emission for in excess of 100,000 detectors observing the | ||
sky concurrently, at resolutions as fine as one arcminute. The | ||
atmospheric model used is detailed | ||
`here <https://arxiv.org/abs/2111.01319>`_. | ||
*maria blows the stars around / and sends the clouds a-flyin’* | ||
|
||
.. raw:: html | ||
<audio controls="controls"> | ||
<source src="./_static/they_call_the_wind_maria.mp4" type="audio/wav"> | ||
Your browser does not support the <code>audio</code> element. | ||
</audio> | ||
|
||
``maria`` is a complete simulator of ground-based millimeter- and submillimeter-wave telescopes. Tutorials for installation and usage can be found in the `documentation <https://www.thomaswmorris.com/maria>`_. | ||
|
||
.. Background | ||
.. ---------- | ||
.. Atmospheric modeling is an important step in both experiment design and | ||
.. subsequent data analysis for ground-based cosmological telescopes | ||
.. observing the cosmic microwave background (CMB). The next generation of | ||
.. ground-based CMB experiments will be marked by a huge increase in data | ||
.. acquisition: telescopes like `AtLAST <https://www.atlast.uio.no>`_ and | ||
.. `CMB-S4 <https://cmb-s4.org>`_ will consist of hundreds of thousands of | ||
.. superconducting polarization-sensitive bolometers sampling the sky. This | ||
.. necessitates new methods of efficiently modeling and simulating | ||
.. atmospheric emission at small angular resolutions, with algorithms than | ||
.. can keep up with the high throughput of modern telescopes. | ||
.. maria simulates layers of turbulent atmospheric emission according to a | ||
.. statistical model derived from observations of the atmosphere in the | ||
.. Atacama Desert, from the `Atacama Cosmology Telescope | ||
.. (ACT) <https://lambda.gsfc.nasa.gov/product/act/>`_ and the `Atacama | ||
.. B-Mode Search (ABS) <https://lambda.gsfc.nasa.gov/product/abs/>`_. It | ||
.. uses a sparse-precision auto-regressive Gaussian process algorithm that | ||
.. allows for both fast simulation of high-resolution atmosphere, as well | ||
.. as the ability to simulate arbitrarily long periods of atmospheric | ||
.. evolution. | ||
.. Methodology | ||
.. ----------- | ||
.. ``maria`` auto-regressively simulates an multi-layeed two-dimensional | ||
.. “integrated” atmospheric model that is much cheaper to compute than a | ||
.. three-dimensional model, which can effectively describe time-evolving | ||
.. atmospheric emission. maria can thus effectively simulate correlated | ||
.. atmospheric emission for in excess of 100,000 detectors observing the | ||
.. sky concurrently, at resolutions as fine as one arcminute. The | ||
.. atmospheric model used is detailed | ||
.. `here <https://arxiv.org/abs/2111.01319>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ | |
autoapi_type = "python" | ||
autoapi_dirs = ["./../../maria"] | ||
|
||
nbsphinx_execute = "never" | ||
nbsphinx_execute = "always" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
from itertools import cycle | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import scipy as sp | ||
from matplotlib.patches import Patch | ||
|
||
from ..utils.signal import detrend as detrend_signal | ||
|
||
|
||
def plot_tod( | ||
tod, | ||
detrend: bool = True, | ||
n_freq_bins: int = 256, | ||
max_dets: int = 100, | ||
lw: float = 1e0, | ||
fontsize: float = 8, | ||
): | ||
fig, axes = plt.subplots( | ||
ncols=2, nrows=len(tod.fields), sharex="col", figsize=(8, 4), dpi=160 | ||
) | ||
gs = axes[0, 0].get_gridspec() | ||
|
||
plt.subplots_adjust(top=0.99, bottom=0.01, hspace=0, wspace=0.02) | ||
|
||
for ax in axes[:, -1]: | ||
ax.remove() | ||
ps_ax = fig.add_subplot(gs[:, -1]) | ||
|
||
handles = [] | ||
colors = cycle(plt.rcParams["axes.prop_cycle"].by_key()["color"]) | ||
|
||
for i, field in enumerate(tod.fields): | ||
data = tod.get_field(field) | ||
|
||
tod_ax = axes[i, 0] | ||
|
||
for band_name in np.unique(tod.dets.band_name): | ||
color = next(colors) | ||
|
||
band_mask = tod.dets.band_name == band_name | ||
signal = data[band_mask] | ||
|
||
if band_mask.sum() > max_dets: | ||
signal = signal[ | ||
np.random.choice(np.arange(len(signal)), max_dets, replace=False) | ||
] | ||
|
||
detrended_signal = detrend_signal(signal, order=1) | ||
if detrend: | ||
signal = detrended_signal | ||
|
||
f, ps = sp.signal.periodogram(detrended_signal, fs=tod.fs, window="tukey") | ||
|
||
f_bins = np.geomspace(f[1], f[-1], n_freq_bins) | ||
f_mids = np.sqrt(f_bins[1:] * f_bins[:-1]) | ||
|
||
binned_ps = sp.stats.binned_statistic( | ||
f, ps.mean(axis=0), bins=f_bins, statistic="mean" | ||
)[0] | ||
|
||
use = binned_ps > 0 | ||
|
||
ps_ax.plot( | ||
f_mids[use], | ||
binned_ps[use], | ||
lw=lw, | ||
color=color, | ||
) | ||
tod_ax.plot( | ||
tod.time, | ||
signal[0], | ||
lw=lw, | ||
color=color, | ||
) | ||
|
||
handles.append(Patch(color=color, label=f"{field} ({band_name})")) | ||
|
||
tod_ax.set_xlim(tod.time.min(), tod.time.max()) | ||
|
||
# if tod.units == "K_RJ": | ||
# ylabel = f"{field} [K]" | ||
# elif tod.units == "K_CMB": | ||
# ylabel = rf"{field} [K]" | ||
# elif tod.units == "pW": | ||
# ylabel = f"{field} [pW]" | ||
|
||
# tod_ax.set_ylabel(tod.units) | ||
|
||
label = tod_ax.text( | ||
0.01, | ||
0.99, | ||
f"{field} [{tod.units}]", | ||
fontsize=fontsize, | ||
ha="left", | ||
va="top", | ||
transform=tod_ax.transAxes, | ||
) | ||
label.set_bbox(dict(facecolor="white", alpha=0.8)) | ||
|
||
# if i + 1 < n_fields: | ||
# tod_ax.set_xticklabels([]) | ||
|
||
tod_ax.set_xlabel("Time [s]", fontsize=fontsize) | ||
|
||
ps_ax.yaxis.tick_right() | ||
ps_ax.yaxis.set_label_position("right") | ||
ps_ax.set_xlabel("Frequency [Hz]", fontsize=fontsize) | ||
ps_ax.set_ylabel(f"[{tod.units}$^2$/Hz]", fontsize=fontsize) | ||
ps_ax.legend(handles=handles, loc="upper right", fontsize=fontsize) | ||
ps_ax.loglog() | ||
ps_ax.set_xlim(f_mids.min(), f_mids.max()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.