Skip to content

Commit

Permalink
ssins disable diff eavils
Browse files Browse the repository at this point in the history
  • Loading branch information
d3v-null committed Sep 12, 2024
1 parent af12c9d commit 53bd257
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
37 changes: 22 additions & 15 deletions demo/04_ssins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,45 @@
from matplotlib import pyplot as plt
import numpy as np
from astropy.time import Time
from sys import argv, exit
import argparse

data_files = argv[1:]
if len(data_files) > 1 and data_files[-1].endswith(".fits"):
metafits = data_files[0]
parser = argparse.ArgumentParser()
parser.add_argument("--no-diff", default=False, action="store_true")
parser.add_argument("files", nargs="+")
args = parser.parse_args()

if len(args.files) > 1 and args.files[-1].endswith(".fits"):
metafits = args.files[0]
# output name is basename of metafits, or uvfits if provided
base, _ = os.path.splitext(metafits)
elif len(data_files) == 1:
vis = data_files[-1]
elif len(args.files) == 1:
vis = args.files[-1]
base, _ = os.path.splitext(vis)
else:
print(f"Usage: {argv[0]} <metafits> <data ...>")
args.print_usage()
exit(1)

# sky-subtract https://ssins.readthedocs.io/en/latest/sky_subtract.html
ss = SS()
cache = f"{base}.ssa.h5"
diff = not args.no_diff
suffix = ".diff" if diff else ""
cache = f"{base}{suffix}.ssa.h5"
if os.path.exists(cache):
print(f"reading from {cache=}")
ss.read_uvh5(cache, read_data=True, use_future_array_shapes=True)
else:
print(f"reading from {data_files=}")
print(f"reading from {args.files=}")
ss.read(
data_files,
args.files,
read_data=True,
diff=True, # difference timesteps
diff=diff, # difference timesteps
remove_coarse_band=False, # does not work with low freq res
correct_van_vleck=False, # slow
remove_flagged_ants=True, # remove flagged antennas
)
# just look at autos
unflagged_ants = np.unique(ss.ant_1_array)
ss = ss.select(antenna_nums=[(a, a) for a in unflagged_ants], inplace=False)
ss = ss.select(bls=[(a, a) for a in unflagged_ants], inplace=False)
ss.apply_flags(flag_choice="original")
ss.write_uvh5(cache)
print(f"wrote ss to {cache=}")
Expand Down Expand Up @@ -77,12 +83,13 @@
chan_labels = [f"{ch: 8.3f}" for ch in ss.freq_array / 1e6]
nchans_visible = figsize[0] * 72 / fontsize / 2.0 / len(pols)
chan_stride = int(max(1, len(chan_labels) // nchans_visible))
print(f"{time_stride=}, {chan_stride=}")

for i, pol in enumerate(ss.get_pols()):
ax_met, ax_sig = subplots[:, i]

ax_met.set_title(f'{base.split("/")[-1]} ss vis amps {pol}')
ax_met.set_title(
f'{base.split("/")[-1]} ss vis amps {"diff " if diff else " "}{pol}'
)
ax_met.imshow(
ins.metric_array[..., i], aspect="auto", interpolation="none", cmap=cmap
)
Expand All @@ -104,6 +111,6 @@
ax_sig.set_xticks(np.arange(ss.Nfreqs)[::chan_stride])
ax_sig.set_xticklabels(chan_labels[::chan_stride], fontsize=fontsize, rotation=90)

figname = f"{base}.auto_spectrum.png"
figname = f"{base}{suffix}.auto_spectrum.png"
plt.savefig(figname, bbox_inches="tight")
print(f"wrote {figname}")
1 change: 1 addition & 0 deletions demo_data.md5sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ab0a3040c6adfc482ed1485fa080c18f demo/data/1121334536/raw/1121334536_20150719094841_gpubox20_00.fits
dd0b6b540ac7752e3cd741dc0c46f11e demo/data/1303134032/raw/1303134032_20210422134016_gpubox20_00.fits
dabf81a21ab53a585e0afab67636fc9f demo/data/1341914000/raw/1341914000_20220715095302_ch137_000.fits

0 comments on commit 53bd257

Please sign in to comment.