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

gh-35: Sphinx documentation #36

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

python:
install:
- method: pip
path: .
extra_requirements:
- docs
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ healpix
This package implements a lean set of routines for working with the HEALPix
discretisation of the sphere. It supports NSIDE parameters up to 2^29.

The online documentation can be found [here](http://healpix.readthedocs.io).

The C library is based on the *healpix_bare* library, which was released under
the 3-clause BSD license, with the following additions:

Expand Down Expand Up @@ -38,9 +40,6 @@ The Python package consists of two modules:

* Random point picking in HEALPix pixels.

For a function reference, run `pydoc healpix` (or `pydoc chealpix`) locally if
you have the package installed, or see the [online reference][pydoc].

The high-level functions in the `healpix` module can be used more or less
interchangeably with functions from the *healpy* package. However, in some
cases, compatibility is sacrificed for consistency.
Expand All @@ -67,5 +66,3 @@ and therefore have minimal memory overhead:
>>>
>>> # no memory overhead: only the 2G output arrays were used
```

[pydoc]: https://github.com/ntessore/healpix/raw/main/python/reference.txt
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_build
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15 changes: 15 additions & 0 deletions docs/chealpix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

:mod:`chealpix` -- Python bindings
==================================

.. currentmodule:: chealpix
.. module:: chealpix

Vectorised Python bindings to the HEALPix C library.

.. data:: NSIDE_MAX

Maximum admissible value for the NSIDE parameter.

If nside > NSIDE_MAX is used, the resulting pixel indices can overflow their
underlying integer type in the C library functions.
33 changes: 33 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

from importlib import metadata

project = 'healpix'
copyright = '2024, Nicolas Tessore'
author = 'Nicolas Tessore'
version = metadata.version(project)
release = version

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'sphinx.ext.autodoc',
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
html_static_path = ['_static']
62 changes: 62 additions & 0 deletions docs/healpix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

:mod:`healpix` -- Python module
===============================

.. currentmodule:: healpix
.. module:: healpix

Python module for the HEALPix discretisation of the sphere.


Resolution
----------

.. autodata:: NSIDE_MAX

.. function:: nside2npix(nside)
npix2nside(npix)

Convert between resolution parameter *nside* and number of pixels *npix*.


.. function:: nside2order(nside)
order2nside(order)

Convert between resolution parameter *nside* and HEALPix order *order*.
Requires *nside* to be a power of two.


Pixel routines
--------------

.. function:: ang2pix(nside, theta, phi, nest=False, lonlat=False)
pix2ang(nside, ipix, nest=False, lonlat=False)

.. function:: pix2vec(nside, ipix, nest=False)
vec2pix(nside, x, y, z, nest=False)

.. function:: ang2vec(theta, phi, lonlat=False)
vec2ang(x, y, z, lonlat=False)

.. function:: ring2nest(nside, ipix)
nest2ring(nside, ipix)


Subpixel indexing
-----------------


Random point picking
--------------------

.. autofunction:: randang
.. autofunction:: randvec


Multi-Order Coverage (MOC)
--------------------------

.. function:: pix2uniq(order, ipix, nest=False)
uniq2pix(uniq, nest=False)

Convert pixel indices to or from the UNIQ pixel indexing scheme.
19 changes: 19 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

Welcome to healpix's documentation!
===================================

.. toctree::
:maxdepth: 2
:caption: Contents

healpix
chealpix
library


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
15 changes: 15 additions & 0 deletions docs/library.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
C library
=========

The C library consists of a header ``healpix.h`` and source ``healpix.c``. The
files have no requirements besides a C99-compatible compiler, and are usually
copied directly into a project.


Reference
---------

The contents of the ``healpix.h`` header file are reproduced below.

.. literalinclude:: ../src/healpix.h
:language: c
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Loading