Skip to content

Commit 38cb64d

Browse files
committed
dev
1 parent fb4062c commit 38cb64d

5 files changed

Lines changed: 150 additions & 142 deletions

File tree

cf/docstring/docstring.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@
8888
elements will be automatically reduced if including the full
8989
amount defined by the halo would extend the subspace beyond
9090
the axis limits.""",
91-
# ----------------------------------------------------------------
91+
# HEALPix references
92+
"{{HEALPix references}}": """K. Gorski, Eric Hivon, A. Banday, B. Wandelt, M. Bartelmann,
93+
et al.. HEALPix: A Framework for High-Resolution
94+
Discretization and Fast Analysis of Data Distributed on the
95+
Sphere. The Astrophysical Journal, 2005, 622 (2), pp.759-771.
96+
https://dx.doi.org/10.1086/427976
97+
98+
M. Reinecke and E. Hivon: Efficient data structures for masks
99+
on 2D grids. A&A, 580 (2015)
100+
A132. https://doi.org/10.1051/0004-6361/201526549""",
101+
# ----------------------------------------------------------------
92102
# Method description substitutions (3 levels of indentation)
93103
# ----------------------------------------------------------------
94104
# i: deprecated at version 3.0.0
@@ -586,7 +596,7 @@
586596
employed. In the "nested_unique" scheme, pixels at
587597
different refinement levels inside a single coarser
588598
refinement level cell can have widely different
589-
indices. For each refinment level *n*, the
599+
indices. For each refinement level *n*, the
590600
"nested_unique" indices are in the range
591601
:math:`4^{(n+1)}, ..., 4^{(n+2)}-1`.""",
592602
# ----------------------------------------------------------------

cf/domain.py

Lines changed: 70 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -267,21 +267,15 @@ def create_regular(cls, x_args, y_args, bounds=True):
267267
def create_healpix(
268268
cls, refinement_level, indexing_scheme="nested", radius=None
269269
):
270-
"""Create a new global HEALPix domain.
270+
r"""Create a new global HEALPix domain.
271271
272272
The HEALPix axis of the new Domain is ordered so that the
273273
HEALPix indices are monotonically increasing.
274274
275-
K. Gorski, Eric Hivon, A. Banday, B. Wandelt, M. Bartelmann,
276-
et al.. HEALPix: A Framework for High-Resolution
277-
Discretization and Fast Analysis of Data Distributed on the
278-
Sphere. The Astrophysical Journal, 2005, 622 (2), pp.759-771.
279-
https://dx.doi.org/10.1086/427976
280-
281-
M. Reinecke and E. Hivon: Efficient data structures for masks
282-
on 2D grids. A&A, 580 (2015)
283-
A132. https://doi.org/10.1051/0004-6361/201526549
284-
275+
**References**
276+
277+
{{HEALPix references}}
278+
285279
.. versionadded:: NEXTVERSION
286280
287281
.. seealso:: `cf.Domain.create_regular`,
@@ -293,8 +287,8 @@ def create_healpix(
293287
The refinement level of the grid within the HEALPix
294288
hierarchy, starting at 0 for the base tessellation
295289
with 12 cells. The number of cells in the global
296-
HEALPix grid is :math:`(12 \times
297-
4^refinement_level)`.
290+
HEALPix grid for refinement level *n* is
291+
:math:`12\times 4^n`.
298292
299293
indexing_scheme: `str`
300294
The HEALPix indexing scheme. One of ``'nested'`` (the
@@ -325,64 +319,78 @@ def create_healpix(
325319
326320
**Examples**
327321
328-
>>> d = cf.Domain.create_healpix(4)
329-
>>> d.dump()
330-
--------
331-
Domain:
332-
--------
333-
Domain Axis: healpix_index(3072)
334-
335-
Auxiliary coordinate: healpix_index
336-
standard_name = 'healpix_index'
337-
units = '1'
338-
Data(healpix_index(3072)) = [0, ..., 3071] 1
339-
340-
Coordinate reference: grid_mapping_name:healpix
341-
Coordinate conversion:grid_mapping_name = healpix
342-
Coordinate conversion:indexing_scheme = nested
343-
Coordinate conversion:refinement_level = 4
344-
Auxiliary Coordinate: healpix_index
345-
346-
>>> d = cf.Domain.create_healpix(4, "nested_unique", radius=6371000)
347-
>>> d.dump()
348-
--------
349-
Domain:
350-
--------
351-
Domain Axis: healpix_index(3072)
352-
353-
Auxiliary coordinate: healpix_index
354-
standard_name = 'healpix_index'
355-
units = '1'
356-
Data(healpix_index(3072)) = [1024, ..., 4095] 1
357-
358-
Coordinate reference: grid_mapping_name:healpix
359-
Coordinate conversion:grid_mapping_name = healpix
360-
Coordinate conversion:indexing_scheme = nested_unique
361-
Datum:earth_radius = 6371000.0
362-
Auxiliary Coordinate: healpix_index
363-
364-
>>> d.create_latlon_coordinates(inplace=True)
365-
>>> print(d)
366-
Auxiliary coords: healpix_index(ncdim%cell(3072)) = [1024, ..., 4095] 1
367-
: latitude(ncdim%cell(3072)) = [2.388015463268772, ..., -2.388015463268786] degrees_north
368-
: longitude(ncdim%cell(3072)) = [45.0, ..., 315.0] degrees_east
369-
Coord references: grid_mapping_name:healpix
322+
.. code-block:: python
323+
324+
>>> d = cf.Domain.create_healpix(4)
325+
>>> d.dump()
326+
--------
327+
Domain:
328+
--------
329+
Domain Axis: healpix_index(3072)
330+
331+
Auxiliary coordinate: healpix_index
332+
standard_name = 'healpix_index'
333+
units = '1'
334+
Data(healpix_index(3072)) = [0, ..., 3071] 1
335+
336+
Coordinate reference: grid_mapping_name:healpix
337+
Coordinate conversion:grid_mapping_name = healpix
338+
Coordinate conversion:indexing_scheme = nested
339+
Coordinate conversion:refinement_level = 4
340+
Auxiliary Coordinate: healpix_index
341+
342+
.. code-block:: python
343+
344+
>>> d = cf.Domain.create_healpix(4, "nested_unique", radius=6371000)
345+
>>> d.dump()
346+
--------
347+
Domain:
348+
--------
349+
Domain Axis: healpix_index(3072)
350+
351+
Auxiliary coordinate: healpix_index
352+
standard_name = 'healpix_index'
353+
units = '1'
354+
Data(healpix_index(3072)) = [1024, ..., 4095] 1
355+
356+
Coordinate reference: grid_mapping_name:healpix
357+
Coordinate conversion:grid_mapping_name = healpix
358+
Coordinate conversion:indexing_scheme = nested_unique
359+
Datum:earth_radius = 6371000.0
360+
Auxiliary Coordinate: healpix_index
361+
362+
.. code-block:: python
363+
364+
>>> d.create_latlon_coordinates(inplace=True)
365+
>>> print(d)
366+
Auxiliary coords: healpix_index(ncdim%cell(3072)) = [1024, ..., 4095] 1
367+
: latitude(ncdim%cell(3072)) = [2.388015463268772, ..., -2.388015463268786] degrees_north
368+
: longitude(ncdim%cell(3072)) = [45.0, ..., 315.0] degrees_east
369+
Coord references: grid_mapping_name:healpix
370370
371371
"""
372372
import dask.array as da
373373

374-
from .healpix import HEALPix_indexing_schemes
374+
from .healpix import (
375+
HEALPix_indexing_schemes,
376+
healpix_max_refinement_level,
377+
)
375378

376-
if indexing_scheme not in HEALPix_indexing_schemes:
379+
if (
380+
not isinstance(refinement_level, Integral)
381+
or refinement_level < 0
382+
or refinement_level > healpix_max_refinement_level()
383+
):
377384
raise ValueError(
378-
"Can't create HEALPix Domain: 'indexing_scheme' must be one "
379-
f"of {HEALPix_indexing_schemes!r}. Got {indexing_scheme!r}"
385+
"Can't create HEALPix Domain: 'refinement_level' must be a "
386+
"non-negative integer less than or equal to "
387+
f"{healpix_max_refinement_level()}. Got {refinement_level!r}"
380388
)
381389

382-
if not isinstance(refinement_level, Integral) or refinement_level < 0:
390+
if indexing_scheme not in HEALPix_indexing_schemes:
383391
raise ValueError(
384-
"Can't create HEALPix Domain: 'refinement_level' must be a "
385-
f"non-negative integer. Got: {refinement_level!r}"
392+
"Can't create HEALPix Domain: 'indexing_scheme' must be one "
393+
f"of {HEALPix_indexing_schemes!r}. Got {indexing_scheme!r}"
386394
)
387395

388396
nested_unique = indexing_scheme == "nested_unique"

0 commit comments

Comments
 (0)