Coverage for python / lsst / meas / photoz / base / estimate_photoz_task_bpz.py: 60%
36 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-01 08:21 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-01 08:21 +0000
1# This file is part of meas_photoz_base.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22__all__ = [
23 "EstimatePhotozBPZAlgoConfig",
24 "EstimatePhotozBPZAlgoTask",
25 "EstimatePhotozBPZConfig",
26 "EstimatePhotozBPZTask",
27]
29from rail.estimation.algos.bpz_lite import BPZliteEstimator
30from rail.estimation.estimator import CatEstimator
32import lsst.pex.config as pexConfig
34from .estimate_photoz_task import (
35 EstimatePhotozAlgoConfigBase,
36 EstimatePhotozAlgoTask,
37 EstimatePhotozTask,
38 EstimatePhotozTaskConfig,
39 photozAlgoRegistry,
40)
43class EstimatePhotozBPZAlgoConfig(EstimatePhotozAlgoConfigBase):
44 """Config for EstimatePhotozBPZAlgoTask."""
46 @classmethod
47 def estimator_class(cls) -> type[CatEstimator]:
48 return BPZliteEstimator
50 @classmethod
51 def stage_name(cls):
52 return "bpz"
54 def _finalize(self):
55 super()._finalize()
56 if not self.filter_list:
57 self.filter_list = [f"DC2LSST_{band}" for band in self.bands_to_convert]
58 if not self.zp_errors:
59 self.zp_errors = [0.1] * len(self.filter_list)
61 def setDefaults(self):
62 super().setDefaults()
63 self.filter_list = []
64 self.zp_errors = []
67EstimatePhotozBPZAlgoConfig._make_fields()
70@pexConfig.registerConfigurable(EstimatePhotozBPZAlgoConfig.stage_name(), photozAlgoRegistry)
71class EstimatePhotozBPZAlgoTask(EstimatePhotozAlgoTask):
72 """Subtask to run RAIL BPZ algorithm for p(z) estimation.
74 See https://github.com/LSSTDESC/rail_bpz/blob/main/src/rail/estimation/algos/bphotoz_lite.py
75 for algorithm implementation.
76 """
78 ConfigClass = EstimatePhotozBPZAlgoConfig
79 _DefaultName = "estimatePhotozBPZAlgo"
82class EstimatePhotozBPZConfig(EstimatePhotozTaskConfig):
83 """Config for EstimatePhotozBPZTask."""
85 def setDefaults(self) -> None:
86 super().setDefaults()
87 name = EstimatePhotozBPZAlgoConfig.stage_name()
88 self.connections.algo = name
89 self.photoz_algo = name
92class EstimatePhotozBPZTask(EstimatePhotozTask):
93 """Task to run RAIL BPZ algorithm for p(z) estimation."""
95 ConfigClass = EstimatePhotozBPZConfig
96 _DefaultName = "estimatePhotozBPZ"