Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

ci:
autofix_prs: false
autoupdate_schedule: monthly
autoupdate_schedule: quarterly

repos:

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion xrtpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion xrtpy/image_correction/deconvolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions xrtpy/response/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
8 changes: 4 additions & 4 deletions xrtpy/response/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from astropy import units as u

__all__ = [
"Geometry",
"EntranceFilter",
"Mirror",
"Filter",
"CCD",
"Channel",
"EntranceFilter",
"Filter",
"Geometry",
"Mirror",
"resolve_filter_name",
]

Expand Down
4 changes: 2 additions & 2 deletions xrtpy/response/effective_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion xrtpy/response/temperature_from_filter_ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
38 changes: 20 additions & 18 deletions xrtpy/response/tests/test_effective_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion xrtpy/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
2 changes: 1 addition & 1 deletion xrtpy/util/filename2repo_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions xrtpy/util/make_exposure_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -98,15 +98,15 @@ 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
lng_hdu.close()

# 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

Expand All @@ -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:
Expand Down
Loading