From f13d63739fc1f7850000f4a9f5fe89cc0d990b0d Mon Sep 17 00:00:00 2001 From: sphemakh Date: Sat, 30 Aug 2025 12:57:52 +0200 Subject: [PATCH 1/2] Fixes #25 --- contsub/parser/imcontsub.py | 2 +- contsub/parser/imcontsub.yaml | 5 +++++ contsub/utils.py | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/contsub/parser/imcontsub.py b/contsub/parser/imcontsub.py index 3c9d375..ad69b31 100644 --- a/contsub/parser/imcontsub.py +++ b/contsub/parser/imcontsub.py @@ -56,7 +56,7 @@ def runit(**kwargs): chunks = dict(ra = opts.ra_chunks or 64, dec=None, spectral=None) rest_freq = opts.rest_freq - zds = zds_from_fits(infits, chunks=chunks, rest_freq=rest_freq) + zds = zds_from_fits(infits, chunks=chunks, rest_freq=rest_freq, hdu_idx=opts.hdu_index) base_dims = ["ra", "dec", "spectral", "stokes"] if not hasattr(zds, "stokes"): base_dims.remove("stokes") diff --git a/contsub/parser/imcontsub.yaml b/contsub/parser/imcontsub.yaml index e79df72..94d2b26 100644 --- a/contsub/parser/imcontsub.yaml +++ b/contsub/parser/imcontsub.yaml @@ -60,6 +60,11 @@ inputs: info: "### DEPRECATED #### Set this flag if the input image has a stokes dimension. (Default is True)." default: yes dtype: bool + hdu-index: + info: FITS primary HDU index + dtype: int + default: 0 + abbreviation: hi ra-chunks: info: Chunking along RA-axis. If set to zero, no Chunking is perfomed. dtype: int diff --git a/contsub/utils.py b/contsub/utils.py index c5c518b..d588d9a 100644 --- a/contsub/utils.py +++ b/contsub/utils.py @@ -43,7 +43,7 @@ def get_automask(xspec, cube, sigma_clip=5, order=3, segments=400): return mask -def zds_from_fits(fname, chunks=None, rest_freq=None): +def zds_from_fits(fname, chunks=None, rest_freq=None, hdu_idx=0): """ Creates Zarr store from a FITS file. The resulting array has dimensions = RA, DEC, SPECTRAL[, STOKES] @@ -59,7 +59,7 @@ def zds_from_fits(fname, chunks=None, rest_freq=None): Zarr: Zarr array (persistant store, mode=w) """ chunks = chunks or dict(ra=64,dec=None, spectral=None) - fds = xds_from_fits(fname)[0] + fds = xds_from_fits(fname, hdus=hdu_idx)[0] header = fds.hdu.header if rest_freq: From 55c56b87c4eb0f2bd31d0d464f64f7957eb74713 Mon Sep 17 00:00:00 2001 From: sphemakh Date: Sat, 30 Aug 2025 12:59:45 +0200 Subject: [PATCH 2/2] Fixes #25 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7abd4b3..56196bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "contsub" -version = "1.0.3" +version = "1.0.4" description = "Radio astronomy data continuum subtraction tools" authors = ["Amir Kazemi-Moridani, Sphesihle Makhathini, Mika Naidoo"] license = "MIT"