def test_INS_plot(): obs = '1061313128_99bl_1pol_half_time' insfile = os.path.join(DATA_PATH, '%s_SSINS.h5' % obs) outdir = os.path.join(DATA_PATH, 'test_plots') prefix = '%s/%s' % (outdir, obs) outfile = '%s_SSINS.pdf' % prefix log_prefix = '%s/%s_log' % (outdir, obs) log_outfile = '%s_SSINS.pdf' % log_prefix ins = INS(insfile) xticks = np.arange(0, 384, 96) xticklabels = ['%.1f' % (10**-6 * ins.freq_array[tick]) for tick in xticks] yticks = np.arange(0, 50, 10) yticklabels = ['%i' % (2 * tick) for tick in yticks] cp.INS_plot(ins, prefix) cp.INS_plot(ins, log_prefix, log=True, xticks=xticks, yticks=yticks, xticklabels=xticklabels, yticklabels=yticklabels, title='Title') assert os.path.exists(outfile), "The first plot was not made" assert os.path.exists(log_outfile), "The second plot was not made" os.remove(outfile) os.remove(log_outfile) os.rmdir(outdir)
def test_INS_plot(): matplotlib = pytest.importorskip("matplotlib") obs = '1061313128_99bl_1pol_half_time' insfile = os.path.join(DATA_PATH, f'{obs}_SSINS.h5') outdir = os.path.join(DATA_PATH, 'test_plots') prefix = f'{outdir}/{obs}_raw' outfile = f'{prefix}_SSINS.pdf' log_prefix = f'{outdir}/{obs}_log' log_outfile = f'{log_prefix}_SSINS.pdf' symlog_prefix = f'{outdir}/{obs}_symlog' symlog_outfile = f'{symlog_prefix}_SSINS.pdf' ins = INS(insfile) xticks = np.arange(0, 384, 96) xticklabels = ['%.1f' % (10**-6 * ins.freq_array[tick]) for tick in xticks] yticks = np.arange(0, 50, 10) yticklabels = ['%i' % (2 * tick) for tick in yticks] # Make lst straddle the 2pi boundary to trigger the warning mean_lst = np.mean(ins.lst_array) ins.lst_array += (2 * np.pi) - mean_lst ins.lst_array[ins.lst_array > (2 * np.pi)] -= 2 * np.pi with pytest.warns(UserWarning, match="LSTs appear to cross"): cp.INS_plot(ins, prefix, backend='Agg', use_extent=True, extent_time_format='lst') with pytest.warns(UserWarning, match="Plotting keyword"): cp.INS_plot(ins, log_prefix, log=True, xticks=xticks, yticks=yticks, xticklabels=xticklabels, yticklabels=yticklabels, title='Title') cp.INS_plot(ins, symlog_prefix, symlog=True, xticks=xticks, yticks=yticks, xticklabels=xticklabels, yticklabels=yticklabels, use_extent=False) assert os.path.exists(outfile), "The first plot was not made" assert os.path.exists(log_outfile), "The second plot was not made" assert os.path.exists(symlog_outfile), "The third plot was not made" os.remove(outfile) os.remove(log_outfile) os.remove(symlog_outfile) os.rmdir(outdir)
def test_INS_plot(): matplotlib = pytest.importorskip("matplotlib") obs = '1061313128_99bl_1pol_half_time' insfile = os.path.join(DATA_PATH, '%s_SSINS.h5' % obs) outdir = os.path.join(DATA_PATH, 'test_plots') prefix = '%s/%s_raw' % (outdir, obs) outfile = '%s_SSINS.pdf' % prefix log_prefix = '%s/%s_log' % (outdir, obs) log_outfile = '%s_SSINS.pdf' % log_prefix symlog_prefix = '%s/%s_symlog' % (outdir, obs) symlog_outfile = '%s_SSINS.pdf' % symlog_prefix ins = INS(insfile) xticks = np.arange(0, 384, 96) xticklabels = ['%.1f' % (10**-6 * ins.freq_array[tick]) for tick in xticks] yticks = np.arange(0, 50, 10) yticklabels = ['%i' % (2 * tick) for tick in yticks] cp.INS_plot(ins, prefix, backend='Agg') cp.INS_plot(ins, log_prefix, log=True, xticks=xticks, yticks=yticks, xticklabels=xticklabels, yticklabels=yticklabels, title='Title') cp.INS_plot(ins, symlog_prefix, symlog=True, xticks=xticks, yticks=yticks, xticklabels=xticklabels, yticklabels=yticklabels, use_extent=False) assert os.path.exists(outfile), "The first plot was not made" assert os.path.exists(log_outfile), "The second plot was not made" assert os.path.exists(symlog_outfile), "The third plot was not made" os.remove(outfile) os.remove(log_outfile) os.remove(symlog_outfile) os.rmdir(outdir)
def test_sig_plot(): matplotlib = pytest.importorskip("matplotlib") obs = '1061313128_99bl_1pol_half_time' insfile = os.path.join(DATA_PATH, '%s_SSINS.h5' % obs) outdir = os.path.join(DATA_PATH, 'test_plots') prefix = '%s/%s_flagged' % (outdir, obs) dataplotfile = '%s_SSINS.pdf' % prefix outfile = '%s_SSINS_sig.pdf' % prefix ins = INS(insfile) shape_dict = { 'TV6': [1.74e8, 1.81e8], 'TV7': [1.81e8, 1.88e8], 'TV8': [1.88e8, 1.95e8] } sig_thresh = {'TV6': 5, 'TV7': 5, 'TV8': 5, 'narrow': 5, 'streak': 5} mf = MF(ins.freq_array, sig_thresh, shape_dict=shape_dict) mf.apply_match_test(ins) xticks = np.arange(0, 384, 96) xticklabels = ['%.1f' % (10**-6 * ins.freq_array[tick]) for tick in xticks] yticks = np.arange(0, 50, 10) yticklabels = ['%i' % (2 * tick) for tick in yticks] cp.INS_plot(ins, prefix) assert os.path.exists(outfile), "The first plot was not made" assert os.path.exists(dataplotfile), "The second plot was not made" os.remove(outfile) os.remove(dataplotfile) os.rmdir(outdir)
# Pre-flagged and Post-flagged cp.VDH_plot(ss, prefix, file_ext='pdf', xlabel='Visibility Differences', xscale='log', yscale='log', legend=True, ylim=None, density=False, pre_flag=True, post_flag=True, pre_model=True, post_model=True, pre_label='Pre flagging', post_label='Post flagging', pre_model_label='Pre Model', post_model_label='Post Model', pre_model_color='green', post_model_color='yellow', pre_color='red', post_color='blue', font_size='medium') # Create an INS object and use uvfits file ins = INS(ss) # Make a INS plot # Pre-flagged and Post-flagged cp.INS_plot(ins, prefix, file_ext='.pdf')
shape_dict = { 'TV4': [1.74e8, 1.82e8], 'TV5': [1.82e8, 1.9e8], 'TV6': [1.9e8, 1.98e8], 'dig1': [1.125e8, 1.15625e8], 'dig2': [1.375e8, 1.40625e8], 'dig3': [1.625e8, 1.65625e8], 'dig4': [1.875e8, 1.90625e8] } ss.INS_prepare() ss.INS.save() cp.INS_plot(ss.INS, ms_vmin=-5, ms_vmax=5, vmin=0, vmax=0.03, aspect=ss.UV.Nfreqs / ss.UV.Ntimes) ss.INS.data[:, 0, :82] = np.ma.masked ss.INS.data[:, 0, -21:] = np.ma.masked ss.INS.data_ms = ss.INS.mean_subtract(order=1) ss.MF_prepare(sig_thresh=5, N_thresh=20, shape_dict=shape_dict) ss.MF.apply_match_test(apply_N_thresh=True, order=1) ss.INS.data[ss.INS.data > 0.03] = np.ma.masked ss.INS.data_ms = ss.INS.mean_subtract(order=0) ss.INS.save() cp.MF_plot(ss.MF, ms_vmin=-5, ms_vmax=5,
outpath = '%s/test_combines' % basedir insarray = [] for x in obs: read_paths = util.read_paths_construct(basedir, 'None', x, 'INS') insarray.append( INS(obs=x, outpath=outpath, read_paths=read_paths, flag_choice='orginal')) inscombined = INS_helpers.INS_concat(insarray, axis=0) inscombined.obs = 'LWA_50to60' inscombined.outpath = outpath inscombined.vis_units = insarray[0].vis_units inscombined.pols = insarray[0].pols inscombined.save() cp.INS_plot(inscombined, vmax=.05, ms_vmax=5, ms_vmin=-5) shape_dict = {'44MHZ': [44e6, 45e6], '40.6MHZ': [40.4e6, 40.7e6]} sig_thresh = 4.35 mf = MF(inscombined, shape_dict=shape_dict, sig_thresh=sig_thresh, point=False, streak=False) mf.apply_match_test() cp.MF_plot(mf, ms_vmin=-mf.sig_thresh, ms_vmax=mf.sig_thresh)
read_paths = { 'data': arr, 'Nbls': '%s/arrs/%s_%s_INS_Nbls.npym' % (args.inpath, obs, args.flag_choice), 'freq_array': '%s/metadata/%s_freq_array.npy' % (args.inpath, obs), 'pols': '%s/metadata/%s_pols.npy' % (args.inpath, obs), 'vis_units': '%s/metadata/%s_vis_units.npy' % (args.inpath, obs) } ins = INS(obs=obs, outpath=args.outpath, flag_choice=args.flag_choice, read_paths=read_paths) # ins.data[:, :, :82] = np.ma.masked # ins.data[:, :, -21:] = np.ma.masked ins.data_ms = ins.mean_subtract() ins.counts, ins.bins, ins.sig_thresh = ins.hist_make() cp.INS_plot(ins, **ms_plot_kwargs) mf = MF(ins, shape_dict=shape_dict, point=args.point, streak=args.streak, **mf_kwargs) for test in args.tests: getattr(mf, 'apply_%s_test' % test)(args.order) ins.save() cp.MF_plot(mf, **ms_plot_kwargs)
parser = argparse.ArgumentParser() parser.add_argument('obs') parser.add_argument('inpath') parser.add_argument('outpath') args = parser.parse_args() ss = SS(inpath=args.inpath, outpath=args.outpath, obs=args.obs, flag_choice='original', bad_time_indices=[0, -1, -2, -3, -4, -5], read_kwargs={'ant_str': 'cross'}) ss.INS_prepare() ss.INS.save() cp.INS_plot(ss.INS) for sig_thresh in [5, 10, 20, 40, 80]: ss.MF_prepare(sig_thresh=sig_thresh, N_thresh=15, shape_dict={ 'TV6': [1.74e8, 1.81e8], 'TV7': [1.81e8, 1.88e8], 'TV8': [1.88e8, 1.95e8], 'broad6': [1.72e8, 1.83e8], 'broad7': [1.79e8, 1.9e8], 'broad8': [1.86e8, 1.97e8] }) ss.MF.apply_match_test() cp.INS_plot(ss.INS, sig_thresh=sig_thresh) del ss.INS del ss.MF
args = parser.parse_args() if args.labels is not None: shape_dict = {label: [min, max] for (label, min, max) in zip(args.labels, args.mins, args.maxs)} else: shape_dict = {} obslist = util.make_obslist(args.obsfile) edges = [0 + 16 * i for i in range(24)] + [15 + 16 * i for i in range(24)] freqs = np.load('/Users/mike_e_dubs/python_stuff/MJW-MWA/Useful_Information/MWA_Highband_Freq_Array.npy') for i, obs in enumerate(obslist): read_paths = util.read_paths_INS(args.basedir, args.flag_choice, obs) ins = INS(read_paths=read_paths, flag_choice=args.flag_choice, obs=obs, outpath=args.outdir, order=args.order) cp.INS_plot(ins) mf = MF(ins, sig_thresh=5, shape_dict=shape_dict) mf.apply_match_test(order=args.order) cp.MF_plot(mf) if not i: occ_num = np.ma.masked_array(mf.INS.data.mask) occ_den = np.ma.masked_array(np.ones(occ_num.shape)) occ_num[:, 0, edges] = np.ma.masked occ_den[:, 0, edges] = np.ma.masked else: occ_num = occ_num + mf.INS.data.mask occ_den = occ_den + np.ones(occ_num.shape) occ_freq = occ_num.sum(axis=(0, 1, 3)) / occ_den.sum(axis=(0, 1, 3)) * 100 occ_total = occ_num.sum() / occ_den.sum() * 100 fig, ax = plt.subplots(figsize=(14, 8))
import argparse from SSINS import util from SSINS import INS from SSINS import Catalog_Plot as cp from matplotlib import cm parser = argparse.ArgumentParser() parser.add_argument('basedir') parser.add_argument('outdir') parser.add_argument('obsfile') parser.add_argument('flag_choice') parser.add_argument('order', type=int) args = parser.parse_args() obslist = util.make_obslist(args.obsfile) for obs in obslist: read_paths = util.read_paths_INS(args.basedir, args.flag_choice, obs) ins = INS(read_paths=read_paths, flag_choice=args.flag_choice, obs=obs, outpath=args.outdir, order=args.order) cp.INS_plot(ins, ms_vmax=5, ms_vmin=-5, vmin=0, vmax=0.13, data_cmap=cm.viridis)
import pickle obslist = util.make_obslist( '/Users/mike_e_dubs/MWA/Obs_Lists/sidelobe_survey_obsIDs.txt') indir = '/Users/mike_e_dubs/MWA/INS/Diffuse' outpath = '%s_Filtered' % indir sig_thresh = 5 shape_dict = { 'TV6': [1.74e8, 1.81e8], 'TV7': [1.81e8, 1.88e8], 'TV8': [1.88e8, 1.95e8] } mf_kwargs = {'sig_thresh': sig_thresh, 'shape_dict': shape_dict} occ_dict = {} for obs in obslist: if len(glob.glob('%s/figs/%s*' % (indir, obs))): read_paths = util.read_paths_construct(indir, None, obs, 'INS') ins = INS(obs=obs, outpath=outpath, read_paths=read_paths) ins.data[-5:] = np.ma.masked ins.data[0] = np.ma.masked ins.data_ms = ins.mean_subtract() mf = MF(ins, **mf_kwargs) mf.apply_match_test() cp.MF_plot(mf) cp.INS_plot(ins, ms_vmin=-5, ms_vmax=5) occ_dict['obs'] = (np.count_nonzero(ins.data_ms.mask[:-3]) / ins.data[:-3].size) del ins del mf pickle.dump(occ_dict, open('%s/occ_dict_only_subflags' % outpath, 'wb'))
ss.select(bls=snap_bls) ss.select(ant_str='cross') ins = INS(ss) # Clear some memory del ss # Write the raw data and z-scores to h5 format ins.write(prefix, sep='.', clobber=args.clobber) ins.write(prefix, output_type='z_score', sep='.', clobber=args.clobber) # Write out plots cp.INS_plot(ins, f'{prefix}_RAW', vmin=0, vmax=20000, ms_vmin=-5, ms_vmax=5) # Flag FM radio where_FM = np.where( np.logical_and(ins.freq_array > 87.5e6, ins.freq_array < 108e6)) ins.metric_array[:, where_FM] = np.ma.masked ins.metric_ms = ins.mean_subtract() ins.history += "Manually flagged the FM band. " # Make a filter with specified settings with open(args.shape_dict, 'r') as shape_file: shape_dict = yaml.safe_load(shape_file) sig_thresh = {shape: args.other_sig for shape in shape_dict}
return(xticks, xticklabels) parser = argparse.ArgumentParser() parser.add_argument('obslist') args = parser.parse_args() obslist = util.make_obslist(args.obslist) obsdir = '/Volumes/Faramir/uvfits' outdir = '/Users/mikewilensky/2016_funny_flag' freqlist = np.arange(170, 200, 5) * 10**6 for obs in obslist: filepath = '%s/%s_uvfits/%s.uvfits' % (obsdir, obs, obs) prefix = '%s/%s' % (outdir, obs) outpath = '%s_SSINS_data.h5' % prefix if not os.path.exists(outpath): ss = SS() ss.read(filepath, read_data=False) ss.read(filepath, times=np.unique(ss.time_array)[2:-3]) ins = INS(ss) ins.write(prefix) else: ins = INS(outpath) xticks, xticklabels = get_freq_ticks(ins.freq_array, freqlist) print(ins.freq_array[1] - ins.freq_array[0]) cp.INS_plot(ins, '%s_SSINS.pdf' % prefix, xticks=xticks, xticklabels=xticklabels)
indir = args.infile[:args.infile.rfind('/')] if indir == args.outdir: raise ValueError("indir and outdir are the same") ss = SS() ss.read(args.infile, flag_choice='original') ins = INS(ss) ins.metric_array[-5:] = np.ma.masked ins.metric_ms = ins.mean_subtract() shape_dict = { 'TV4': [1.74e8, 1.81e8], 'TV5': [1.81e8, 1.88e8], 'TV6': [1.88e8, 1.95e8], 'broad6': [1.72e8, 1.83e8], 'broad7': [1.79e8, 1.9e8], 'broad8': [1.86e8, 1.98e8] } mf = MF(ins.freq_array, 5, shape_dict=shape_dict, N_samp_thresh=25) mf.apply_match_test(ins, apply_samp_thresh=True) cp.INS_plot(ins, '%s/%s' % (args.outdir, args.obsid)) ss.apply_flags(flag_choice='INS', INS=ins) ss.write('%s/%s.uvfits' % (args.outdir, args.obsid), 'uvfits', nsample_default=16)
from SSINS import Catalog_Plot as cp from SSINS import MF import numpy as np import os obslist_path = '/Users/mike_e_dubs/HERA/Interesting_Obs_Master.txt' obslist = util.make_obslist(obslist_path) basedirs = ['/Users/mike_e_dubs/HERA/INS/IDR2_Prelim_Nocut/HERA_IDR2_Prelim_Set_nocut', '/Users/mike_e_dubs/HERA/INS/IDR2_OR/HERA_IDR2_Prelim_Set_OR_original'] shape_dict = {'dig1': [1.125e8, 1.15625e8], 'dig2': [1.375e8, 1.40625e8], 'dig3': [1.625e8, 1.65625e8], 'dig4': [1.875e8, 1.90625e8], 'TV4': [1.74e8, 1.82e8], 'TV5': [1.82e8, 1.9e8], 'TV6': [1.9e8, 1.98e8], 'TV7': [1.98e8, 2.06e8]} for i, flag_choice in enumerate(['None', 'original']): for obsid in obslist: for pol in ['xx', 'yy', 'xy', 'yx']: obs = 'zen.%s.%s.HH' % (obsid, pol) read_paths = util.read_paths_INS(basedirs[i], flag_choice, obs) ins = INS(read_paths=read_paths, obs=obs, flag_choice=flag_choice, outpath='/Users/mike_e_dubs/HERA/INS/Adam_Presentation/%s' % flag_choice) cp.INS_plot(ins, vmax=0.05, ms_vmax=5, ms_vmin=-5) if flag_choice is 'None':
from SSINS import SS from SSINS import Catalog_Plot as cp inpath = '/Users/mike_e_dubs/MWA/Data/1061313128_noflag.uvfits' outpath = '/Users/mike_e_dubs/MWA/1061313128_noflag' obs = '1061313128' ss = SS(inpath=inpath, outpath=outpath, obs=obs, bad_time_indices=[0, -1, -2, -3, -4], read_kwargs={ 'ant_str': 'cross', 'file_type': 'uvfits' }) ss.MF_prepare(sig_thresh=5, shape_dict={ 'TV6': [1.74e8, 1.81e8], 'TV7': [1.81e8, 1.88e8], 'TV8': [1.88e8, 1.95e8], 'TV7_Broad': [1.79e8, 1.9e8] }) cp.INS_plot(ss.INS, ms_vmin=-5, ms_vmax=5) ss.MF.apply_match_test() cp.MF_plot(ss.MF, ms_vmin=-5, ms_vmax=5)
ss = SS() if args.correct: ss.read(args.uvd, phase_to_pointing_center=True, correct_cable_len=True, flag_choice='original', diff=True, remove_dig_gains=True, remove_coarse_band=True, data_array_dtype=np.complex64) else: ss.read(args.uvd, phase_to_pointing_center=True, correct_cable_len=True, flag_choice='original', diff=True, remove_dig_gains=False, remove_coarse_band=False, data_array_dtype=np.complex64) ins = INS(ss) prefix = f'{args.outdir}/{args.obsid}' Catalog_Plot.INS_plot(ins, prefix, data_cmap=cm.plasma, ms_vmin=-5, ms_vmax=5, title=args.obsid, xlabel='Frequency (Mhz)', ylabel='Time (UTC)') # Try to save memory - hope for garbage collector del ss # Set up MF flagging for routine shapes shape_dict = {'TV6': [1.74e8, 1.81e8], 'TV7': [1.81e8, 1.88e8], 'TV8': [1.88e8, 1.95e8], 'TV9': [1.95e8, 2.02e8]} sig_thresh = {shape: 5 for shape in shape_dict} sig_thresh['narrow'] = 5 sig_thresh['streak'] = 10 mf = MF(ins.freq_array, sig_thresh, shape_dict=shape_dict, tb_aggro=0.5, broadcast_streak=True) # Do the flagging
def execbody(ins_filepath): slash_ind = ins_filepath.rfind('/') obsid = ins_filepath[slash_ind + 1:slash_ind + 11] ins = INS(ins_filepath) ins.select(times=ins.time_array[3:-3]) ins.metric_ms = ins.mean_subtract() shape_dict = { 'TV6': [1.74e8, 1.81e8], 'TV7': [1.81e8, 1.88e8], 'TV8': [1.88e8, 1.95e8], 'TV9': [1.95e8, 2.02e8] } sig_thresh = {shape: 5 for shape in shape_dict} sig_thresh['narrow'] = 5 sig_thresh['streak'] = 8 mf = MF(ins.freq_array, sig_thresh, shape_dict=shape_dict, N_samp_thresh=len(ins.time_array) // 2) ins.metric_array[ins.metric_array == 0] = np.ma.masked ins.metric_ms = ins.mean_subtract() ins.sig_array = np.ma.copy(ins.metric_ms) #write plots if command flagged to do so if args.plots: prefix = '%s/%s_trimmed_zeromask' % (args.outdir, obsid) freqs = np.arange(1.7e8, 2e8, 5e6) xticks, xticklabels = util.make_ticks_labels(freqs, ins.freq_array, sig_fig=0) yticks = [0, 20, 40] yticklabels = [] for tick in yticks: yticklabels.append( Time(ins.time_array[tick], format='jd').iso[:-4]) Catalog_Plot.INS_plot(ins, prefix, xticks=xticks, yticks=yticks, xticklabels=xticklabels, yticklabels=yticklabels, data_cmap=cm.plasma, ms_vmin=-5, ms_vmax=5, title=obsid, xlabel='Frequency (Mhz)', ylabel='Time (UTC)') if args.verbose: print("wrote trimmed zeromask plot for " + obsid) mf.apply_match_test(ins, apply_samp_thresh=False) mf.apply_samp_thresh_test(ins, event_record=True) flagged_prefix = '%s/%s_trimmed_zeromask_MF_s8' % (args.outdir, obsid) #write data/mask/match/ if command flagged to do so if args.write: ins.write(flagged_prefix, output_type='data', clobber=True) ins.write(flagged_prefix, output_type='mask', clobber=True) ins.write(flagged_prefix, output_type='match_events') if args.verbose: print("wrote data/mask/match files for " + obsid) #write plots if command flagged to do so if args.plots: Catalog_Plot.INS_plot(ins, flagged_prefix, xticks=xticks, yticks=yticks, xticklabels=xticklabels, yticklabels=yticklabels, data_cmap=cm.plasma, ms_vmin=-5, ms_vmax=5, title=obsid, xlabel='Frequency (Mhz)', ylabel='Time (UTC)') if args.verbose: print("wrote trimmed zeromask (w/ match filter) for " + obsid) #a hardcoded csv generator for occ_csv if args.gencsv is not None: csv = "" + obsid + "," + flagged_prefix + "_SSINS_data.h5," + flagged_prefix + "_SSINS_mask.h5," + flagged_prefix + "_SSINS_match_events.yml\n" with open(args.gencsv, "a") as csvfile: csvfile.write(csv) print("wrote entry for " + obsid)
ss.read(args.uvd, phase_to_pointing_center=True, correct_cable_len=True, flag_choice='original', diff=True) ins = INS(ss) prefix = '%s/%s' % (args.outdir, args.obsid) ins.write(prefix) freqs = np.arange(1.7e8, 2e8, 5e6) xticks, xticklabels = util.make_ticks_labels(freqs, ins.freq_array, sig_fig=0) yticks = [0, 20, 40] yticklabels = [] for tick in yticks: yticklabels.append(Time(ins.time_array[tick], format='jd').iso[:-4]) Catalog_Plot.INS_plot(ins, prefix, xticks=xticks, yticks=yticks, xticklabels=xticklabels, yticklabels=yticklabels, data_cmap=cm.plasma, ms_vmin=-5, ms_vmax=5, title=args.obsid, xlabel='Frequency (Mhz)', ylabel='Time (UTC)') # Try to save memory - hope for garbage collector del ss # Set up MF flagging for routine shapes shape_dict = {'TV6': [1.74e8, 1.81e8], 'TV7': [1.81e8, 1.88e8], 'TV8': [1.88e8, 1.95e8], 'TV9': [1.95e8, 2.02e8]} sig_thresh = {shape: 5 for shape in shape_dict} sig_thresh['narrow'] = 5 sig_thresh['streak'] = 8 mf = MF(ins.freq_array, sig_thresh, shape_dict=shape_dict, N_samp_thresh=len(ins.time_array) // 2) mf.apply_match_test(ins, apply_samp_thresh=False) mf.apply_samp_thresh_test(ins, event_record=True) Catalog_Plot.INS_plot(ins, '%s_flagged' % prefix,
from __future__ import absolute_import, division, print_function import argparse from SSINS import Catalog_Plot as cp from SSINS import SS, INS import numpy as np parser = argparse.ArgumentParser() parser.add_argument('obs', action='store', help='The observation ID') parser.add_argument('inpath', action='store', help='The path to the data file') parser.add_argument('outpath', action='store', help='The base directory for saving all outputs') args = parser.parse_args() ss = SS() ss.read(args.inpath, ant_str='cross') ins = INS(ss) prefix = '%s/%s' % (args.outpath, args.obs) ins.write(prefix) cp.INS_plot(ins, prefix)