Skip to content

Commit

Permalink
rebase onto main and update with changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ntessore committed Dec 13, 2023
1 parent 339e669 commit 30523f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
32 changes: 16 additions & 16 deletions heracles/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

# valid option keys
FIELD_TYPES = {
"positions": "heracles.maps:PositionMap",
"shears": "heracles.maps:ShearMap",
"visibility": "heracles.maps:VisibilityMap",
"weights": "heracles.maps:WeightMap",
"positions": "heracles.fields:Positions",
"shears": "heracles.fields:Shears",
"visibility": "heracles.fields:Visibility",
"weights": "heracles.fields:Weights",
}


Expand Down Expand Up @@ -152,8 +152,8 @@ def subsections(self, group: str) -> dict[str, str]:
return {s.rpartition(":")[-1].strip(): s for s in sections}


def map_from_config(config, section):
"""Construct a map instance from config."""
def field_from_config(config, section):
"""Construct a field instance from config."""

from pkgutil import resolve_name

Expand All @@ -176,11 +176,11 @@ def map_from_config(config, section):
return cls(nside, *columns)


def maps_from_config(config, group="fields"):
"""Construct all map instances from config."""
def fields_from_config(config, group="fields"):
"""Construct all field instances from config."""
sections = config.subsections(group)
return {
name: map_from_config(config, section) for name, section in sections.items()
name: field_from_config(config, section) for name, section in sections.items()
}


Expand Down Expand Up @@ -364,7 +364,7 @@ def map_all_selections(
) -> Iterator:
"""Iteratively map the catalogues defined in config."""

from .maps import map_catalogs
from .fields import map_catalogs

# turn groups into a deduplicated sequence
if groups is None:
Expand All @@ -374,13 +374,13 @@ def map_all_selections(
else:
groups = list(dict.fromkeys(groups))

# load catalogues and maps to process
# load catalogues and fields to process
catalogs = catalogs_from_config(config)
maps = {}
fields = {}
for group in groups:
maps |= maps_from_config(config, group)
fields |= fields_from_config(config, group)

logger.info("mapping %s", ", ".join(map(repr, maps)))
logger.info("fields %s", ", ".join(map(repr, fields)))

# process each catalogue separately into maps
for key, catalog in catalogs.items():
Expand All @@ -393,7 +393,7 @@ def map_all_selections(

# maps for single catalogue
yield map_catalogs(
maps,
fields,
{key: catalog},
parallel=True, # no effect but prettier log output
progress=True,
Expand Down Expand Up @@ -464,8 +464,8 @@ def alms(
"""

from .fields import transform_maps
from .io import AlmFits
from .maps import transform_maps

# load the config file, this contains alms setting and maps definition
logger.info("reading configuration from %s", files)
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,6 @@ all = true
spaces_indent_inline_array = 4
trailing_comma_inline_array = true
overrides."project.classifiers".inline_arrays = false

[project.scripts]
heracles = "heracles.cli:main"

0 comments on commit 30523f0

Please sign in to comment.