Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-36311: Remove deprecated kernelSize* fields #70

Merged
merged 5 commits into from
Jul 3, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Copyright 2014-2021, 2022 University of Washington
Copyright 2008-2021 Association of Universities for Research in Astronomy, Inc. (AURA)
Copyright 2014-2023 The Trustees of Princeton University
Copyright 2018-2020, 2023 The Board of Trustees of the Leland Stanford Junior University, through SLAC National Accelerator Laboratory
Copyright 2014-2017 The Regents of the University of California
Copyright 2014-2015 The University of Tokyo
21 changes: 21 additions & 0 deletions python/lsst/meas/extensions/psfex/psfex.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# This file is part of meas_extensions_psfex.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os
import re

Expand Down
61 changes: 18 additions & 43 deletions python/lsst/meas/extensions/psfex/psfexPsfDeterminer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# This file is part of meas_extensions_psfex.
#
# LSST Data Management System
# Copyright 2008-2015 AURA/LSST.
#
# This product includes software developed by the
# LSST Project (http://www.lsst.org/).
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -15,10 +16,11 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the LSST License Statement and
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

__all__ = ("PsfexPsfDeterminerConfig", "PsfexPsfDeterminerTask")

import os
import numpy as np

Expand Down Expand Up @@ -94,14 +96,6 @@ class PsfexPsfDeterminerConfig(measAlg.BasePsfDeterminerConfig):
doc="Should PSFEX be permitted to recentroid PSF candidates?",
default=False,
)
kernelSize = pexConfig.Field[int](
doc=("Size of the postage stamp around each star that is extracted for fitting."
"Note: this reflects the oversampling setting of the psf, set by `samplingSize`;"
"e.g. `samplingSize=0.5` would require this value to be 2x what you expect."),
default=None,
optional=True,
deprecated="'kernelSize' is deprecated and will be removed in v25. Use `stampSize` instead.",
)

def setDefaults(self):
super().setDefaults()
Expand Down Expand Up @@ -178,32 +172,13 @@ def determinePsf(self, exposure, psfCandidateList, metadata=None, flagKey=None):
rmsSize = quad.getTraceRadius()
sizes[i] = rmsSize

# TODO: Keep only the if block and remove the else blocks in DM-36311
if self.config.stampSize:
pixKernelSize = self.config.stampSize
actualKernelSize = int(2*np.floor(0.5*pixKernelSize/self.config.samplingSize) + 1)
elif self.config.kernelSize >= 15:
self.log.warning("NOT scaling kernelSize by stellar quadrupole moment, but using absolute value")
actualKernelSize = self.config.kernelSize
pixKernelSize = int(actualKernelSize*self.config.samplingSize)
if pixKernelSize % 2 == 0:
pixKernelSize += 1
else:
actualKernelSize = 2 * int(self.config.kernelSize * np.sqrt(np.median(sizes)) + 0.5) + 1
# TODO: DM-36311 Remove deprecated kernelSizeMin and kernelSizeMax
if actualKernelSize < self.config.kernelSizeMin:
actualKernelSize = self.config.kernelSizeMin
if actualKernelSize > self.config.kernelSizeMax:
actualKernelSize = self.config.kernelSizeMax

pixKernelSize = int(actualKernelSize*self.config.samplingSize)
if pixKernelSize % 2 == 0:
pixKernelSize += 1

if display:
rms = np.median(sizes)
self.log.debug("Median PSF RMS size=%.2f pixels (\"FWHM\"=%.2f)",
rms, 2*np.sqrt(2*np.log(2))*rms)
pixKernelSize = self.config.stampSize
actualKernelSize = int(2*np.floor(0.5*pixKernelSize/self.config.samplingSize) + 1)

if display:
rms = np.median(sizes)
self.log.debug("Median PSF RMS size=%.2f pixels (\"FWHM\"=%.2f)",
rms, 2*np.sqrt(2*np.log(2))*rms)

self.log.trace("Psfex Kernel size=%.2f, Image Kernel Size=%.2f", actualKernelSize, pixKernelSize)

Expand Down
35 changes: 11 additions & 24 deletions python/lsst/meas/extensions/psfex/psfexStarSelector.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# This file is part of meas_extensions_psfex.
#
# LSST Data Management System
# Copyright 2008, 2009, 2010 LSST Corporation.
#
# This product includes software developed by the
# LSST Project (http://www.lsst.org/).
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -15,10 +16,11 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the LSST License Statement and
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

__all__ = ("PsfexStarSelectorConfig", "PsfexStarSelectorTask")

import re
import sys

Expand All @@ -36,8 +38,6 @@
from . import psfexLib
from .psfex import compute_fwhmrange

__all__ = ["PsfexStarSelectorConfig", "PsfexStarSelectorTask"]


class PsfexStarSelectorConfig(BaseSourceSelectorTask.ConfigClass):
fluxName = pexConfig.Field(
Expand Down Expand Up @@ -65,19 +65,6 @@ class PsfexStarSelectorConfig(BaseSourceSelectorTask.ConfigClass):
doc="Allowed FWHM variability (1.0 = 100%)",
default=0.2,
)
maxbad = pexConfig.Field(
dtype=int,
doc="Max number of bad pixels ",
default=0,
check=lambda x: x >= 0,
deprecated="This field has never worked and its code is gone. Will be removed after v21."
)
maxbadflag = pexConfig.Field(
dtype=bool,
doc="Filter bad pixels? ",
default=True,
deprecated="This field has never worked and its code is gone. Will be removed after v21."
)
maxellip = pexConfig.Field(
dtype=float,
doc="Maximum (A-B)/(A+B) ",
Expand Down
19 changes: 9 additions & 10 deletions tests/test_PsfexPsf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This file is part of meas_extensions_psfex.
#
# LSST Data Management System
#
# Copyright 2008-2016 AURA/LSST.
#
# This product includes software developed by the
# LSST Project (http://www.lsst.org/).
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -16,10 +16,9 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the LSST License Statement and
# the GNU General Public License along with this program. If not,
# see <https://www.lsstcorp.org/LegalNotices/>.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import math
import numpy as np
import unittest
Expand Down