Skip to content

Commit

Permalink
feat(containers): added a HealpixContainer baseclass
Browse files Browse the repository at this point in the history
  • Loading branch information
jrs65 committed Apr 12, 2021
1 parent 0c4b397 commit 6135579
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
31 changes: 24 additions & 7 deletions draco/core/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,27 @@ def __init__(self, mmax=None, *args, **kwargs):
super().__init__(*args, **kwargs)


class Map(FreqContainer):
class HealpixContainer(ContainerBase):
"""Base class container for holding Healpix map data.
Parameters
----------
nside : int
The nside of the Healpix maps.
"""

_axes = ("pixel",)

def __init__(self, nside=None, *args, **kwargs):

# Set up axes from passed arguments
if nside is not None:
kwargs["pixel"] = 12 * nside ** 2

super().__init__(*args, **kwargs)


class Map(FreqContainer, HealpixContainer):
"""Container for holding multifrequency sky maps.
The maps are packed in format `[freq, pol, pixel]` where the polarisations
Expand All @@ -813,7 +833,7 @@ class Map(FreqContainer):
stored.
"""

_axes = ("pol", "pixel")
_axes = ("pol",)

_dataset_spec = {
"map": {
Expand All @@ -825,17 +845,14 @@ class Map(FreqContainer):
}
}

def __init__(self, nside=None, polarisation=True, *args, **kwargs):
def __init__(self, polarisation=True, *args, **kwargs):

# Set up axes from passed arguments
if nside is not None:
kwargs["pixel"] = 12 * nside ** 2

kwargs["pol"] = (
np.array(["I", "Q", "U", "V"]) if polarisation else np.array(["I"])
)

super(Map, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

@property
def map(self):
Expand Down
2 changes: 1 addition & 1 deletion draco/core/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def next(self, *input):
except AttributeError:
self.done = True

# Process input and fetch ouput
# Process input and fetch output
if self._no_input:
if len(input) > 0:
# This should never happen. Just here to catch bugs.
Expand Down

0 comments on commit 6135579

Please sign in to comment.