diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 27fbf9a8f..a3d920a69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ ci: autofix_prs: false - autoupdate_schedule: monthly + autoupdate_schedule: quarterly repos: @@ -82,7 +82,7 @@ repos: - id: text-unicode-replacement-char - repo: https://github.com/codespell-project/codespell - rev: v2.4.2 + rev: v2.4.3 hooks: - id: codespell name: codespell (add false positives to pyproject.toml) @@ -94,13 +94,13 @@ repos: - repo: https://github.com/adhtruong/mirrors-typos # use mirrors-typos because `pre-commit autoupdate` drops the version # of the primary typos repo from v1.x.y to v1 - rev: v1.48.0 + rev: v1.49.0 hooks: - id: typos name: typos (add false positives to _typos.toml) - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.20 + rev: v0.16.1 hooks: - id: ruff-check name: ruff-check (see https://docs.astral.sh/ruff/rules) @@ -144,6 +144,6 @@ repos: - mdformat-ruff - repo: https://github.com/tox-dev/pyproject-fmt - rev: v2.25.1 + rev: v2.27.0 hooks: - id: pyproject-fmt diff --git a/xrtpy/__init__.py b/xrtpy/__init__.py index ba3646bec..5391886b0 100644 --- a/xrtpy/__init__.py +++ b/xrtpy/__init__.py @@ -14,4 +14,4 @@ __version__ = "0.0.0" # Then you can be explicit to control what ends up in the namespace, -__all__ = ["response", "__version__"] +__all__ = ["__version__", "response"] diff --git a/xrtpy/image_correction/deconvolve.py b/xrtpy/image_correction/deconvolve.py index 616a0cec1..6052ed52e 100644 --- a/xrtpy/image_correction/deconvolve.py +++ b/xrtpy/image_correction/deconvolve.py @@ -115,7 +115,7 @@ def deconvolve(image_map, niter=5, verbose=False, psf1keV=False): tmp_deconv = tmp_deconv[xcen - ddx : xcen + ddx, ycen - ddy : ycen + ddy] deconv_data = np.minimum(tmp_deconv, 2500.0) - date = datetime.now().ctime() + date = datetime.now().ctime() # noqa: DTZ005 added_hist = f"{__name__}: ({date}) " + deconvolve_hist deconv_meta = image_meta deconv_meta["history"] = image_meta["history"] + added_hist diff --git a/xrtpy/response/__init__.py b/xrtpy/response/__init__.py index 09c577109..d95a58ee7 100644 --- a/xrtpy/response/__init__.py +++ b/xrtpy/response/__init__.py @@ -16,15 +16,15 @@ from . import tools __all__ = [ - "Geometry", - "EntranceFilter", - "Mirror", - "Filter", "CCD", "Channel", - "resolve_filter_name", "EffectiveAreaFundamental", + "EntranceFilter", + "Filter", + "Geometry", + "Mirror", "TemperatureResponseFundamental", + "resolve_filter_name", "temperature_from_filter_ratio", "tools", ] diff --git a/xrtpy/response/channel.py b/xrtpy/response/channel.py index c8f13fafd..c079df200 100644 --- a/xrtpy/response/channel.py +++ b/xrtpy/response/channel.py @@ -8,12 +8,12 @@ from astropy import units as u __all__ = [ - "Geometry", - "EntranceFilter", - "Mirror", - "Filter", "CCD", "Channel", + "EntranceFilter", + "Filter", + "Geometry", + "Mirror", "resolve_filter_name", ] diff --git a/xrtpy/response/effective_area.py b/xrtpy/response/effective_area.py index 30908a694..92c9fb580 100644 --- a/xrtpy/response/effective_area.py +++ b/xrtpy/response/effective_area.py @@ -207,7 +207,7 @@ def observation_date(self, date): -1 ].datetime.strftime("%Y/%m/%d") - modified_time_datetime = datetime.datetime.fromtimestamp( + modified_time_datetime = datetime.datetime.fromtimestamp( # noqa: DTZ006 modified_time_path ).strftime("%Y/%m/%d") @@ -500,7 +500,7 @@ def _transmission_equation(self): def _angular_wavenumber_CCD(self): """Define angular wavenumber on CCD.""" - index, _, cos_a, wavelength_max, _, _, _ = self._transmission_equation + index, _, cos_a, wavelength_max, _, _, _ = self._transmission_equation # noqa: RUF059 # Define wavevector angular_wavenumber = np.array( diff --git a/xrtpy/response/temperature_from_filter_ratio.py b/xrtpy/response/temperature_from_filter_ratio.py index 35f6711ed..132d4d5b0 100644 --- a/xrtpy/response/temperature_from_filter_ratio.py +++ b/xrtpy/response/temperature_from_filter_ratio.py @@ -754,7 +754,7 @@ def make_results_maps(hdr1, hdr2, T_e, EM, T_error, EMerror, extra_metadata): new_hdr["L1_file2"] = filename2 extra_values, extra_comments = split_values_comments(extra_metadata) new_hdr.update(extra_values) - create_date = datetime.now().ctime() + create_date = datetime.now().ctime() # noqa: DTZ005 new_hdr["history"] = f"Created by temperature_from_filter_ratio {create_date}\n" Thdr = new_hdr.copy() Thdr["BUNIT"] = "log10(K)" diff --git a/xrtpy/response/tests/test_effective_area.py b/xrtpy/response/tests/test_effective_area.py index 78941d828..16ed757c6 100644 --- a/xrtpy/response/tests/test_effective_area.py +++ b/xrtpy/response/tests/test_effective_area.py @@ -38,31 +38,32 @@ ] valid_dates = [ - datetime(year=2006, month=9, day=25, hour=22, minute=1, second=1), - datetime(year=2007, month=9, day=22, hour=22, minute=1, second=1), - datetime(year=2009, month=9, day=22, hour=22, minute=1, second=1), - datetime(year=2010, month=9, day=22, hour=22, minute=1, second=1), - datetime(year=2012, month=9, day=22, hour=22, minute=1, second=1), - datetime(year=2015, month=9, day=22, hour=22, minute=1, second=1), - datetime(year=2017, month=9, day=22, hour=22, minute=1, second=1), - datetime(year=2019, month=9, day=23, hour=22, minute=1, second=1), - datetime(year=2020, month=9, day=23, hour=22, minute=1, second=1), - datetime(year=2021, month=9, day=23, hour=22, minute=1, second=1), - datetime(year=2022, month=9, day=23, hour=22, minute=1, second=1), + datetime(year=2006, month=9, day=25, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2007, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2009, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2010, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2012, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2015, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2017, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2019, month=9, day=23, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2020, month=9, day=23, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2021, month=9, day=23, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2022, month=9, day=23, hour=22, minute=1, second=1), # noqa: DTZ001 ] invalid_dates = [ - datetime(year=2006, month=8, day=25, hour=22, minute=1, second=1), - datetime(year=2005, month=9, day=22, hour=22, minute=1, second=1), - datetime(year=2002, month=9, day=22, hour=22, minute=1, second=1), - datetime(year=2000, month=9, day=22, hour=22, minute=1, second=1), - datetime(year=1990, month=9, day=22, hour=22, minute=1, second=1), + datetime(year=2006, month=8, day=25, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2005, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2002, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=2000, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 + datetime(year=1990, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 ] def test_ccd_contam_data_loads(): eff = EffectiveAreaFundamental( - "Al-poly", datetime(year=2013, month=9, day=22, hour=22, minute=1, second=1) + "Al-poly", + datetime(year=2013, month=9, day=22, hour=22, minute=1, second=1), # noqa: DTZ001 ) data = eff.ccd_contam_data assert isinstance(data, dict) @@ -79,7 +80,8 @@ def test_channel_name(channel_name): @pytest.mark.parametrize("name", channel_names) def test_EffectiveArea_filter_name(name): instance = EffectiveAreaFundamental( - name, datetime(year=2013, month=9, day=22, hour=22, minute=0, second=0) + name, + datetime(year=2013, month=9, day=22, hour=22, minute=0, second=0), # noqa: DTZ001 ) assert instance.name == name diff --git a/xrtpy/util/__init__.py b/xrtpy/util/__init__.py index ccec6ca65..8a46c9469 100644 --- a/xrtpy/util/__init__.py +++ b/xrtpy/util/__init__.py @@ -5,10 +5,10 @@ from .filters import solve_filter_name, validate_and_format_filters __all__ = [ + "SSW_MIRRORS", "epoch", "filename2repo_path", "make_exposure_map", - "SSW_MIRRORS", "solve_filter_name", "validate_and_format_filters", ] diff --git a/xrtpy/util/filename2repo_path.py b/xrtpy/util/filename2repo_path.py index 55b615808..6c25bea27 100644 --- a/xrtpy/util/filename2repo_path.py +++ b/xrtpy/util/filename2repo_path.py @@ -67,7 +67,7 @@ def filename2repo_path( mo = date[4:6] dy = date[6:] hr = "H" + time[0:2] + "00" - logging.info(f"yr, mo, dy, hr = {yr}, {mo}, {dy}, {hr}") + logging.info(f"yr, mo, dy, hr = {yr}, {mo}, {dy}, {hr}") # noqa: LOG015 if filename.name[:6] == "L1_XRT": if filename.name[-9:] == "qual.fits": path = root / "data_products" / "Level1_Qual" / yr / mo / dy / hr diff --git a/xrtpy/util/make_exposure_map.py b/xrtpy/util/make_exposure_map.py index a2bc07a5c..571977bed 100644 --- a/xrtpy/util/make_exposure_map.py +++ b/xrtpy/util/make_exposure_map.py @@ -58,28 +58,28 @@ def make_exposure_map(comp_image_file, qualfiles=None, retsatpix=False, verbose= logging.basicConfig(format="%(funcName)s: %(message)s", level=logging.INFO) comp_header = fits.getheader(comp_image_file) short_exp_filepath = Path(comp_header["SRTFNAME"]) - logging.info(f"short exp. file: {short_exp_filepath}") + logging.info(f"short exp. file: {short_exp_filepath}") # noqa: LOG015 short_exp_urlpath = filename2repo_path(short_exp_filepath, join=True) - logging.info(f"short exp. url: {short_exp_urlpath}") + logging.info(f"short exp. url: {short_exp_urlpath}") # noqa: LOG015 short_exp_filepath = download_file(short_exp_urlpath) if "MEDFNAME" in comp_header: triple = True - logging.info("Composite image is a triple") + logging.info("Composite image is a triple") # noqa: LOG015 if qualfiles is None: medium_exp_filename = Path(comp_header["MEDFNAME"]) medium_exp_qualpath = Path( medium_exp_filename.stem + ".qual" + medium_exp_filename.suffix ) medium_exp_urlpath = filename2repo_path(medium_exp_qualpath, join=True) - logging.info(f"medium exp. url: {medium_exp_urlpath}") + logging.info(f"medium exp. url: {medium_exp_urlpath}") # noqa: LOG015 medium_exp_qualpath = download_file(medium_exp_urlpath, allow_insecure=True) else: medium_exp_qualpath = Path(qualfiles[0]) else: medium_exp_filename = None triple = False - logging.info("Composite image is a double") + logging.info("Composite image is a double") # noqa: LOG015 if qualfiles is None: long_exp_filename = Path(comp_header["LNGFNAME"]) @@ -98,7 +98,7 @@ def make_exposure_map(comp_image_file, qualfiles=None, retsatpix=False, verbose= naxis2 = comp_header["NAXIS2"] srt_exp = fits.getval(short_exp_filepath, "EXPTIME") - logging.info(f"Short image exposure time = {srt_exp}") + logging.info(f"Short image exposure time = {srt_exp}") # noqa: LOG015 lng_hdu = fits.open(long_exp_qualpath) lng_exp = lng_hdu[0].header["EXPTIME"] lng_gmap = lng_hdu[0].data @@ -106,7 +106,7 @@ def make_exposure_map(comp_image_file, qualfiles=None, retsatpix=False, verbose= # do bit arithmetic to get saturated pixels lng_sat = (lng_gmap & 1).astype(bool) - logging.info(f"No. of saturated pixels in long exposure = {np.sum(lng_sat)}") + logging.info(f"No. of saturated pixels in long exposure = {np.sum(lng_sat)}") # noqa: LOG015 exp_map = np.ones((naxis1, naxis2)) * lng_exp exp_map[lng_sat] = srt_exp @@ -117,9 +117,9 @@ def make_exposure_map(comp_image_file, qualfiles=None, retsatpix=False, verbose= med_hdu.close() med_sat = (med_gmap & 1).astype(bool) exp_map[~med_sat & lng_sat] = med_exp - logging.info(f"No. of saturated pixels in medium exposure = {np.sum(med_sat)}") - logging.info(f"Medium image exposure time = {med_exp}") - logging.info(f"Long image exposure time = {lng_exp}") + logging.info(f"No. of saturated pixels in medium exposure = {np.sum(med_sat)}") # noqa: LOG015 + logging.info(f"Medium image exposure time = {med_exp}") # noqa: LOG015 + logging.info(f"Long image exposure time = {lng_exp}") # noqa: LOG015 if retsatpix: if triple: