diff --git a/.gitignore b/.gitignore index 6e677ae..e8dd03e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,13 @@ __pycache__/ *.py[cod] *$py.class +# Radio Astro +*.fits +*.zarr +*.ms +*.ipynb + + # C extensions *.so diff --git a/contsub/parser/imcontsub.py b/contsub/parser/imcontsub.py index 4763c70..3c9d375 100644 --- a/contsub/parser/imcontsub.py +++ b/contsub/parser/imcontsub.py @@ -55,8 +55,8 @@ def runit(**kwargs): chunks = dict(ra = opts.ra_chunks or 64, dec=None, spectral=None) - - zds = zds_from_fits(infits, chunks=chunks) + rest_freq = opts.rest_freq + zds = zds_from_fits(infits, chunks=chunks, rest_freq=rest_freq) base_dims = ["ra", "dec", "spectral", "stokes"] if not hasattr(zds, "stokes"): base_dims.remove("stokes") @@ -75,13 +75,13 @@ def runit(**kwargs): if len(opts.order) != len(opts.segments): raise ValueError("If setting multiple --order and --segments, they must be of equal length. " - f"Got {len(opts.order)} orders and {len(opts.segments)} segments.") + f"Got {len(opts.order)} orders and {len(opts.segments)} segments.") niter = len(opts.order) nomask = True automask = False if getattr(opts, "mask_image", None): - mask = zds_from_fits(opts.mask_image, chunks=chunks).DATA + mask = zds_from_fits(opts.mask_image, chunks=chunks, rest_freq=rest_freq).DATA nomask = False if getattr(opts, "sigma_clip", None): diff --git a/contsub/parser/imcontsub.yaml b/contsub/parser/imcontsub.yaml index d244fa1..e79df72 100644 --- a/contsub/parser/imcontsub.yaml +++ b/contsub/parser/imcontsub.yaml @@ -24,6 +24,14 @@ inputs: dtype: List[float] policies: repeat: "[]" + default: + - 5 + - 4 + - 3 + automask-per-iter: + info: Generate a new mask per iteration. + dtype: bool + default: False fit-model: info: "### NOT IMPLEMENTED ### Fit function to model the continuum." dtype: str @@ -45,6 +53,9 @@ inputs: dtype: int default: 0 choices: [0,1,2,3] + rest-freq: + info: Cube rest frequency in MHz. Will ignore the one in the FITS header if it exists. + dtype: float stokes-axis: info: "### DEPRECATED #### Set this flag if the input image has a stokes dimension. (Default is True)." default: yes diff --git a/contsub/utils.py b/contsub/utils.py index 3087548..c5c518b 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): +def zds_from_fits(fname, chunks=None, rest_freq=None): """ Creates Zarr store from a FITS file. The resulting array has dimensions = RA, DEC, SPECTRAL[, STOKES] @@ -62,6 +62,8 @@ def zds_from_fits(fname, chunks=None): fds = xds_from_fits(fname)[0] header = fds.hdu.header + if rest_freq: + header["RESTFRQ"] = rest_freq * 1e6 # set it to Hz wcs = WCS(header, naxis="spectral stokes".split()) diff --git a/pyproject.toml b/pyproject.toml index 1cadac4..7abd4b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "contsub" -version = "1.0.2" +version = "1.0.3" description = "Radio astronomy data continuum subtraction tools" authors = ["Amir Kazemi-Moridani, Sphesihle Makhathini, Mika Naidoo"] license = "MIT"