Skip to content

Commit

Permalink
Fixing Flake8 W505
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcrenshaw committed Dec 15, 2023
1 parent a2cd270 commit 55ec6e2
Show file tree
Hide file tree
Showing 16 changed files with 126 additions and 113 deletions.
56 changes: 30 additions & 26 deletions python/lsst/ts/wep/estimation/tie.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ class TieAlgorithm(WfAlgorithm):
compGain : float, optional
The gain used to update the Zernikes for image compensation.
centerTol : float, optional
The maximum absolute change in any Zernike amplitude (in meters) for which
the images need to be recentered. A smaller value causes the images to
be recentered more often. If 0, images are recentered on every iteration.
The maximum absolute change in any Zernike amplitude (in meters) for
which the images need to be recentered. A smaller value causes the
images to be recentered more often. If 0, images are recentered on
every iteration.
centerBinary : bool, optional
Whether to use a binary template when centering the image.
Using a binary template is typically less accurate, but faster.
convergeTol : float, optional
The maximum absolute change in any Zernike amplitude (in meters) between
subsequent TIE iterations below which convergence is declared and iteration
is stopped.
The maximum absolute change in any Zernike amplitude (in meters)
between subsequent TIE iterations below which convergence is declared
and iteration is stopped.
maskKwargs : dict, optional
Dictionary of mask keyword arguments to pass to mask creation.
To see possibilities, see the docstring for
Expand Down Expand Up @@ -129,12 +130,13 @@ def opticalModel(self, value: str) -> None:
Parameters
----------
value : str
The optical model to use for mapping between the image and pupil
planes. Can be "onAxis", or "offAxis". onAxis is an analytic model
appropriate for donuts near the optical axis. It is valid for both
slow and fast optical systems. The offAxis model is a numerically-fit
model that is valid for fast optical systems at wide field angles.
offAxis requires an accurate Batoid model.
The optical model to use for mapping between the image and
pupil planes. Can be "onAxis", or "offAxis". onAxis is an
analytic model appropriate for donuts near the optical axis.
It is valid for both slow and fast optical systems. The offAxis
model is a numerically-fit model that is valid for fast optical
systems at wide field angles. offAxis requires an accurate Batoid
model.
Raises
------
Expand Down Expand Up @@ -214,11 +216,12 @@ def compSequence(self, value: Iterable) -> None:
Parameters
----------
value : iterable
An iterable that determines the maximum Noll index to compensate on
each iteration of the TIE loop. For example, if compSequence = [4, 10],
then on the first iteration, only Zk4 is used in image compensation and
on iteration 2, Zk4-Zk10 are used. Once the end of the sequence has
been reached, all Zernike coefficients are used during compensation.
An iterable that determines the maximum Noll index to
compensate on each iteration of the TIE loop. For example,
if compSequence = [4, 10], then on the first iteration,
only Zk4 is used in image compensation and on iteration 2,
Zk4-Zk10 are used. Once the end of the sequence has been
reached, all Zernike coefficients are used during compensation.
Raises
------
Expand Down Expand Up @@ -258,19 +261,20 @@ def compGain(self, value: float) -> None:

@property
def centerTol(self) -> float:
"""Maximum abs. deviation in Zernike coefficients that requires re-centering."""
"""Max abs. deviation in Zernike coeff. that requires re-centering."""
return self._centerTol

@centerTol.setter
def centerTol(self, value: float) -> None:
"""Set max abs. deviation in Zernike coefficients that requires re-centering.
"""Set max abs. deviation in Zernike coeff that requires re-centering.
Parameters
----------
value : float
The maximum absolute change in any Zernike amplitude (in meters) for which
the images need to be recentered. A smaller value causes the images to
be recentered more often. If 0, images are recentered on every iteration.
The maximum absolute change in any Zernike amplitude (in meters)
for which the images need to be recentered. A smaller value causes
the images to be recentered more often. If 0, images are recentered
on every iteration.
"""
self._centerTol = float(value)

Expand Down Expand Up @@ -301,7 +305,7 @@ def centerBinary(self, value: bool) -> None:

@property
def convergeTol(self) -> float:
"""Mean abs. deviation in Zernikes (meters) at which the TIE loop terminates."""
"""Mean abs. deviation in Zernikes (meters) at which TIE terminates."""
return self._convergeTol

@convergeTol.setter
Expand Down Expand Up @@ -333,7 +337,7 @@ def maskKwargs(self) -> dict:

@maskKwargs.setter
def maskKwargs(self, value: Union[dict, None]) -> None:
"""Set dictionary of keyword arguments passed to ImageMapper.createPupilMask().
"""Set dict of keyword args passed to ImageMapper.createPupilMask().
Parameters
----------
Expand Down Expand Up @@ -377,7 +381,7 @@ def saveHistory(self) -> bool:

@saveHistory.setter
def saveHistory(self, value: bool) -> None:
"""Set the boolean that determines whether the algorithm history is saved.
"""Set boolean that determines whether algorithm history is saved.
Parameters
----------
Expand Down Expand Up @@ -594,7 +598,7 @@ def estimateZk(
# Center the images
recenter = (i == 0) or (np.max(np.abs(zkComp - zkCenter)) > self.centerTol)
if recenter:
# Zernikes have changed enough that we should recenter the images
# Zernikes have changed enough that we should recenter images
zkCenter = zkComp.copy()
intraCent = imageMapper.centerOnProjection(
intra,
Expand Down
13 changes: 7 additions & 6 deletions python/lsst/ts/wep/estimation/wfAlgorithmFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ def createWfAlgorithm(
A WfAlgorithmName enum or the corresponding string, indicating
which WfAlgorithm to use.
algoConfig : str or dict or WfAlgorithm, optional
Algorithm configuration. If a string, it is assumed this points to a
config file, which is used to configure the algorithm. If the path
begins with "policy/", then it is assumed the path is relative to the
policy directory. If a dictionary, it is assumed to hold keywords for
configuration. If a WfAlgorithm object, that object is just used.
If None, the algorithm defaults are used.
Algorithm configuration. If a string, it is assumed this points
to a config file, which is used to configure the algorithm. If the
path begins with "policy/", then it is assumed the path is relative
to the policy directory. If a dictionary, it is assumed to hold
keywords for configuration. If a WfAlgorithm object, that object is
just used. If None, the algorithm defaults are used.
(the default is None)
"""
# Convert to enum
algoName = WfAlgorithmName(algoName)
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/ts/wep/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def defocalType(self, value: Union[DefocalType, str]) -> None:
----------
value : DefocalType or str
Whether the image is intra- or extra-focal.
Can be specified using a DefocalType Enum or the corresponding string.
Can be specified using DefocalType Enum or corresponding string.
Raises
------
Expand Down Expand Up @@ -262,7 +262,7 @@ def mask(self) -> Union[np.ndarray, None]:
def mask(self, value: Optional[np.ndarray]) -> None:
"""Set the image mask.
Note that mask creation is meant to be handled by the ImageMapper class.
Note mask creation is meant to be handled by the ImageMapper class.
Parameters
----------
Expand Down
13 changes: 7 additions & 6 deletions python/lsst/ts/wep/imageMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ def opticalModel(self, value: str) -> None:
Parameters
----------
value : str
The optical model to use for mapping between the image and pupil
planes. Can be "onAxis", or "offAxis". onAxis is an analytic model
appropriate for donuts near the optical axis. It is valid for both
slow and fast optical systems. The offAxis model is a numerically-fit
model that is valid for fast optical systems at wide field angles.
offAxis requires an accurate Batoid model.
The optical model to use for mapping between the image and
pupil planes. Can be "onAxis", or "offAxis". onAxis is an
analytic model appropriate for donuts near the optical axis.
It is valid for both slow and fast optical systems. The offAxis
model is a numerically-fit model that is valid for fast optical
systems at wide field angles. offAxis requires an accurate Batoid
model.
Raises
------
Expand Down
81 changes: 42 additions & 39 deletions python/lsst/ts/wep/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ class Instrument:
pixelSize : float, optional
The pixel size in meters.
refBand : BandLabel or str, optional
When getting the wavelength or loading the Batoid model, use this value
in place of BandLabel.REF. It should be a BandLabel Enum, or one of the
corresponding strings. If set to None, this value defaults to BandLabel.REF.
When getting the wavelength or loading the Batoid model, use this
value in place of BandLabel.REF. It should be a BandLabel Enum, or
one of the corresponding strings. If set to None, this value defaults
to BandLabel.REF.
wavelength : float or dict, optional
The effective wavelength of the instrument in meters. Can be a float, or
a dictionary that corresponds to different bands. The keys in this
The effective wavelength of the instrument in meters. Can be a float,
or a dictionary that corresponds to different bands. The keys in this
dictionary are expected to correspond to the strings specified in the
BandLabel enum in jf_wep.utils.enums.
batoidModelName : str, optional
The name used to load the Batoid model, via
batoid.Optic.fromYaml(batoidModelName). If the string contains "{band}",
then it is assumed there are different Batoid models for different
photometric bands, and the names of these bands will be filled in at
runtime using the strings specified in the BandLabel enum in
jf_wep.utils.enums.
Name of Batoid model (used via batoid.Optic.fromYaml(batoidModelName))
If the string contains "{band}", it is assumed there are different
Batoid models for different photometric bands, and the names of these
bands will be filled in at runtime using the strings specified in the
BandLabel enum in jf_wep.utils.enums.
batoidOffsetOptic : str, optional
The optic to offset in the Batoid model in order to simulate
defocal images. When this is None, it defaults to "Detector".
Expand All @@ -82,9 +82,9 @@ class Instrument:
pairs are
- thetaMin: the minimum field angle in degrees for which this mask
element is relevant
- center: list of polynomial coefficients (in meters) for np.polyval
- center: list of polynomial coeffs (in meters) for np.polyval()
to determine the center of the circle
- radius: list of polynomial coefficients (in meters) for np.polyval
- radius: list of polynomial coeffs (in meters) for np.polyval()
to determine the radius of the circle
None defaults to an empty dictionary.
"""
Expand Down Expand Up @@ -294,20 +294,19 @@ def donutDiameter(self) -> float:

@property
def refBand(self) -> BandLabel:
"""The band to use with Batoid and wavelength when band == BandLabel.REF"""
"""Band to use with Batoid and wavelength when band == BandLabel.REF"""
return self._refBand

@refBand.setter
def refBand(self, value: Union[BandLabel, str]) -> None:
"""Set the reference band to use with Batoid and wavelength.
"""Set reference band for loading Batoid model and getting wavelength.
Parameters
----------
value : BandLabel or str
When loading the Batoid model, use this value in place of BandLabel.REF.
It should be a BandLabel Enum, or one of the corresponding strings.
If set to None, this value defaults to BandLabel.REF. Note this only
matters if batoidModelName contains "{band}".
The reference band. Should be a BandLabel Enum, or one of the
corresponding strings. If set to None, this value defaults to
BandLabel.REF.
"""
if value is None:
self._refBand = BandLabel.REF
Expand All @@ -326,8 +325,8 @@ def wavelength(self, value: Union[float, dict]) -> None:
Parameters
----------
value : float or dict
The effective wavelength(s) in meters. Can either be a single float,
or a dictionary mapping BandLabels to floats.
The effective wavelength(s) in meters. Can either be a single
float, or a dictionary mapping BandLabels to floats.
Raises
------
Expand Down Expand Up @@ -374,7 +373,10 @@ def batoidModelName(self) -> Union[str, None]:
def batoidModelName(self, value: Optional[str]) -> None:
"""Set the Batoid model name.
The name should match one of the yaml files in the batoid/data directory:
The Batoid model name is used to load the Batoid model via
batoid.Optic.fromYaml(batoidModelName)
The name must match one of the yaml files in the batoid/data directory:
https://github.com/jmeyers314/batoid/tree/main/batoid/data
You can use "{band}" in the name, and this will be replaced with a band
name when loading the batoid model.
Expand Down Expand Up @@ -447,7 +449,7 @@ def batoidOffsetOptic(self, value: Union[str, None]) -> None:

@property
def batoidOffsetValue(self) -> Union[float, None]:
"""The amount in meters by which the optic is offset in the Batoid model."""
"""Amount in meters the optic is offset in the Batoid model."""
if self.batoidModelName is None:
return None
elif self._batoidOffsetValue is None:
Expand All @@ -457,7 +459,7 @@ def batoidOffsetValue(self) -> Union[float, None]:

@batoidOffsetValue.setter
def batoidOffsetValue(self, value: Union[str, None]) -> None:
"""Set the amount in meters by which the optic is offset in the batoid model.
"""Set amount in meters the optic is offset in the batoid model.
Parameters
----------
Expand Down Expand Up @@ -616,8 +618,9 @@ def _getOffAxisCoeffCached(
The DefocalType Enum or corresponding string, specifying which side
of focus to model.
band : BandLabel or str
The BandLabel Enum or corresponding string, specifying which batoid
model to load. Only relevant if self.batoidModelName contains "{band}".
The BandLabel Enum or corresponding string, specifying which
batoid model to load. Only relevant if self.batoidModelName
contains "{band}".
jmax : int, optional
The maximum Noll index of the off-axis model Zernikes.
Expand Down Expand Up @@ -682,9 +685,9 @@ def getOffAxisCoeff(
The DefocalType Enum or corresponding string, specifying which side
of focus to model.
band : BandLabel or str, optional
The BandLabel Enum or corresponding string, specifying which batoid
model to load. Only relevant if self.batoidModelName contains "{band}".
(the default is BandLabel.REF)
The BandLabel Enum or corresponding string, specifying which
batoid model to load. Only relevant if self.batoidModelName
contains "{band}". (the default is BandLabel.REF)
jmax : int, optional
The maximum Noll index of the off-axis model Zernikes.
(the default is 66)
Expand Down Expand Up @@ -728,16 +731,16 @@ def maskParams(self, value: Optional[dict]) -> None:
Parameters
----------
value : dict or None
Dictionary of mask parameters. Each key in this dictionary corresponds
to a different mask element. The corresponding values are dictionaries
that define circles with different centers and radii. The key, value
pairs are
- thetaMin: the minimum field angle in degrees for which this mask
element is relevant
- center: list of polynomial coefficients (in meters) for np.polyval
to determine the center of the circle
- radius: list of polynomial coefficients (in meters) for np.polyval
to determine the radius of the circle
Dictionary of mask parameters. Each key in this dictionary
corresponds to a different mask element. The corresponding
values are dictionaries that define circles with different
centers and radii. The key, value pairs are
- thetaMin: the minimum field angle in degrees for which
this mask element is relevant
- center: list of polynomial coefficients (in meters) for
np.polyval() to determine the center of the circle
- radius: list of polynomial coefficients (in meters) for
np.polyval() to determine the radius of the circle
None defaults to an empty dictionary.
Raises
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/ts/wep/task/calcZernikesBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class CalcZernikesTaskConfig(


class CalcZernikesBaseTask(pipeBase.PipelineTask, metaclass=abc.ABCMeta):
"""Base class for calculating Zernike coefficients from pairs of DonutStamps."""
"""Base class for calculating Zernike coeffs from pairs of DonutStamps."""

ConfigClass = CalcZernikesTaskConfig
_DefaultName = "calcZernikesBaseTask"
Expand Down Expand Up @@ -201,7 +201,7 @@ def estimateZernikes(
return np.array(zkList)

def getCombinedZernikes(self, zernikeArray: np.ndarray) -> np.ndarray:
"""Combine Zernike coefficients from all pairs to create single estimate.
"""Combine Zernike coeffs from all pairs to create single estimate.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ts/wep/task/cutOutDonutsBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def __init__(self, **kwargs):
self.maskGrowthIter = self.config.maskGrowthIter

def _checkAndSetOffset(self, dataOffsetValue):
"""Check the defocal offset and set to provided value if not yet defined.
"""Check defocal offset and set to provided value if not yet defined.
Parameters
----------
Expand Down
Loading

0 comments on commit 55ec6e2

Please sign in to comment.