1
|
|
|
_EQUATORIAL = 'equatorial' |
|
|
|
|
2
|
|
|
_GALACTIC = 'galactic' |
3
|
|
|
|
4
|
|
|
_RING = 'RING' |
5
|
|
|
_NESTED = 'NESTED' |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
class HealpixROIBase(object): |
|
|
|
|
9
|
|
|
|
10
|
|
|
def active_pixels(self, nside, system=_EQUATORIAL, ordering=_RING): |
11
|
|
|
""" |
12
|
|
|
Returns the non-zero elements, i.e., the pixels selected according to this Region Of Interest |
13
|
|
|
|
14
|
|
|
:param nside: the NSIDE of the healpix map |
15
|
|
|
:param system: the system of the Healpix map, either 'equatorial' or 'galactic' (default: equatorial) |
16
|
|
|
:param ordering: numbering scheme for Healpix. Either RING or NESTED (default: RING) |
17
|
|
|
:return: an array of pixels IDs (in healpix RING numbering scheme) |
18
|
|
|
""" |
19
|
|
|
|
20
|
|
|
# Let's transform to lower case (so Equatorial will work, as well as EQuaTorial, or whatever) |
21
|
|
|
system = system.lower() |
22
|
|
|
|
23
|
|
|
assert system == _EQUATORIAL, "%s reference system not supported" % system |
24
|
|
|
|
25
|
|
|
assert ordering in [_RING, _NESTED], "Could not understand ordering %s. Must be %s or %s" % (ordering, |
26
|
|
|
_RING, |
27
|
|
|
_NESTED) |
28
|
|
|
|
29
|
|
|
return self._active_pixels(nside, ordering) |
30
|
|
|
|
31
|
|
|
# This is supposed to be overridden by child classes |
32
|
|
|
def _active_pixels(self, nside, ordering): # pragma: no cover |
33
|
|
|
|
34
|
|
|
raise NotImplementedError("You need to implement this") |
35
|
|
|
|
36
|
|
|
def display(self): # pragma: no cover |
|
|
|
|
37
|
|
|
|
38
|
|
|
raise NotImplementedError("You need to implement this") |
39
|
|
|
|
40
|
|
|
def to_dict(self): # pragma: no cover |
|
|
|
|
41
|
|
|
|
42
|
|
|
raise NotImplementedError("You need to implement this") |
43
|
|
|
|
44
|
|
|
def from_dict(self, data): # pragma: no cover |
|
|
|
|
45
|
|
|
|
46
|
|
|
raise NotImplementedError("You need to implement this") |
47
|
|
|
|
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.