diff --git a/.github/workflows/changelog.yaml b/.github/workflows/changelog.yaml
new file mode 100644
index 0000000..96d8245
--- /dev/null
+++ b/.github/workflows/changelog.yaml
@@ -0,0 +1,19 @@
+name: ChangelogUpdated
+on:
+ pull_request:
+ types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
+ branches:
+ - develop
+jobs:
+ build:
+ name: Check Actions
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v1
+ - name: Changelog check
+ uses: Zomzog/changelog-checker@v1.2.0
+ with:
+ fileName: doc/versionHistory.rst
+ checkNotification: Simple
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml
new file mode 100644
index 0000000..711ced1
--- /dev/null
+++ b/.github/workflows/lint.yaml
@@ -0,0 +1,25 @@
+name: lint
+
+on:
+ - push
+ - pull_request
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.11'
+
+ - name: Install
+ run: |
+ $CONDA/bin/conda install -c lsstts -y ts-pre-commit-config">=0.9.2"
+ $CONDA/bin/conda install -c conda-forge pre-commit -y
+ $CONDA/bin/generate_pre_commit_conf --skip-pre-commit-install
+
+ - name: Run pre commit checks
+ run: $CONDA/bin/pre-commit run --all
diff --git a/.gitignore b/.gitignore
index d205584..38fa5a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,10 +10,9 @@ config.log
*Lib.py
# Pre-commit configs
-.pre-commit-config.yaml
+.mypy.ini
.flake8
.isort.cfg
-.mypy.ini
# Built by sconsUtils
version.py
@@ -37,3 +36,4 @@ pytest_session.txt
# MacOS metadata
.DS_Store
+.clang-format
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..7d3d971
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,33 @@
+repos:
+ - repo: https://github.com/psf/black
+ rev: 23.7.0
+ hooks:
+ - id: black
+
+ - repo: https://github.com/pycqa/flake8
+ rev: 6.1.0
+ hooks:
+ - id: flake8
+
+ - repo: https://github.com/lsst-ts/pre-commit-xmllint
+ rev: v1.0.0
+ hooks:
+ - id: format-xmllint
+
+ - repo: https://github.com/pycqa/isort
+ rev: 5.12.0
+ hooks:
+ - id: isort
+ name: isort (python)
+
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.4.0
+ hooks:
+ - id: check-yaml
+ exclude: conda/meta.yaml|^policy/config/[input|image|output|stamp|opd]
+ - id: check-xml
+
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ rev: v0.0.287
+ hooks:
+ - id: ruff
diff --git a/.ts_pre_commit_config.yaml b/.ts_pre_commit_config.yaml
index e1e33e9..feeb7c7 100644
--- a/.ts_pre_commit_config.yaml
+++ b/.ts_pre_commit_config.yaml
@@ -1,6 +1,10 @@
-check-yaml: true
-check-xml: true
black: true
+check-xml: true
+check-yaml: true
+clang-format: false
flake8: true
+format-xmllint: false
isort: true
mypy: false
+ruff: true
+towncrier: false
diff --git a/bin.src/imgClosedLoop.py b/bin.src/img_closed_loop.py
similarity index 97%
rename from bin.src/imgClosedLoop.py
rename to bin.src/img_closed_loop.py
index 863f3be..86bbfb9 100644
--- a/bin.src/imgClosedLoop.py
+++ b/bin.src/img_closed_loop.py
@@ -24,7 +24,7 @@
import argparse
import logging
-from lsst.ts.imsim.closedLoopTask import ClosedLoopTask
+from lsst.ts.imsim.closed_loop_task import ClosedLoopTask
if __name__ == "__main__":
# Set the parser
diff --git a/doc/conf.py b/doc/conf.py
index fde415c..974eeca 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -5,18 +5,18 @@
import os
-import lsst.ts.imsim
-from documenteer.conf.pipelinespkg import *
+import lsst.ts.imsim # noqa
+from documenteer.conf.pipelinespkg import * # noqa
project = "ts_imsim"
-html_theme_options["logotext"] = project
+html_theme_options["logotext"] = project # noqa
html_title = project
html_short_title = project
doxylink = {}
# Support the sphinx extension of plantuml
-extensions.append("sphinxcontrib.plantuml")
+extensions.append("sphinxcontrib.plantuml") # noqa
# Put the path to plantuml.jar
plantuml_path = (
diff --git a/doc/user-guide/user-guide.rst b/doc/user-guide/user-guide.rst
index 0a23abc..d7ab5ca 100644
--- a/doc/user-guide/user-guide.rst
+++ b/doc/user-guide/user-guide.rst
@@ -4,7 +4,7 @@
User Guide
#####################
-The `ts_imsim` closed loop is designed to run as an executable through the command line as `imgClosedLoop.py`.
+The `ts_imsim` closed loop is designed to run as an executable through the command line as `img_closed_loop.py`.
.. _Installing_ts_imsim:
@@ -46,13 +46,13 @@ Using `ts_imsim`
Running the AOS Closed Loop
---------------------------
-The closed loop is available from the command line after running `scons` with the command `imgClosedLoop.py`.
+The closed loop is available from the command line after running `scons` with the command `img_closed_loop.py`.
A sample command to run 5 iterations of the closed loop with the lsst wavefront sensors is:
.. code-block:: python
- imgClosedLoop.py --output cwfs_imsim_output/ --iter_num 5 --config_pointer_file ts_imsim/policy/config/lsstCamNoPertPointer.yaml --turn_off_atmosphere --turn_off_sky_background
+ img_closed_loop.py --output cwfs_imsim_output/ --iter_num 5 --config_pointer_file ts_imsim/policy/config/lsstCamNoPertPointer.yaml --turn_off_atmosphere --turn_off_sky_background
where the following minimal set of command line options are used:
diff --git a/doc/versionHistory.rst b/doc/versionHistory.rst
index ef275f4..3c107ea 100644
--- a/doc/versionHistory.rst
+++ b/doc/versionHistory.rst
@@ -6,6 +6,14 @@
Version History
##################
+-------------
+0.7.0
+-------------
+
+* Add T&S pre-commit settings to ts_imsim.
+* Change file names to snake_case.
+* Move imgClosedLoop to img_closed_loop.
+
-------------
0.6.3
-------------
diff --git a/python/lsst/ts/imsim/__init__.py b/python/lsst/ts/imsim/__init__.py
index e2de311..69cb82a 100644
--- a/python/lsst/ts/imsim/__init__.py
+++ b/python/lsst/ts/imsim/__init__.py
@@ -19,8 +19,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from .closedLoopTask import *
-from .imsimCmpt import *
-from .obsMetadata import *
-from .opdMetrology import *
-from .skySim import *
+from .closed_loop_task import *
+from .imsim_cmpt import *
+from .obs_metadata import *
+from .opd_metrology import *
+from .sky_sim import *
diff --git a/python/lsst/ts/imsim/closedLoopTask.py b/python/lsst/ts/imsim/closed_loop_task.py
similarity index 99%
rename from python/lsst/ts/imsim/closedLoopTask.py
rename to python/lsst/ts/imsim/closed_loop_task.py
index 272a32b..4ef7076 100644
--- a/python/lsst/ts/imsim/closedLoopTask.py
+++ b/python/lsst/ts/imsim/closed_loop_task.py
@@ -32,10 +32,10 @@
import numpy as np
from lsst.afw.cameraGeom import FIELD_ANGLE, DetectorType
from lsst.daf import butler as dafButler
-from lsst.ts.imsim.imsimCmpt import ImsimCmpt
-from lsst.ts.imsim.obsMetadata import ObsMetadata
-from lsst.ts.imsim.opdMetrology import OpdMetrology
-from lsst.ts.imsim.skySim import SkySim
+from lsst.ts.imsim.imsim_cmpt import ImsimCmpt
+from lsst.ts.imsim.obs_metadata import ObsMetadata
+from lsst.ts.imsim.opd_metrology import OpdMetrology
+from lsst.ts.imsim.sky_sim import SkySim
from lsst.ts.imsim.utils import (
SensorWavefrontError,
get_camera,
@@ -740,7 +740,7 @@ def _generate_images(
imsim_config_yaml["output"]["opd"]["file_name"],
)
if os.path.exists(imsimOpdPath):
- self.log.info(f"OPD already created, moving to analysis.")
+ self.log.info("OPD already created, moving to analysis.")
else:
self.log.info(
f"Writing Imsim Configuration file to {imsim_config_path}"
diff --git a/python/lsst/ts/imsim/imsimCmpt.py b/python/lsst/ts/imsim/imsim_cmpt.py
similarity index 98%
rename from python/lsst/ts/imsim/imsimCmpt.py
rename to python/lsst/ts/imsim/imsim_cmpt.py
index afa24d2..4a846cf 100644
--- a/python/lsst/ts/imsim/imsimCmpt.py
+++ b/python/lsst/ts/imsim/imsim_cmpt.py
@@ -28,9 +28,9 @@
import yaml
from astropy.io import fits
from lsst.afw import cameraGeom
-from lsst.ts.imsim.obsMetadata import ObsMetadata
-from lsst.ts.imsim.opdMetrology import OpdMetrology
-from lsst.ts.imsim.skySim import SkySim
+from lsst.ts.imsim.obs_metadata import ObsMetadata
+from lsst.ts.imsim.opd_metrology import OpdMetrology
+from lsst.ts.imsim.sky_sim import SkySim
from lsst.ts.imsim.utils import (
ModifiedEnvironment,
SensorWavefrontError,
@@ -288,12 +288,12 @@ def add_config_header(self, obs_metadata: ObsMetadata) -> str:
Header information for ImSim config
"""
header_text = " header:\n"
- header_text += f" mjd: *mjd\n"
+ header_text += " mjd: *mjd\n"
header_text += (
f" observationStartMJD: {obs_metadata.mjd - (15/(60*60*24))}\n"
)
- header_text += f" seqnum: *seqnum\n"
- header_text += f" band: *band\n"
+ header_text += " seqnum: *seqnum\n"
+ header_text += " band: *band\n"
header_text += f" fieldRA: {obs_metadata.ra}\n"
header_text += f" fieldDec: {obs_metadata.dec}\n"
header_text += f" rotTelPos: {obs_metadata.rotator_angle}\n"
@@ -605,8 +605,8 @@ def _map_opd_to_zk(self, rot_opd_in_deg: float, num_opd: int) -> np.ndarray:
opd_rot = opd.copy()
# Since to rotate the opd we need to substitue the nan values
# for zeros, we need to find the minimum value of the opd
- # excluding the nan values. Then after the rotation we will discard
- # the values that are smaller than the minimum value.
+ # excluding the nan values. Then after the rotation we will
+ # discard the values that are smaller than the minimum value.
# Note that we use order = 0 to avoid interpolation errors.
min_value = np.nanmin(np.abs(opd_rot))
opd_rot[np.isnan(opd_rot)] = 0.0
diff --git a/python/lsst/ts/imsim/obsMetadata.py b/python/lsst/ts/imsim/obs_metadata.py
similarity index 100%
rename from python/lsst/ts/imsim/obsMetadata.py
rename to python/lsst/ts/imsim/obs_metadata.py
diff --git a/python/lsst/ts/imsim/opdMetrology.py b/python/lsst/ts/imsim/opd_metrology.py
similarity index 99%
rename from python/lsst/ts/imsim/opdMetrology.py
rename to python/lsst/ts/imsim/opd_metrology.py
index d18ec78..bd90dd9 100644
--- a/python/lsst/ts/imsim/opdMetrology.py
+++ b/python/lsst/ts/imsim/opd_metrology.py
@@ -21,8 +21,6 @@
__all__ = ["OpdMetrology"]
-import os
-
import numpy as np
import yaml
from astropy.io import fits
diff --git a/python/lsst/ts/imsim/skySim.py b/python/lsst/ts/imsim/sky_sim.py
similarity index 99%
rename from python/lsst/ts/imsim/skySim.py
rename to python/lsst/ts/imsim/sky_sim.py
index d8c9204..73bcc36 100644
--- a/python/lsst/ts/imsim/skySim.py
+++ b/python/lsst/ts/imsim/sky_sim.py
@@ -24,12 +24,13 @@
import astropy
import numpy as np
from astroplan import Observer
-from lsst.ts.imsim.obsMetadata import ObsMetadata
+from lsst.ts.imsim.obs_metadata import ObsMetadata
from lsst.ts.imsim.utils import get_camera
class SkySim:
"""Initialization of sky simulator class."""
+
def __init__(self) -> None:
# Star ID
self.star_id = np.array([], dtype=int)
diff --git a/python/lsst/ts/imsim/utils/__init__.py b/python/lsst/ts/imsim/utils/__init__.py
index d5fe6a1..88b9815 100644
--- a/python/lsst/ts/imsim/utils/__init__.py
+++ b/python/lsst/ts/imsim/utils/__init__.py
@@ -19,7 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from .metroTool import *
-from .plotUtil import *
-from .sensorWavefrontError import *
+from .metro_tool import *
+from .plot_util import *
+from .sensor_wavefront_error import *
from .utility import *
diff --git a/python/lsst/ts/imsim/utils/metroTool.py b/python/lsst/ts/imsim/utils/metro_tool.py
similarity index 100%
rename from python/lsst/ts/imsim/utils/metroTool.py
rename to python/lsst/ts/imsim/utils/metro_tool.py
diff --git a/python/lsst/ts/imsim/utils/plotUtil.py b/python/lsst/ts/imsim/utils/plot_util.py
similarity index 100%
rename from python/lsst/ts/imsim/utils/plotUtil.py
rename to python/lsst/ts/imsim/utils/plot_util.py
diff --git a/python/lsst/ts/imsim/utils/sensorWavefrontError.py b/python/lsst/ts/imsim/utils/sensor_wavefront_error.py
similarity index 100%
rename from python/lsst/ts/imsim/utils/sensorWavefrontError.py
rename to python/lsst/ts/imsim/utils/sensor_wavefront_error.py
diff --git a/python/lsst/ts/imsim/utils/utility.py b/python/lsst/ts/imsim/utils/utility.py
index 4fe4719..55f2f76 100644
--- a/python/lsst/ts/imsim/utils/utility.py
+++ b/python/lsst/ts/imsim/utils/utility.py
@@ -173,7 +173,8 @@ def __enter__(self) -> None:
def __exit__(self, exc_type: None, exc_val: None, exc_tb: None) -> None:
for key in self._overrides:
- # Restore original values, delete or keep as they are based on the original state
+ # Restore original values, delete or keep as they are
+ # based on the original state.
if key in self._originals:
os.environ[key] = self._originals[key]
else:
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 14dca9c..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,13 +0,0 @@
-[flake8]
-max-line-length = 110
-max-doc-length = 79
-ignore = E133, E203, E226, E228, N802, N803, N806, N812, N813, N815, N816, W503, W504
-exclude =
- bin,
- doc/**,
- **/*/__init__.py,
- **/*/version.py,
- tests/.tests
-
-[options]
-setup_requires=setuptools_scm
diff --git a/tests/test_closedLoopTask.py b/tests/test_closed_loop_task.py
similarity index 98%
rename from tests/test_closedLoopTask.py
rename to tests/test_closed_loop_task.py
index 400d045..e7b334f 100644
--- a/tests/test_closedLoopTask.py
+++ b/tests/test_closed_loop_task.py
@@ -24,8 +24,7 @@
import tempfile
import unittest
-from lsst.ts.imsim.closedLoopTask import ClosedLoopTask
-from lsst.ts.imsim.obsMetadata import ObsMetadata
+from lsst.ts.imsim import ClosedLoopTask, ObsMetadata
from lsst.ts.imsim.utils.utility import get_module_path
from lsst.ts.wep.utils import CamType, FilterType
diff --git a/tests/test_imsimCmpt.py b/tests/test_imsim_cmpt.py
similarity index 98%
rename from tests/test_imsimCmpt.py
rename to tests/test_imsim_cmpt.py
index 319143e..dfbea0d 100644
--- a/tests/test_imsimCmpt.py
+++ b/tests/test_imsim_cmpt.py
@@ -26,11 +26,9 @@
import galsim
import numpy as np
import yaml
-from lsst.ts.imsim.imsimCmpt import ImsimCmpt
-from lsst.ts.imsim.obsMetadata import ObsMetadata
-from lsst.ts.imsim.skySim import SkySim
-from lsst.ts.imsim.utils.sensorWavefrontError import SensorWavefrontError
-from lsst.ts.imsim.utils.utility import (
+from lsst.ts.imsim import ImsimCmpt, ObsMetadata, SkySim
+from lsst.ts.imsim.utils import (
+ SensorWavefrontError,
get_camera,
get_config_dir,
get_module_path,
diff --git a/tests/test_obsMetadata.py b/tests/test_obs_metadata.py
similarity index 97%
rename from tests/test_obsMetadata.py
rename to tests/test_obs_metadata.py
index 36c537c..0efe11d 100644
--- a/tests/test_obsMetadata.py
+++ b/tests/test_obs_metadata.py
@@ -21,7 +21,7 @@
import unittest
-from lsst.ts.imsim.obsMetadata import ObsMetadata
+from lsst.ts.imsim import ObsMetadata
class TestObsMetadata(unittest.TestCase):
diff --git a/tests/test_opdMetrology.py b/tests/test_opd_metrology.py
similarity index 99%
rename from tests/test_opdMetrology.py
rename to tests/test_opd_metrology.py
index 5eb96f7..3bd6ffa 100644
--- a/tests/test_opdMetrology.py
+++ b/tests/test_opd_metrology.py
@@ -26,7 +26,7 @@
import numpy as np
from astropy.io import fits
from lsst.afw.cameraGeom import FIELD_ANGLE
-from lsst.ts.imsim.opdMetrology import OpdMetrology
+from lsst.ts.imsim import OpdMetrology
from lsst.ts.imsim.utils.utility import get_module_path, get_zk_from_file
diff --git a/tests/test_skySim.py b/tests/test_sky_sim.py
similarity index 97%
rename from tests/test_skySim.py
rename to tests/test_sky_sim.py
index cc12e3d..fa6b4f4 100644
--- a/tests/test_skySim.py
+++ b/tests/test_sky_sim.py
@@ -24,8 +24,7 @@
from astroplan import FixedTarget, Observer
from astropy.time import Time
-from lsst.ts.imsim.obsMetadata import ObsMetadata
-from lsst.ts.imsim.skySim import SkySim
+from lsst.ts.imsim import ObsMetadata, SkySim
from lsst.ts.imsim.utils.utility import get_module_path
diff --git a/tests/utils/test_plotUtil.py b/tests/utils/test_plot_util.py
similarity index 94%
rename from tests/utils/test_plotUtil.py
rename to tests/utils/test_plot_util.py
index 9b1653a..28bbe06 100644
--- a/tests/utils/test_plotUtil.py
+++ b/tests/utils/test_plot_util.py
@@ -22,8 +22,7 @@
import os
import unittest
-from lsst.ts.imsim.utils.plotUtil import plot_fwhm_of_iters
-from lsst.ts.imsim.utils.utility import get_module_path
+from lsst.ts.imsim.utils import get_module_path, plot_fwhm_of_iters
class TestPlotUtil(unittest.TestCase):
diff --git a/tests/utils/test_sensorWavefrontError.py b/tests/utils/test_sensor_wavefront_error.py
similarity index 98%
rename from tests/utils/test_sensorWavefrontError.py
rename to tests/utils/test_sensor_wavefront_error.py
index aadcdd7..b713c14 100644
--- a/tests/utils/test_sensorWavefrontError.py
+++ b/tests/utils/test_sensor_wavefront_error.py
@@ -22,7 +22,7 @@
import unittest
import numpy as np
-from lsst.ts.imsim.utils.sensorWavefrontError import SensorWavefrontError
+from lsst.ts.imsim.utils import SensorWavefrontError
class TestSensorWavefrontError(unittest.TestCase):
diff --git a/tests/utils/test_utility.py b/tests/utils/test_utility.py
index 03fd19a..fb8c33c 100644
--- a/tests/utils/test_utility.py
+++ b/tests/utils/test_utility.py
@@ -24,7 +24,7 @@
from lsst.afw import cameraGeom
from lsst.obs.lsst import LsstCam
-from lsst.ts.imsim.utils.utility import (
+from lsst.ts.imsim.utils import (
ModifiedEnvironment,
get_camera,
get_config_dir,