Skip to content
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ __pycache__/
*.py[cod]
*$py.class

# Radio Astro
*.fits
*.zarr
*.ms
*.ipynb


# C extensions
*.so

Expand Down
8 changes: 4 additions & 4 deletions contsub/parser/imcontsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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):
Expand Down
11 changes: 11 additions & 0 deletions contsub/parser/imcontsub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion contsub/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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())


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down