Skip to content
Merged
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ called 'extra' that will be rendered in the UI. For example:
}
]
```
Such a list of sources can be loaded using `tilemaker open` by passing the JSON filename, e.g.
```
tilemaker open my_catalog.json my_map.fits
```

### Highlight Boxes

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tilemaker = ["server/static/*", "server/static/assets/*"]

[project]
name = "tilemaker"
version = "2.3.3"
version = "2.4.0"
requires-python = ">=3.11"
dependencies = [
"pixell",
Expand Down
21 changes: 19 additions & 2 deletions tilemaker/metadata/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import structlog
from astropy import units
from astropy.io import fits
from pydantic import BaseModel
from pydantic import BaseModel, TypeAdapter

from tilemaker.metadata.core import DataConfiguration
from tilemaker.metadata.definitions import Band, FITSLayerProvider, Layer, Map, MapGroup
from tilemaker.metadata.sources import Source, SourceGroup

# Define the hits unit
hits = units.def_unit("hits", units.dimensionless_unscaled)
Expand All @@ -25,14 +26,30 @@ def generate(
) -> DataConfiguration:
map_files = [x for x in filenames if "fits" in x.name]
map_group = map_group_from_fits(map_files, force_auto_contrast=force_auto_contrast)
source_files = [x for x in filenames if "json" in x.name]
source_groups = [source_group_from_json(x) for x in source_files]

return DataConfiguration(map_groups=[map_group], boxes=[], source_groups=[])
return DataConfiguration(
map_groups=[map_group], boxes=[], source_groups=source_groups
)


def filename_to_id(filename: str | Path) -> str:
return md5(str(filename).encode("utf-8")).hexdigest()[:6]


def source_group_from_json(source_file: Path) -> SourceGroup:
with open(source_file, "r") as handle:
SourceListTypeAdapter = TypeAdapter(list[Source])
return SourceGroup(
source_group_id=filename_to_id(source_file),
name=source_file.name,
description="Source group read from file",
sources=SourceListTypeAdapter.validate_json(handle.read()),
grant=None,
)


def map_group_from_fits(
filenames: list[Path],
force_auto_contrast: bool = False,
Expand Down