From 53bd25765f2a76e6e5eba3122906ad6d2b678226 Mon Sep 17 00:00:00 2001 From: d3v-null Date: Thu, 12 Sep 2024 19:06:04 +0800 Subject: [PATCH] ssins disable diff eavils --- demo/04_ssins.py | 37 ++++++++++++++++++++++--------------- demo_data.md5sum | 1 + 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/demo/04_ssins.py b/demo/04_ssins.py index 883330e..919cd9a 100755 --- a/demo/04_ssins.py +++ b/demo/04_ssins.py @@ -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]} ") + 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=}") @@ -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 ) @@ -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}") diff --git a/demo_data.md5sum b/demo_data.md5sum index df3260f..323381d 100644 --- a/demo_data.md5sum +++ b/demo_data.md5sum @@ -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