Skip to content

Commit

Permalink
Version bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecThomson committed Dec 4, 2024
1 parent b8e447f commit 82e2100
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
36 changes: 19 additions & 17 deletions arrakis/imager.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,26 @@ def make_cube(
logger = get_run_logger()

logger.info(f"Creating cube for {pol=} {image_set.ms=}")
image_list = image_set.image_lists[pol]
image_list = [Path(i) for i in image_set.image_lists[pol]]

image_type = "restored" if aux_mode is None else aux_mode

# Create a cube name
old_name = image_list[0]
out_dir = os.path.dirname(old_name)
old_base = os.path.basename(old_name)
new_base = old_base
b_idx = new_base.find("beam") + len("beam") + 2
sub = new_base[b_idx:]
new_base = new_base.replace(sub, ".conv.fits")
new_base = new_base.replace("image", f"image.{image_type}.{pol.lower()}")
new_name = Path(out_dir) / new_base

# First combine images into cubes
hdu_list, freqs = combine_fits(file_list=image_list, create_blanks=True)
new_header = hdu_list[0].header
data_cube = hdu_list[0].data
_ = combine_fits(file_list=image_list, out_cube=new_name, create_blanks=True)
with fits.open(new_name, mode="denywrite", memmap=True) as hdu_list:
new_header = hdu_list[0].header
data_cube = hdu_list[0].data

# Add pol angle to header
new_header["INSTRUMENT_RECEPTOR_ANGLE"] = (
Expand All @@ -610,16 +622,6 @@ def make_cube(
# Calculate rms noise
rmss_arr = mad_std(data_cube, axis=(1, 2, 3), ignore_nan=True)

# Create a cube name
old_name = image_list[0]
out_dir = os.path.dirname(old_name)
old_base = os.path.basename(old_name)
new_base = old_base
b_idx = new_base.find("beam") + len("beam") + 2
sub = new_base[b_idx:]
new_base = new_base.replace(sub, ".conv.fits")
new_base = new_base.replace("image", f"image.{image_type}.{pol.lower()}")
new_name = os.path.join(out_dir, new_base)
# Deserialise beam
with open(common_beam_pkl, "rb") as f:
common_beam = pickle.load(f)
Expand All @@ -633,9 +635,9 @@ def make_cube(
# 0 1234.5
# 1 6789.0
# etc.
new_w_name = new_name.replace(
f"image.{image_type}", f"weights.{image_type}"
).replace(".fits", ".txt")
new_w_name = Path(
new_name.as_posix().replace(f"image.{image_type}", f"weights.{image_type}")
).with_suffix(".txt")
data = dict(
Channel=np.arange(len(rmss_arr)),
Weight=1 / rmss_arr**2, # Want inverse variance
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ RMTable = ">=1.2.1"
RM-Tools = ">=1.4.2"
PolSpectra = ">=1.1.0"
setuptools = "*"
fixms = ">=0.2.6"
fitscube = ">=0.3"
fixms = ">=0.3.3"
fitscube = ">=0.5.1"
psycopg2-binary = "*"
sqlalchemy = "*"
scikit-image = ">=0.23"
Expand Down

0 comments on commit 82e2100

Please sign in to comment.