def waterfall_plot(data, xlims, sbs, obs_mode, sbs_interval=10, interval=10000): num_plots = int(data.shape[1]/sbs_interval) #print(num_plots) f, axs = plt.subplots(num_plots, 1, figsize=(10,10), sharex=True) x = np.linspace(xlims[0], xlims[1], data.shape[0]) c = np.arange(1, int(data.shape[1]/sbs_interval)+1) #+1 so the last few plots are not completely white norm = mpl.colors.Normalize(vmin=c.min(), vmax=c.max()) cmap = mpl.cm.ScalarMappable(norm=norm, cmap=mpl.cm.cool) cmap.set_array([]) leg = LofarRaw.sb_to_f(sbs[0]+np.linspace(0, data.shape[1], data.shape[1]+1)[::sbs_interval], obs_mode) leg = [round(x.value, 2) for x in leg]*u.MHz data = data[:,::sbs_interval] for i,ax in enumerate(axs): ax.plot(x, data[:,num_plots-i], c='k') ax.fill_between(x, data[:,num_plots-i], facecolor=cmap.to_rgba(i+1)) ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) ax.spines['left'].set_visible(False) ax.spines['bottom'].set_visible(False) ax.axhline(y=data.min(), lw=2, clip_on=False, color=cmap.to_rgba(i+1)) ax.set_yticks([]) ax.set_ylim([data.min(),data.max()]) ax.patch.set_alpha(0) label(ax, cmap.to_rgba(i+1), leg[num_plots-i]) date_format = mdates.DateFormatter('%H:%M:%S.%f') axs[-1].spines['bottom'].set_visible(True) ax.xaxis.set_major_formatter(date_format) ax.xaxis.set_minor_locator(mdates.MicrosecondLocator(interval=interval)) ax.set_xlabel('Time', fontsize=14) ax.tick_params(labelsize=14) f.subplots_adjust(hspace=-.5) f.autofmt_xdate()
def get_data_lims(sbs, obs_mode, sbs_number, trange): """ Return the limits of the data in usable form sbs_number = number of subbands used trange = the length of time. """ flimits = np.array([0,sbs_number]) freqlimits = LofarRaw.sb_to_f(flimits+sbs[0], obs_mode) xlims = list(map(dt.datetime.fromisoformat, [trange.start.value, trange.end.value])) xlims = mdates.date2num(xlims) return freqlimits, xlims
def plot_event_1d(data, xlims, sbs, obs_mode, sbs_interval=10, interval=10000): """ This just shows a couple 1d plots of an event up close acrdeductionoss sbs_interval frequencies (total_sbs/10) """ f, ax = plt.subplots(figsize=(10,6)) f.set_facecolor('white') plt.plot(np.linspace(xlims[0], xlims[1], data.shape[0]), data[:,::sbs_interval]) plt.xlim(xlims[0], xlims[1]) plt.gca().xaxis_date() date_format = mdates.DateFormatter('%H:%M:%S.%f') ax.xaxis.set_major_formatter(date_format) ax.xaxis.set_minor_locator(mdates.MicrosecondLocator(interval=interval)) f.autofmt_xdate() plt.xlabel('Time') plt.ylabel('Arbitrary voltages') leg = LofarRaw.sb_to_f(sbs[0]+np.linspace(0, data.shape[1], data.shape[1]+1)[::sbs_interval], obs_mode) leg = [round(x.value, 2) for x in leg]*u.MHz plt.legend(leg) plt.grid(ls=':') plt.tight_layout()
beam1_sbs = np.arange(76, 198) obs_mode = 3 trange = TimeRange("2020-10-13T17:45:00", 15. * u.min) """ fname = 'udpoutput/jupiter-stokesI_0_2020-10-13T17:47:00_19563125244140' sbs = np.arange(76, 319) obs_mode = 3 trange = TimeRange("2020-10-13T17:47:00", 10.*u.minute) """ #just plotting parameters xlabel = "Time from 2020/10/13 17:45:00.0000" ylabel = "Frequency (MHz)" title = sys.argv[1].split('/')[1] # read data raw = LofarRaw(fname=filename, sbs=sbs, obs_mode=obs_mode, frange=frange) # time resolution was scrubbed x16 in udpPM flimits = np.array([40, 94]) freqlimits = raw.sb_to_f(flimits + sbs[0], obs_mode) xlims = list( map(dt.datetime.fromisoformat, [trange.start.value, trange.end.value])) xlims = mdates.date2num(xlims) print(freqlimits[0].value) raw.data = raw.data[:, flimits[0]:flimits[1]] ### let's try remove that rfi with sk again ### do it first thing, no normalisation until afterwards
off_fname = '../udpoutput/offsource-stokesVectors_0_2020-12-15T20:04:00_19629670898060' cal_fname = '../udpoutput/cygA-stokesVectors_0_2020-12-15T20:00:00_19629667968374' #calibrator has different obs length! plot_names = 'test_script/Uranus_StokesI_' plot_title = "Uranus observation - Stokes I" frange = [15,30] sbs = np.arange(76,198) obs_mode = 3 time_len_mins = 176. trange = TimeRange(filename.split('_')[-2], time_len_mins*u.min) xlabel = "Time from {} {}".format(filename.split('_')[-2].split('T')[0], filename.split('_')[-2].split('T')[1]) xlabel = "Time on {} (UTC)".format(filename.split('_')[-2].split('T')[0]) ylabel = "Frequency (MHz)" title = filename.split('/')[2] no_sbs = 78 #number of usable subbands! #how much to split up data into nsplit = 10 r_factor = 12207 #on-beam rawdata = LofarRaw(fname=filename, sbs=sbs, obs_mode=obs_mode, frange=frange) rawdata.data = rawdata.data[:,:no_sbs] #need to do this because of the way subbands were set up for uranus observations! (only use 78 subbands!) ylims, xlims = get_data_lims(no_sbs, trange) df_chunk = data_chunker(rawdata.data, nsplit) for i,j in enumerate(df_chunk): data = fft_change_res()
beam1_sbs = np.arange(76, 198) obs_mode = 3 trange = TimeRange("2020-10-13T17:45:00", 15. * u.min) """ fname = 'udpoutput/jupiter-stokesI_0_2020-10-13T17:47:00_19563125244140' sbs = np.arange(76, 319) obs_mode = 3 trange = TimeRange("2020-10-13T17:47:00", 10.*u.minute) """ #just plotting parameters xlabel = "Time from 2020/10/13 17:45:00.0000" ylabel = "Frequency (MHz)" title = sys.argv[1].split('/')[1] # read data raw = LofarRaw(fname=filename, sbs=sbs, obs_mode=obs_mode, frange=frange) # time resolution was scrubbed x16 in udpPM flimits = np.array([40, 94]) freqlimits = raw.sb_to_f(flimits + sbs[0], obs_mode) xlims = list( map(dt.datetime.fromisoformat, [trange.start.value, trange.end.value])) xlims = mdates.date2num(xlims) print(freqlimits[0].value) raw.data = raw.data[:, flimits[0]:flimits[1]] #defining some of the rfi dominated bands and masking those rfi_bands = [0, 1, 25, -1, -2, -3] #dominant rfi bands 0->20 + 31, 32, 38 rfi_freqs = raw.sb_to_f(np.array(rfi_bands) + flimits[0] + sbs[0], obs_mode)