Skip to content

Commit

Permalink
Add description/unit/operation to property map metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Oct 4, 2023
1 parent f70ddfc commit dac4588
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
4 changes: 3 additions & 1 deletion python/lsst/pipe/tasks/healSparseMapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,9 @@ def consolidate_map(self, sky_map, input_refs):
input_map.nside_sparse,
input_map.dtype,
sentinel=input_map._sentinel,
cov_pixels=cov_pix)
cov_pixels=cov_pix,
metadata=input_map.metadata,
)

# Only use pixels that are properly inside the tract.
vpix, ra, dec = input_map.valid_pixels_pos(return_pixels=True)
Expand Down
33 changes: 28 additions & 5 deletions python/lsst/pipe/tasks/healSparseMappingProperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import numpy as np
import healsparse as hsp
import copy

import lsst.pex.config as pexConfig
import lsst.geom
Expand Down Expand Up @@ -209,6 +210,9 @@ class BasePropertyMap:
dtype = np.float64
requires_psf = False

description = ""
unit = ""

ConfigClass = BasePropertyMapConfig

registry = PropertyMapRegistry(BasePropertyMapConfig)
Expand All @@ -229,26 +233,45 @@ def initialize_tract_maps(self, nside_coverage, nside):
nside : `int`
Healpix nside of the property map.
"""
base_metadata = {
"DESCRIPTION": self.description,
"UNIT": self.unit,
}
if self.config.do_min:
metadata = copy.copy(base_metadata)
metadata["OPERATION"] = "minimum"
self.min_map = hsp.HealSparseMap.make_empty(nside_coverage,
nside,
self.dtype)
self.dtype,
metadata=metadata)
if self.config.do_max:
metadata = copy.copy(base_metadata)
metadata["OPERATION"] = "maximum"
self.max_map = hsp.HealSparseMap.make_empty(nside_coverage,
nside,
self.dtype)
self.dtype,
metadata=metadata)
if self.config.do_mean:
metadata = copy.copy(base_metadata)
metadata["OPERATION"] = "mean"
self.mean_map = hsp.HealSparseMap.make_empty(nside_coverage,
nside,
self.dtype)
self.dtype,
metadata=metadata)
if self.config.do_weighted_mean:
metadata = copy.copy(base_metadata)
metadata["OPERATION"] = "weighted mean"
self.weighted_mean_map = hsp.HealSparseMap.make_empty(nside_coverage,
nside,
self.dtype)
self.dtype,
metadata=metadata)
if self.config.do_sum:
metadata = copy.copy(base_metadata)
metadata["OPERATION"] = "sum"
self.sum_map = hsp.HealSparseMap.make_empty(nside_coverage,
nside,
self.dtype)
self.dtype,
metadata=metadata)

def initialize_values(self, n_pixels):
"""Initialize the value arrays for accumulation.
Expand Down

0 comments on commit dac4588

Please sign in to comment.