Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a global path in RemoteData #7

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
74c815d
Fixed year on Bennett et al. citation
brandonshensley Oct 5, 2021
ec529cc
Remove doctest-rst option from pytest
zonca Oct 7, 2021
f578230
Rewrite test_units.py
zonca Oct 7, 2021
0139f1c
fix: remove unused imports
zonca Oct 7, 2021
3401a80
Merge pull request #89 from zonca/rewrite_test_units
zonca Oct 7, 2021
f4a8aa0
Use logging instead of warning
zonca Oct 7, 2021
9cdafd8
Log instead of warning for unit
zonca Oct 7, 2021
ae0b83b
fix codestyle
zonca Oct 7, 2021
6ca3741
move also bandpass_unit_conversion to logging
zonca Oct 7, 2021
799b886
docs: how to handle verbosity
zonca Oct 7, 2021
aec18c7
fix: escape \e that was causing DeprecationWarning
zonca Oct 7, 2021
f6eaaf0
fix: extract_hdu_unit was leaving FITS file open
zonca Oct 7, 2021
153a12c
escape back slash
zonca Oct 7, 2021
d424dfd
fix: filter out benign numpy warnings
zonca Oct 7, 2021
2e7e916
fix codestyle
zonca Oct 7, 2021
3053e5f
Filter out AstropyDeprecationWarning
zonca Oct 7, 2021
79f4555
filter out all numpy benign warnings
zonca Oct 7, 2021
917520b
fix: numpy warning, use float32 instead of float
zonca Oct 7, 2021
23e875f
fix: use filterwarnings instead of simplefilter
zonca Oct 7, 2021
8e8f248
fix: remove unnecessary import
zonca Oct 7, 2021
137c49d
fix: remove verbose which is deprecated in healpy 1.15
zonca Oct 7, 2021
586dded
fix: no need of deprecation warning filter anymore
zonca Oct 7, 2021
ef0aef2
test: try to filter warnings in pytest
zonca Oct 7, 2021
88c98c9
Merge pull request #88 from zonca/warnings_to_logging
zonca Oct 7, 2021
e1acb81
mention warnings to logging and JOSS review in changelog
zonca Oct 7, 2021
c57c3e5
[doc] how to install test requirements
zonca Oct 27, 2021
b2e3d4b
[fix] escape \e to avoid warning
zonca Oct 27, 2021
9bb6228
[docs] mention to install pandoc
zonca Oct 27, 2021
c2d470f
[rtd] install test requirements
zonca Oct 27, 2021
4847b85
[rtd] switch to python 3.8
zonca Oct 27, 2021
0815cba
[fix] replace np.int with int
zonca Oct 28, 2021
c66b16b
[docs] better docs for MPI
zonca Oct 28, 2021
f55b97e
[docs] link to MPI tutorial
zonca Oct 28, 2021
9ace3e6
[fix] setup mpi requirement
zonca Oct 28, 2021
ef44aef
Merge pull request #93 from galsci/test_requirements
zonca Oct 28, 2021
6345750
[fix] fix imports in so pysm model example
zonca Oct 29, 2021
c4a1627
[docs] improve CMBMap
zonca Oct 29, 2021
5c480ee
[docs] reference to docs improvement PR
zonca Oct 29, 2021
87d8f14
[paper] mention tolerance in unit tests
zonca Oct 29, 2021
72c26c6
set release date
zonca Oct 29, 2021
845fc0d
small changes in paper
danielskatz Nov 1, 2021
b07a27b
[paper] replace journal shortcuts
zonca Nov 1, 2021
1c30fbe
Merge pull request #94 from danielskatz/patch-1
zonca Nov 1, 2021
61363ab
[paper] fix bibliography capitalization
zonca Nov 1, 2021
c2a4273
Merge pull request #95 from zonca/bib_capit
zonca Nov 1, 2021
cec3de6
[paper] update CITATION to cite JOSS instead of Arxiv
zonca Nov 1, 2021
56212bb
Merge pull request #87 from zonca/dust_layers
zonca Jan 12, 2022
d300ba9
test: implement unit test for remotedata
zonca Feb 1, 2022
a86cc73
test: enable logging in pytest
zonca Feb 1, 2022
b30f28f
run test with global path
zonca Feb 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ build:
image: latest

python:
version: 3.7
version: 3.8
system_packages: true
install:
- method: pip
path: .
extra_requirements:
- docs
- all
- test

formats: []
8 changes: 7 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
3.3.2 (unreleased)
3.3.3 (unreleased)
==================

3.3.2 (2021-10-29)
==================

- `Improvements to install documentation <https://github.com/galsci/pysm/pull/93>`_
- Moved Github repository from `healpy/pysm` to `galsci/pysm`, under the Panexperiment Galactic Science group organization
- Changes in this release are related to the `JOSS Review <https://github.com/openjournals/joss-reviews/issues/3783>`_
- Turned `UserWarning` into `logging`, `Pull Request 88 <https://github.com/galsci/pysm/pull/88>`_

3.3.1 (2021-06-30)
==================
Expand Down
21 changes: 13 additions & 8 deletions CITATION
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
@misc{pysm3,
title={The Python Sky Model 3 software},
author={Andrea Zonca and Ben Thorne and Nicoletta Krachmalnicoff and Julian Borrill},
year={2021},
eprint={2108.01444},
archivePrefix={arXiv},
primaryClass={astro-ph.IM}
@article{Zonca_2021,
doi = {10.21105/joss.03783},
url = {https://doi.org/10.21105/joss.03783},
year = {2021},
publisher = {The Open Journal},
volume = {6},
number = {67},
pages = {3783},
author = {Andrea Zonca and Ben Thorne and Nicoletta Krachmalnicoff and Julian Borrill},
title = {{The Python Sky Model 3 software}},
journal = {Journal of Open Source Software}
}

@article{Thorne_2017,
title={The Python Sky Model: software for simulating the Galactic microwave sky},
title={{The Python Sky Model: software for simulating the Galactic microwave sky}},
volume={469},
ISSN={1365-2966},
url={http://dx.doi.org/10.1093/mnras/stx949},
Expand Down
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ Install

See the `documentation <https://pysm3.readthedocs.io/en/latest/#installation>`_

* Install with ``pip install .``
* Install with ``pip install .`` or with ``pip install .[test]`` to also install the requirements for running tests
* Optionally, if you have an MPI environment available and you would like to test the MPI capabilities of PySM, install ``mpi4py`` and ``libsharp``, check the documentation link above for more details.
* Check code style with ``tox -e codestyle``
* Test with ``pytest`` or ``tox -e test``
* Building docs requires ``pandoc``, not the python package, the actual ``pandoc`` command line tool, install it with conda or your package manager
* Build docs locally with ``tox -e build_docs``

Support
Expand Down
40 changes: 39 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ Python, which is slower, but easier to debug::

export NUMBA_DISABLE_JIT=1

In order to run in parallel with MPI, it also needs:
Run PySM with MPI support
-------------------------

PySM 3 is capable of running across multiple nodes using a MPI communicator.

See the details in the `MPI section of the tutorial <mpi.ipynb>`_.

In order to run in parallel with MPI, it also needs a functioning MPI environment and:

* `mpi4py`

Expand Down Expand Up @@ -98,10 +105,41 @@ Create a development installation with::

pip install -e .

Install the requirements for testing with::

pip install -e .[test]

Execute the unit tests with::

pytest

Configure verbosity
-------------------

PySM uses the `logging` module to configure its verbosity,
by default it will only print warnings and errors, to configure logging
you can access the "pysm3" logger with::

import logging
log = logging.getLogger("pysm3")

configure the logging level::

log.setLevel(logging.DEBUG)

redirect the logs to the console::

handler = logging.StreamHandler()
log.addHandler(handler)

or customize their format::

log_format="%(name)s - %(levelname)s - %(message)s"
formatter = logging.Formatter(log_format)
handler.setFormatter(formatter)

For more details see the `Python documentation <https://docs.python.org/3/library/logging.html>`_.

Tutorials
=========

Expand Down
2 changes: 1 addition & 1 deletion docs/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Dust
Synchrotron
===========

- **s1**: A power law scaling is used for the synchrotron emission, with a spatially varying spectral index. The emission templates are the Haslam 408 MHz, 57' resolution data reprocessed by Remazeilles et al 2015 MNRAS 451, 4311, and the WMAP 9-year 23 GHz Q/U maps (Bennett, C.L., et.al., 2014, ApJS, 208, 20B). The polarization maps have been smoothed with a Gaussian kernel of FWHM 5 degrees and had small scales added. The intensity template has had small scales added straight to the template. The details of the small scale procedure is outlined in the accompanying paper. The spectral index map was derived using a combination of the Haslam 408 MHz data and WMAP 23 GHz 7-year data (Miville-Deschenes, M.-A. et al., 2008, A&A, 490, 1093). The same scaling is used for intensity and polarization. This is the same prescription as used in the Planck Sky Model's v1.7.8 'power law' option (Delabrouille et al. A&A 553, A96, 2013), but with the Haslam map updated to the Remazeilles version. A 'curved power law' model is also supported with a single isotropic curvature index. The amplitude of this curvature is taken from Kogut, A. 2012, ApJ, 753, 110.
- **s1**: A power law scaling is used for the synchrotron emission, with a spatially varying spectral index. The emission templates are the Haslam 408 MHz, 57' resolution data reprocessed by Remazeilles et al 2015 MNRAS 451, 4311, and the WMAP 9-year 23 GHz Q/U maps (Bennett, C.L., et.al., 2013, ApJS, 208, 20B). The polarization maps have been smoothed with a Gaussian kernel of FWHM 5 degrees and had small scales added. The intensity template has had small scales added straight to the template. The details of the small scale procedure is outlined in the accompanying paper. The spectral index map was derived using a combination of the Haslam 408 MHz data and WMAP 23 GHz 7-year data (Miville-Deschenes, M.-A. et al., 2008, A&A, 490, 1093). The same scaling is used for intensity and polarization. This is the same prescription as used in the Planck Sky Model's v1.7.8 'power law' option (Delabrouille et al. A&A 553, A96, 2013), but with the Haslam map updated to the Remazeilles version. A 'curved power law' model is also supported with a single isotropic curvature index. The amplitude of this curvature is taken from Kogut, A. 2012, ApJ, 753, 110.

- **s2**: synchrotron index steepens off the Galactic plane, from -3.0 in the plane to -3.3 off the plane. Consistent with WMAP.

Expand Down
69 changes: 66 additions & 3 deletions docs/mpi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,85 @@
"\n",
"The requirements to run with MPI are `mpi4py` and, just for distributed smoothing, `libsharp`.\n",
"\n",
"The input maps are read from the first process in order to prevent overloading the filesystem, and then maps are distributed rings by rings across all processes, not overlapping.\n",
"The input maps are read from the first process in order to prevent overloading the filesystem, and then maps are distributed across all processes, not overlapping.\n",
"\n",
"The `pysm.MapDistribution` object takes care of handling the metadata about how the data are distributed.\n",
"## Distribution of maps across MPI processes\n",
"\n",
"The `pysm.MapDistribution` object takes care of handling the metadata about how the data are distributed, there are 3 ways to distribute the pixels:\n",
"\n",
"* the most common, which is required to support smoothing over MPI with `libsharp`, is a distribution by ring, where HEALPix rings (stripes of pixels at the same latitude) are distributed symmetrically, i.e. the process that takes first ring close to the North pole also takes the ring close to the South Pole. This is the default distribution if `pixel_indices` is None and a MPI communicator is provided, given that the `libsharp` package is importable:\n",
"\n",
"```python\n",
"map_dist = pysm.MapDistribution(\n",
"pixel_indices=None, nside=nside, mpi_comm=MPI.COMM_WORLD\n",
")\n",
"```\n",
"\n",
"* in case `libsharp` is not available, it is not possible to smooth the maps, but generating models and integrating bandpass works. The configuration of `MapDistribution` is the same as before, when `libsharp` is not importable. In this case the pixels are distributed uniformly across the processes.\n",
"\n",
"* the final case is a custom distribution, where each MPI process specifies an array of not-overlapping local pixel indices. This is also useful when running serially, if you only want to simulate a small patch of sky:\n",
"\n",
"```python\n",
"map_dist = pysm.MapDistribution(\n",
"pixel_indices=local_pixels_indices, nside=nside, mpi_comm=MPI.COMM_WORLD\n",
")\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Creation of the `Sky` object\n",
"\n",
"Next you pass the `MapDistribution` object to `Sky` to have all the models being distributed,\n",
"\n",
"```python\n",
"sky = pysm.Sky(nside=nside, preset_strings=[\"d1\", \"s1\", \"f1\", \"a1\"], map_dist=map_dist)\n",
"```\n",
"\n",
"When the emission is requested, each process independently computes the emission just on its own portion of the sky.\n",
"\n",
"```python\n",
"\n",
"m = sky.get_emission(\n",
" freq=np.arange(50, 55) * u.GHz, weights=np.array([0.1, 0.3, 0.5, 0.3, 0.1])\n",
")[0]\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Distributed smoothing\n",
"\n",
"When smoothing is applied, `libsharp` is used to efficiently perform a distributed spherical harmonics transform.\n",
"\n",
"```python\n",
"m_smoothed = pysm.apply_smoothing_and_coord_transform(\n",
" m, fwhm=1 * u.deg, map_dist=map_dist\n",
")\n",
"```\n",
"\n",
"After smoothing, each process holds the smoothed version of their local pixels,\n",
"this can then be used for example to generate timelines, or be collected to a single process for writing (not implemented in PySM currently, please open an issue if you need it)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example\n",
"\n",
"Check [`pysm3_mpi.py`](https://github.com/galsci/pysm/blob/master/mpi_examples/pysm3_mpi.py) from the repository as an example.\n",
"\n",
"Execute with (remove `#` to actually execute it):"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down
4 changes: 2 additions & 2 deletions mpi_examples/pysm3_mpi_so_pysm_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import healpy as hp
import pysm
import pysm.units as u
import pysm3 as pysm
import pysm3.units as u
from so_pysm_models import get_so_models
import so_pysm_models

Expand Down
14 changes: 7 additions & 7 deletions paper/paper.bib
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ @ARTICLE{gorski05
{Wandelt}, B.~D. and {Hansen}, F.~K. and {Reinecke}, M. and
{Bartelmann}, M.},
title = "{HEALPix: A Framework for High-Resolution Discretization and Fast Analysis of Data Distributed on the Sphere}",
journal = {\apj},
journal = {The Astrophysical Journal},
eprint = {astro-ph/0409513},
keywords = {Cosmology: Cosmic Microwave Background, Cosmology: Observations, Methods: Statistical},
year = 2005,
Expand All @@ -24,12 +24,12 @@ @article{healpy09
number = {35},
pages = {1298},
author = {Andrea Zonca and Leo P. Singer and Daniel Lenz and Martin Reinecke and Cyrille Rosset and Eric Hivon and Krzysztof M. Gorski},
title = {healpy: equal area pixelization and spherical harmonics transforms for data on the sphere in Python},
title = {{healpy: equal area pixelization and spherical harmonics transforms for data on the sphere in Python}},
journal = {Journal of Open Source Software}
}

@article{pysm17,
title={The Python Sky Model: software for simulating the Galactic microwave sky},
title={{The Python Sky Model: software for simulating the Galactic microwave sky}},
volume={469},
ISSN={1365-2966},
url={http://dx.doi.org/10.1093/mnras/stx949},
Expand All @@ -51,7 +51,7 @@ @ARTICLE{wmap13
{Kogut}, A. and {Limon}, M. and {Meyer}, S.~S. and {Tucker}, G.~S. and
{Wright}, E.~L.},
title = "{Nine-year Wilkinson Microwave Anisotropy Probe (WMAP) Observations: Final Maps and Results}",
journal = {\apjs},
journal = {The Astrophysical Journal Supplement Series},
archivePrefix = "arXiv",
eprint = {1212.5225},
keywords = {cosmic background radiation, cosmology: observations, dark matter, early universe, instrumentation: detectors, space vehicles, space vehicles: instruments, telescopes},
Expand Down Expand Up @@ -107,7 +107,7 @@ @article{libsharp
ISSN={1432-0746},
url={http://dx.doi.org/10.1051/0004-6361/201321494},
DOI={10.1051/0004-6361/201321494},
journal={Astronomy & Astrophysics},
journal={Astronomy and Astrophysics},
publisher={EDP Sciences},
author={Reinecke, M. and Seljebotn, D. S.},
year={2013},
Expand All @@ -122,7 +122,7 @@ @article{astropy2013
Doi = {10.1051/0004-6361/201322068},
Eid = {A33},
Eprint = {1307.6212},
Journal = {\aap},
Journal = {Astronomy and Astrophysics},
Keywords = {methods: data analysis, methods: miscellaneous, virtual observatory tools},
Month = oct,
Pages = {A33},
Expand Down Expand Up @@ -177,7 +177,7 @@ @ARTICLE{astropy2018
{Weaver}, B.~A. and {Whitmore}, J.~B. and {Woillez}, J. and
{Zabalza}, V. and {Astropy Contributors}},
title = "{The Astropy Project: Building an Open-science Project and Status of the v2.0 Core Package}",
journal = {\aj},
journal = {The Astronomical Journal},
keywords = {methods: data analysis, methods: miscellaneous, methods: statistical, reference systems, Astrophysics - Instrumentation and Methods for Astrophysics},
year = 2018,
month = sep,
Expand Down
Loading