From 217bda16d3585587f91f1a42e6a2b7419b06a314 Mon Sep 17 00:00:00 2001 From: tgalvin Date: Sun, 6 Oct 2024 15:43:23 +0800 Subject: [PATCH 1/3] added execuutor type for convolve_cube --- flint/convol.py | 4 +++- tests/test_convol.py | 15 ++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/flint/convol.py b/flint/convol.py index 02376941..4c116f8a 100644 --- a/flint/convol.py +++ b/flint/convol.py @@ -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 @@ -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: @@ -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 diff --git a/tests/test_convol.py b/tests/test_convol.py index ba5bbdaa..9c51ad3a 100644 --- a/tests/test_convol.py +++ b/tests/test_convol.py @@ -68,8 +68,13 @@ def test_get_cube_common_beam_and_convol_cubes(cube_fits) -> None: assert all([isinstance(b, BeamShape) for b in beam_list]) # 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]) From 8ecad5b322281f6a2d9fe3d34d4846b1437b06da Mon Sep 17 00:00:00 2001 From: tgalvin Date: Mon, 7 Oct 2024 14:55:47 +0800 Subject: [PATCH 2/3] added comment to astropy version/broke convolve test up --- pyproject.toml | 2 +- tests/test_convol.py | 125 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c98d6e5e..420a9b69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/tests/test_convol.py b/tests/test_convol.py index 9c51ad3a..abf31d82 100644 --- a/tests/test_convol.py +++ b/tests/test_convol.py @@ -67,6 +67,131 @@ 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 from flint.convol import convolve_cubes From 8f493c441cbfed480dca3bd036bc5fa39d1bd11b Mon Sep 17 00:00:00 2001 From: tgalvin Date: Mon, 7 Oct 2024 15:37:28 +0800 Subject: [PATCH 3/3] added specific git commit to pyproject --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 420a9b69..189bd92f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "*"