Skip to content

Commit

Permalink
Merge branch 'master' into co_maps
Browse files Browse the repository at this point in the history
  • Loading branch information
paganol committed Nov 26, 2024
2 parents 4286ea9 + bbc4f7d commit 4172c4c
Show file tree
Hide file tree
Showing 39 changed files with 2,501 additions and 1,829 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

- **Breaking change**: Redefinition (ωt instead of 2ωt) of the hwp angle returned by `get_pointings()`. Change in the pointing returned by `Observation.get_pointings()`, now behaving as it was before this [commit](https://github.com/litebird/litebird_sim/pull/319/commits/b3bc3bb2049c152cc183d6cfc68f4598f5b93ec0). Documentation updated accordingly. [#340](https://github.com/litebird/litebird_sim/pull/340)

- Restructure the manual and use a new, cleaner style [#342](https://github.com/litebird/litebird_sim/pull/342)

- Module for including nonlinearity in the simulations [#331](https://github.com/litebird/litebird_sim/pull/331)

- Improve the documentation of the binner and the destriper [#333](https://github.com/litebird/litebird_sim/pull/333)

- Make the code compatible with Python 3.12 [#332](https://github.com/litebird/litebird_sim/pull/332)

- plot_fp.py which visualizes focal plane and `DetectorInfo` is implemented.
Also it can generate a dector list file by clicking visualized detectors.
The function is executable by: `python -m litebird_sim.plot_fp` [#345](https://github.com/litebird/litebird_sim/pull/345)

- Simulation.add_noise() uses self.random as default random number generator [#349](https://github.com/litebird/litebird_sim/pull/349)

# Version 0.13.0

- **Breaking change**: new API for pointing computation [#319](https://github.com/litebird/litebird_sim/pull/319). Here is a in-depth list of all the breaking changes in this PR:
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ command:
make.bat html
```
### Focal plane visualizer
We can visualize detectors in the focal plane by:
```
python -m litebird_sim.plot_fp
```
This software loads the IMo which is installed in the machine you are using.
As the conversation unfolds, an interactive Matplotlib window will appear.
Detectors corresponding to the specified channels are represented as blue dots.
Clicking on a dot reveals the `DetectorInfo` for that detector in real time, highlighted with a red star.
Additionally, if you agree during the conversation to generate a detector file,
a list of starred detectors will be saved into a text file at the designated location after you closed the plot.
![plot_fp_usage](https://private-user-images.githubusercontent.com/83496454/388083441-93876c66-8b61-40c0-b23f-79a6998e5e33.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzIxMDQ2MDcsIm5iZiI6MTczMjEwNDMwNywicGF0aCI6Ii84MzQ5NjQ1NC8zODgwODM0NDEtOTM4NzZjNjYtOGI2MS00MGMwLWIyM2YtNzlhNjk5OGU1ZTMzLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDExMjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMTIwVDEyMDUwN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZlOTk2M2M3NDgyZjUyY2M4NjFiOGE3ZjliM2RhMWU1YWU2NjFkNmM1ZGQxYzAzM2Y3ZDVmOGI3ZTdhMTAwNjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.MoAArSYcXhQgVYaer_O72XHIamO_Ex6B5ITuyVgB8_g)
## Roadmap
Expand Down
7 changes: 7 additions & 0 deletions docs/source/appendix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Appendices
==========

.. toctree::
:maxdepth: 1

bibliography.rst
74 changes: 0 additions & 74 deletions docs/source/bandpasses.rst

This file was deleted.

4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# -- Project information -----------------------------------------------------

project = "LiteBIRD simulation pipeline"
project = "LBS"
copyright = "2020, The LiteBIRD Simulation Team"
author = "The LiteBIRD Simulation Team"

Expand Down Expand Up @@ -58,7 +58,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "alabaster"
html_theme = "pydata_sphinx_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
70 changes: 70 additions & 0 deletions docs/source/detectors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,80 @@ each stage of the simulation:
- 000_000_004_QB_040_T


Bandpasses
----------

Any electromagnetic detector is sensitive only to some frequencies of
the spectrum, and it is vital to know what they are. We refer to these
as the «bandpass», i.e., the list of frequencies that can «pass
through the detector» and be detected. A bandpass is a function
:math:`B(\nu)` that associates the frequency :math:`\nu` with a pure
number in the range 0…1, representing the fraction of power that is
actually measured by the instrument. The functional form of
:math:`B(\nu)` is usually called the *bandshape*, and it is usually
nonzero in a limited subset of the real space.

A widely used analytical model of the bandshape is the top-hat bandpass:

.. math::
:name: eq:tophatbandpass
B(\nu) = \begin{cases}
1\,\text{ if } \nu_0 - \Delta\nu/2 < \nu < \nu_0 + \Delta\nu/2,\\
0\,\text{ otherwise.}
\end{cases}
Given a bandshape :math:`B(\nu)`, two quantities are usually employed
to synthetically represent it:

- The *central frequency* :math:`\left<\nu\right>`, which is just the
average value of :math:`\nu` when weighted with :math:`B(\nu)`:

.. math::
\left<\nu\right> = \frac{\int_0^\infty \nu B(\nu)\,\mathrm{d}\nu}{\int_0^\infty B(\nu)\,\mathrm{d}\nu}
which is of course the formula of the weighted average. For the
top-hat band, the central frequency is :math:`\nu_0`.

- The *bandwidth* :math:`\Delta\nu`, which is the *width* of the band,
i.e., a measurement of how wide is the subrange of the
electromagnetic spectrum sampled by the detector:

.. math::
\Delta\nu^2 = \frac{\left(\int_0^\infty B(\nu)\,\mathrm{d}\nu\right)^2}{\int_0^\infty B^2(\nu)\,\mathrm{d}\nu},
which is again inspired by the formula of the standard square
deviation. For the top-hat bandshape, the value of :math:`\Delta\nu`
in :math:numref:`eq:tophatbandpass` is exactly the bandwidth.


Modeling bandshapes
~~~~~~~~~~~~~~~~~~~

In the LiteBIRD Simulation Framework, bandpasses are encoded in the
class :class:`.BandPassInfo`, which can be used either to load
bandpasses from the IMO or to generate them on scratch. In the latter
case, you must specify the central frequency and the bandwidth,
alongside with other parameter that introduce a random component meant
to make the band more realistic. Here is a simple example, which shows
how to create a bandpass and then how to add «noise» to make it more
realistic:

.. plot:: pyplots/bandpass_demo.py
:include-source:



API reference
-------------

.. automodule:: litebird_sim.detectors
:members:
:undoc-members:
:show-inheritance:

.. automodule:: litebird_sim.bandpasses
:members:
:undoc-members:
:show-inheritance:
57 changes: 30 additions & 27 deletions docs/source/dipole.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ Dipole anisotropy
=================

The LiteBIRD Simulation Framework provides tools to simulate the
signal associated with the relative velocity between the spacecraft's
rest frame with respect to the CMB. The motion of the spacecraft in
the rest frame of the CMB is the composition of several components:
signal associated with the relative velocity between the rest frame of
the spacecraft with respect to the CMB. The motion of the spacecraft
in the rest frame of the CMB is the composition of several components:

1. The motion of the spacecraft around L2;

2. The motion of the L2 point in the Ecliptic plane;

3. The motion of the Solar System around the Galactic Centre;

4. The motion of the Milky Way.

Components 1 and 2 are simulated by the LiteBIRD Simulation Framework
using appropriate models for the motions, while components 3 and 4 are
included using the Sun velocity derived by the solar dipole measured
by the Planck satellite.
using appropriate motion models, while components 3 and 4 are included
using the Sun velocity derived by the solar dipole measured by the
Planck satellite.

The motion of the spacecraft around L2 is modelled using a Lissajous
orbit similar to what was used for the WMAP experiment
Expand All @@ -28,21 +31,21 @@ Position and velocity of the spacecraft

The class :class:`.SpacecraftOrbit` describes the orbit of the
LiteBIRD spacecraft with respect to the Barycentric Ecliptic Reference
Frame and the motion of Barycentric Ecliptic Reference Frame with respect
to the CMB; this class is necessary because the class
Frame and the motion of the Barycentric Ecliptic Reference Frame with
respect to the CMB; this class is necessary because the class
:class:`.ScanningStrategy` (see the chapter :ref:`scanning-strategy`)
only models the *direction* each instrument is looking at but knows
nothing about the velocity of the spacecraft itself.

The class :class:`.SpacecraftOrbit` is a dataclass that is able to
initialize its members to sensible default values, which are taken
from the literature. As the LiteBIRD orbit around L2 is not fixed yet,
the code assumes a WMAP-like Lissajous orbit, :cite:`2008:wmap:cavaluzzi`.
For the Sun velocity it assumes Planck 2018 solar dipole
The class :class:`.SpacecraftOrbit` is a dataclass that can initialize
its members to sensible default values taken from the literature. As
the LiteBIRD orbit around L2 is not fixed yet, the code assumes a
WMAP-like Lissajous orbit, :cite:`2008:wmap:cavaluzzi`. For the Sun
velocity it assumes Planck 2018 solar dipole
:cite:`2020:planck:hfi_data_processing`.

To compute the position/velocity of the spacecraft, you call
:func:`.spacecraft_pos_and_vel`; it requires either a time span or an
:func:`.spacecraft_pos_and_vel`; it requires either a period or an
:class:`.Observation` object, and it returns an instance of the class
:class:`.SpacecraftPositionAndVelocity`:

Expand Down Expand Up @@ -75,9 +78,9 @@ the table with the positions and the velocities in the fields
arrays of shape ``(nsamples, 3)``.

Here is a slightly more complex example that shows how to plot the
distance between the spacecraft and the Sun as a function of time, as
well as its speed. The latter quantity is of course most relevant when
computing the CMB dipole.
distance between the spacecraft and the Sun as a function of time and
speed. The latter quantity is, of course, most relevant when computing
the CMB dipole.

.. plot:: pyplots/spacecraft_demo.py
:include-source:
Expand Down Expand Up @@ -118,13 +121,13 @@ and :math:`\mathrm{BB}(\nu, T)` is the spectral radiance of a
black-body according to Planck's law:

.. math:: \mathrm{BB}(\nu, T) = \frac{2h\nu^3}{c^2} \frac1{e^{h\nu/k_B T} - 1} = \frac{2h\nu^3}{c^2} \frac1{e^x - 1}.
There is no numerical issue in computing the full formula, but often
models use some simplifications, to make the math easier to work on
the blackboard. The LiteBIRD Simulation Framework implements several
simplifications of the formula, which are based on a series expansion
of :eq:`dipole`; the caller must pass an object of type
:class:`.DipoleType` (an `enum class

There is no numerical issue in computing the complete formula, but
often, models use some simplifications to make the math more
manageable to work on the blackboard. The LiteBIRD Simulation
Framework implements several simplifications of the formula, which are
based on a series expansion of :eq:`dipole`; the caller must pass an
object of type :class:`.DipoleType` (an `enum class
<https://docs.python.org/3/library/enum.html>`_), whose value signals
which kind of approximation to use:

Expand Down Expand Up @@ -184,8 +187,8 @@ Methods of class simulation
---------------------------

The class :class:`.Simulation` provides two simple functions that compute
poisition and velocity of the spacescraft :func:`.Simulation.compute_pos_and_vel`,
and add the solar and orbital dipole to all the observations of a given
poisition and velocity of the spacescraft :func:`.Simulation.compute_pos_and_vel`,
and add the solar and orbital dipole to all the observations of a given
simulation :func:`.Simulation.add_dipole`.

.. testcode::
Expand Down Expand Up @@ -253,7 +256,7 @@ simulation :func:`.Simulation.add_dipole`.
3.45712e-03

Note that even if :func:`Simulation.compute_pos_and_vel` is not explicitly
invoked, :func:`Simulation.add_dipole` takes care of that internally initializing
invoked, :func:`Simulation.add_dipole` takes care of that internally initializing
:class:`SpacecraftOrbit` and computing positions and velocities.

API reference
Expand Down
13 changes: 0 additions & 13 deletions docs/source/external_modules.rst

This file was deleted.

Loading

0 comments on commit 4172c4c

Please sign in to comment.