Skip to content

Commit

Permalink
Tjgalvin beams (#76)
Browse files Browse the repository at this point in the history
* mock up of target beams

* beams mock / added to cli

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added a test on _get_target_beam

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* corrected inverted check for nchans

* typo and assert fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added checks for nan in target beam props / tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Ruff

* Ruff

---------

Co-authored-by: tgalvin <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tim Galvin <[email protected]>
  • Loading branch information
4 people authored Jan 28, 2025
1 parent d8cfb48 commit 590c372
Show file tree
Hide file tree
Showing 15 changed files with 348 additions and 179 deletions.
32 changes: 15 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile=black"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.9.2"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Docker Build and Push](https://github.com/AlecThomson/RACS-tools/actions/workflows/docker.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/docker.yml) ![Tests](https://github.com/AlecThomson/RACS-tools/actions/workflows/pytest.yml/badge.svg) [![Python package](https://github.com/AlecThomson/RACS-tools/actions/workflows/python-package.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/python-package.yml) [![PyPi](https://github.com/AlecThomson/RACS-tools/actions/workflows/pypi.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/pypi.yml) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/AlecThomson/RACS-tools/master.svg)](https://results.pre-commit.ci/latest/github/AlecThomson/RACS-tools/master)
[![Docker Build and Push](https://github.com/AlecThomson/RACS-tools/actions/workflows/docker.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/docker.yml) ![Tests](https://github.com/AlecThomson/RACS-tools/actions/workflows/pytest.yml/badge.svg) [![Python package](https://github.com/AlecThomson/RACS-tools/actions/workflows/python-package.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/python-package.yml) [![PyPi](https://github.com/AlecThomson/RACS-tools/actions/workflows/pypi.yml/badge.svg)](https://github.com/AlecThomson/RACS-tools/actions/workflows/pypi.yml)[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/AlecThomson/RACS-tools/master.svg)](https://results.pre-commit.ci/latest/github/AlecThomson/RACS-tools/master)

# RACS-tools
Useful scripts for RACS
Expand Down
32 changes: 30 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ numba = "*"
mpi4py = {version = ">=3", optional = true}

[tool.poetry.dev-dependencies]
black = "*"
isort = "*"
ruff = {version = "*", optional = true}

[tool.poetry.extras]
mpi = ["mpi4py"]
Expand All @@ -38,3 +37,32 @@ vcs = "git"
[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"

[tool.ruff]
src = ["racs_tools"]

[tool.ruff.lint]
extend-select = [
# "B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
# "C4", # flake8-comprehensions
# "EM", # flake8-errmsg
"ICN", # flake8-import-conventions
# "G", # flake8-logging-format
# "PGH", # pygrep-hooks
# "PIE", # flake8-pie
# "PL", # pylint
# "PT", # flake8-pytest-style
# "PTH", # flake8-use-pathlib
# "RET", # flake8-return
# "RUF", # Ruff-specific
# "SIM", # flake8-simplify
# "T20", # flake8-print
"UP", # pyupgrade
# "YTT", # flake8-2020
# "EXE", # flake8-executable
# "NPY", # NumPy specific rules
# "PD", # pandas-vet,
# "RET", # flake8-return
]
8 changes: 4 additions & 4 deletions racs_tools/au2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
""" For getting fluxes right in Jy/beam """
"""For getting fluxes right in Jy/beam"""

__author__ = "Tessa Vernstrom"

import math
from typing import List, Tuple

import numpy as np

Expand Down Expand Up @@ -75,8 +75,8 @@ def gaussianDeconvolve(smaj, smin, spa, bmaj, bmin, bpa):


def gauss_factor(
beamConv: List[float], beamOrig: List[float], dx1: float = 1, dy1: float = 1
) -> Tuple[float, float, float, float, float]:
beamConv: list[float], beamOrig: list[float], dx1: float = 1, dy1: float = 1
) -> tuple[float, float, float, float, float]:
"""
Calculates the scaling factor to be applied after convolving
a map in Jy/beam with a gaussian to get fluxes in Jy/beam again.
Expand Down
8 changes: 4 additions & 4 deletions racs_tools/beamcon_2D.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env python
""" Convolve ASKAP images to common resolution """
"""Convolve ASKAP images to common resolution"""

from __future__ import annotations

__author__ = "Alec Thomson"


import logging
import sys
import traceback
from pathlib import Path
from typing import Literal, NamedTuple, Optional
from typing import Literal, NamedTuple

import numpy as np
from astropy import units as u
Expand Down Expand Up @@ -290,7 +290,7 @@ def beamcon_2d_on_fits(
def get_common_beam(
files: list[Path],
conv_mode: Literal["robust", "scipy", "astropy", "astropy_fft"] = "robust",
target_beam: Optional[Beam] = None,
target_beam: Beam | None = None,
cutoff: float | None = None,
tolerance: float = 0.0001,
nsamps: float = 200,
Expand Down
Loading

0 comments on commit 590c372

Please sign in to comment.