From d1c3e83c6f4d79e47d2dc8027660570bb25b3859 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Fri, 15 Aug 2025 12:54:04 -0400 Subject: [PATCH 1/2] ruff --- aperoll/proseco_data.py | 9 ++++++--- aperoll/widgets/attitude_widget.py | 5 +---- aperoll/widgets/star_plot.py | 1 + ruff-base.toml | 10 +++++++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/aperoll/proseco_data.py b/aperoll/proseco_data.py index feef429..d321978 100644 --- a/aperoll/proseco_data.py +++ b/aperoll/proseco_data.py @@ -147,7 +147,9 @@ def run_proseco(self): "review_table": aca_review, } except Exception as exc: - logger.debug(f"ProsecoData failed calling proseco ({type(exc).__name__}): {exc}") + logger.debug( + f"ProsecoData failed calling proseco ({type(exc).__name__}): {exc}" + ) trace = traceback.extract_tb(exc.__traceback__) for step in trace: logger.debug(f" in {step.filename}:{step.lineno}/{step.name}:") @@ -167,14 +169,15 @@ def run_sparkles(self): ) return self._dir / "sparkles" except Exception as exc: - logger.debug(f"ProsecoData failed calling sparkles ({type(exc).__name__}): {exc}") + logger.debug( + f"ProsecoData failed calling sparkles ({type(exc).__name__}): {exc}" + ) trace = traceback.extract_tb(exc.__traceback__) for step in trace: logger.debug(f" in {step.filename}:{step.lineno}/{step.name}:") logger.debug(f" {step.line}") raise Exception(f"ProsecoData failed calling sparkles: {exc}") from None - def open_export_proseco_dialog(self): """ Save the star catalog in a pickle file. diff --git a/aperoll/widgets/attitude_widget.py b/aperoll/widgets/attitude_widget.py index e730409..0f0e067 100644 --- a/aperoll/widgets/attitude_widget.py +++ b/aperoll/widgets/attitude_widget.py @@ -331,10 +331,7 @@ def _set_attitude(self, attitude, emit=True): if emit: self.attitude_cleared.emit() return - if ( - not isinstance(attitude, Quat) - and len(attitude) == 4 - ): + if not isinstance(attitude, Quat) and len(attitude) == 4: attitude = normalize(attitude) # this check is to break infinite recursion because in the connections q1 = None if attitude is None else Quat(attitude).q diff --git a/aperoll/widgets/star_plot.py b/aperoll/widgets/star_plot.py index b2ae2fd..32bdd34 100644 --- a/aperoll/widgets/star_plot.py +++ b/aperoll/widgets/star_plot.py @@ -798,6 +798,7 @@ def set_centroids(self, centroids): def include_slot(self, slot, include): self.view.include_slot(slot, include) + def main(): from aperoll.utils import get_default_parameters diff --git a/ruff-base.toml b/ruff-base.toml index 836205f..8e9a25a 100644 --- a/ruff-base.toml +++ b/ruff-base.toml @@ -1,5 +1,4 @@ -# Copied originally from pandas. This config requires ruff >= 0.2. -target-version = "py311" +target-version = "py312" # fix = true lint.unfixable = [] @@ -31,6 +30,7 @@ lint.extend-select = [ "ARG001", # Unused function argument "RSE102", # Unnecessary parentheses on raised exception "PERF401", # Use a list comprehension to create a transformed list +"S101", # Use of `assert` detected ] lint.ignore = [ @@ -41,10 +41,13 @@ lint.ignore = [ "B028", # No explicit `stacklevel` keyword argument found "PLR0913", # Too many arguments to function call "PLR1730", # Checks for if statements that can be replaced with min() or max() calls + "PLC0415", # `import` should be at the top-level of a file + "PLW1641", # Class implements `__hash__` if `__eq__` is implemented ] extend-exclude = [ "docs", + "build", ] [lint.pycodestyle] @@ -56,4 +59,5 @@ max-line-length = 100 # E501 reports lines that exceed the length of 100. # - D205: Don't worry about test docstrings # - ARG001: Unused function argument false positives for some fixtures # - E501: Line-too-long -"**/tests/test_*.py" = ["D205", "ARG001", "E501"] +# - S101: Do not use assert +"**/tests/test_*.py" = ["D205", "ARG001", "E501", "S101"] From cac8c0362baa0829320d7c99b73e36cc086ea1d6 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Fri, 15 Aug 2025 12:42:43 -0400 Subject: [PATCH 2/2] when reading yoshi files, interpret the attitude as the target attitude --- aperoll/utils.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/aperoll/utils.py b/aperoll/utils.py index 63b2fc6..d5ca9cf 100644 --- a/aperoll/utils.py +++ b/aperoll/utils.py @@ -6,7 +6,9 @@ import maude import numpy as np +from chandra_aca.drift import get_aca_offsets from chandra_aca.transform import ( + calc_aca_from_targ, pixels_to_yagzag, yagzag_to_pixels, ) @@ -190,9 +192,32 @@ def get_parameters_from_yoshi(filename, obsid=None): yoshi_params = contents[0] # assuming there is only one entry yoshi_params["date"] = yoshi_params["obs_date"] - yoshi_params["ra"] = yoshi_params["ra_targ"] - yoshi_params["dec"] = yoshi_params["dec_targ"] - yoshi_params["roll"] = yoshi_params["roll_targ"] + + # ra/dec/roll in yoshi files are the target atttitude, + # so need to transform to ACA attitude + aca_offset_y, aca_offset_z = get_aca_offsets( + yoshi_params["detector"], + yoshi_params["chip_id"], + yoshi_params["chipx"], + yoshi_params["chipy"], + yoshi_params["obs_date"], + -2.5, + ) + + aca_att = calc_aca_from_targ( + [ + yoshi_params["ra_targ"], + yoshi_params["dec_targ"], + yoshi_params["roll_targ"], + ], + y_off=yoshi_params["offset_y"] / 60 + aca_offset_y / 3600, + z_off=yoshi_params["offset_z"] / 60 + aca_offset_z / 3600, + ) + + yoshi_params["ra"], yoshi_params["dec"], yoshi_params["roll"] = ( + aca_att.equatorial + ) + yoshi_params["instrument"] = yoshi_params["detector"] for key in [ "obs_date",