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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: ".*(.csv|.fits|.fts|.fit|.header|.txt|tca.*|.json|.asdf)$|^CITATION.rst
repos:
# This should be before any formatting hooks like isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.4"
rev: "v0.12.2"
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -26,7 +26,7 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.15.0"
rev: "v1.16.1"
hooks:
- id: mypy
additional_dependencies: [ "types-setuptools" ]
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ version_file = "xrayvision/_version.py"

[tool.mypy]
disable_error_code = "import-untyped"
python_version = "py39"
python_version = "3.9"
allow_redefinition = true

[ tool.gilesbot ]

Expand Down
17 changes: 8 additions & 9 deletions xrayvision/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"""

from typing import Union, Optional
from collections.abc import Iterable
from collections.abc import Iterable, MutableSequence

import astropy.units as u
import numpy as np
from astropy.convolution import Gaussian2DKernel
from astropy.units import Quantity
from numpy.typing import NDArray
from numpy.typing import ArrayLike, NDArray
from scipy import signal
from scipy.ndimage import shift
from sunpy.map.map_factory import Map
Expand Down Expand Up @@ -258,7 +258,7 @@ def ms_clean(
dirty_map: Quantity,
dirty_beam: Quantity,
pixel_size: Quantity[u.arcsec / u.pix],
scales: Union[Iterable, NDArray, None] = None,
scales: Optional[MutableSequence[int]] = None,
clean_beam_width: Quantity = 4.0 * u.arcsec,
gain: float = 0.1,
thres: float = 0.01,
Expand All @@ -281,9 +281,8 @@ def ms_clean(
scale_sizes: NDArray[np.int_] = 2 ** np.arange(number_of_scales)

if scales:
scales = np.array(scales)
number_of_scales = len(scales)
scale_sizes = scales
scale_sizes = scales[:]

scale_sizes = np.where(scale_sizes == 0, 1, scale_sizes)

Expand All @@ -298,10 +297,10 @@ def ms_clean(

# Pre-compute scales, residual maps and dirty beams at each scale and dirty beam cross terms
scales = np.zeros((dirty_map.shape[0], dirty_map.shape[1], number_of_scales))
scaled_residuals = np.zeros((dirty_map.shape[0], dirty_map.shape[1], number_of_scales))
scaled_dirty_beams = np.zeros((dirty_beam.shape[0], dirty_beam.shape[1], number_of_scales))
max_scaled_dirty_beams = np.zeros(number_of_scales)
cross_terms = {}
scaled_residuals: NDArray = np.zeros((dirty_map.shape[0], dirty_map.shape[1], number_of_scales))
scaled_dirty_beams: NDArray = np.zeros((dirty_beam.shape[0], dirty_beam.shape[1], number_of_scales))
max_scaled_dirty_beams: NDArray = np.zeros(number_of_scales)
cross_terms: dict[tuple[int, int], ArrayLike] = {}

for i, scale in enumerate(scale_sizes):
scales[:, :, i] = _component(scale=scale, shape=dirty_map.shape)
Expand Down
Loading