Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks to cube convolution and linmos #176

Merged
merged 3 commits into from
Oct 7, 2024
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: 3 additions & 1 deletion flint/convol.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import warnings
from argparse import ArgumentParser
from pathlib import Path
from typing import Collection, List, NamedTuple, Optional
from typing import Collection, List, Literal, NamedTuple, Optional

import astropy.units as u
import numpy as np
Expand Down Expand Up @@ -131,6 +131,7 @@ def convolve_cubes(
beam_shapes: List[BeamShape],
cutoff: Optional[float] = None,
convol_suffix: str = "conv",
executor_type: Literal["thread", "process", "mpi"] = "thread",
) -> Collection[Path]:
logger.info(f"Will attempt to convol {len(cube_paths)} cubes")
if cutoff:
Expand All @@ -155,6 +156,7 @@ def convolve_cubes(
bmin=beam_minor_list,
bpa=beam_pa_list,
suffix=convol_suffix,
executor_type=executor_type,
)

# Construct the name of the new file created. For the moment this is done
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include = [

[tool.poetry.dependencies]
python = "^3.11"
astropy = "6.1.0"
astropy = "6.1.3" # fixing until units change in 6.1.4 addressed in radio-beam
numpy = "^1.26.0"
python-casacore = "3.5.2" # newer version caused MS errors (maybe related to pre-built wheel)
pydantic = "2.8.2" # version 2.9.0 caused prefect model validation error
Expand All @@ -28,7 +28,7 @@ matplotlib = "*"
prefect = "^2.10.0"
prefect-dask = "^0.2.4"
dask-jobqueue = "*"
RACS-tools = "*"
RACS-tools = { git = "https://github.com/AlecThomson/RACS-tools.git@8e5d919e9938eda19fc7b8a915f855e8b8e0e514" } # allows array of beam shapes in beamcon_3D
aegeantools = "2.3.0"
radio-beam = "^0.3.4"
reproject = "*"
Expand Down
140 changes: 135 additions & 5 deletions tests/test_convol.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,139 @@ def test_get_cube_common_beam_and_convol_cubes(cube_fits) -> None:
assert len(beam_list) == data_shape[0]
assert all([isinstance(b, BeamShape) for b in beam_list])


def test_beam_list_convol(cube_fits):
# These come from the beam_list above
bmaj_arcsec = [
14.7,
14.5,
14.3,
14.2,
14.0,
13.8,
13.8,
13.5,
13.4,
32.9,
float("nan"),
147.5,
13.0,
12.9,
12.9,
12.8,
12.7,
13.0,
40.7,
12.7,
12.3,
12.3,
12.2,
12.1,
12.0,
11.9,
11.9,
11.6,
11.4,
11.6,
11.6,
11.5,
11.4,
11.4,
11.4,
11.3,
]
bmin_arcsec = [
12.4,
12.2,
12.1,
12.0,
11.8,
11.7,
11.7,
11.6,
11.4,
16.2,
float("nan"),
63.7,
11.0,
10.9,
10.8,
10.7,
10.6,
10.8,
16.6,
10.6,
10.3,
10.2,
10.1,
10.0,
9.9,
9.9,
9.8,
9.7,
9.3,
9.6,
9.5,
9.4,
9.4,
9.3,
9.2,
9.2,
]
bpa_deg = [
75.25,
75.02,
74.82,
74.82,
75.0,
75.01,
75.33,
76.03,
75.43,
-21.79,
float("nan"),
160.53,
73.28,
73.22,
76.36,
76.14,
76.07,
74.09,
55.61,
76.84,
75.9,
75.76,
75.96,
75.1,
75.76,
75.65,
75.66,
73.47,
71.63,
75.29,
75.35,
75.69,
75.11,
75.78,
75.84,
75.89,
]

beam_list = [
BeamShape(bmaj_arcsec=bmaj, bmin_arcsec=bmin, bpa_deg=bpa)
for bmaj, bmin, bpa in zip(bmaj_arcsec, bmin_arcsec, bpa_deg)
]

fits_files = list(cube_fits.glob("*sub.fits"))
assert len(fits_files) == 10
# This appears to make pytest lock up
# cube_paths = convolve_cubes(
# cube_paths=fits_files, beam_shapes=beam_list, cutoff=150.0
# )
# assert all([isinstance(p, Path) for p in cube_paths])
# assert all([p.exists() for p in cube_paths])
from flint.convol import convolve_cubes

cube_paths = convolve_cubes(
cube_paths=fits_files,
beam_shapes=beam_list,
cutoff=150.0,
executor_type="process",
)
assert all([isinstance(p, Path) for p in cube_paths])
assert all([p.exists() for p in cube_paths])
Loading