Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sp_pgplot.ppgplot.pgslw(5)
sweepstart = sweeped_start - 0.2 * sweep_duration
sp_pgplot.ppgplot.pgsci(0)
sp_pgplot.ppgplot.pgline(delays + sweepstart, freqs)
sp_pgplot.ppgplot.pgsci(1)
#### Figure texts
if integrate_spec:
sp_pgplot.ppgplot.pgsvp(0.81, 0.97, 0.64, 0.909)
sp_pgplot.ppgplot.pgsch(0.62)
else:
sp_pgplot.ppgplot.pgsvp(0.745, 0.97, 0.64, 0.909)
sp_pgplot.ppgplot.pgsch(0.7)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.01, 0.0, "RA: %s" % RA)
sp_pgplot.ppgplot.pgmtxt('T', -2.6, 0.01, 0.0, "DEC: %s" % dec)
sp_pgplot.ppgplot.pgmtxt('T', -4.1, 0.01, 0.0, "MJD: %f" % MJD)
sp_pgplot.ppgplot.pgmtxt('T', -5.6, 0.01, 0.0, "Obs date: %s %s %s" % (date[0], date[1], date[2]))
sp_pgplot.ppgplot.pgmtxt('T', -7.1, 0.01, 0.0, "Telescope: %s" % telescope)
sp_pgplot.ppgplot.pgmtxt('T', -8.6, 0.01, 0.0, "DM: %.2f pc cm\\u-3\\d" % dm)
if sigma:
sp_pgplot.ppgplot.pgmtxt('T', -10.1, 0.01, 0.0, "S/N\\dMAX\\u: %.2f" % sigma)
else:
sp_pgplot.ppgplot.pgmtxt('T', -10.1, 0.01, 0.0, "S/N\\dMAX\\u: N/A")
sp_pgplot.ppgplot.pgmtxt('T', -11.6, 0.01, 0.0, "Number of samples: %i" % nbins)
sp_pgplot.ppgplot.pgmtxt('T', -13.1, 0.01, 0.0, "Number of subbands: %i" % nsub)
sp_pgplot.ppgplot.pgmtxt('T', -14.6, 0.01, 0.0, "Pulse width: %.2f ms" % (pulse_width * 1e3))
sp_pgplot.ppgplot.pgmtxt('T', -16.1, 0.01, 0.0, "Sampling time: %.3f \\gms" % (tsamp * 1e6))
sp_pgplot.ppgplot.pgmtxt('T', -17.6, 0.0, 0.0, "Bary pulse peak time: %.2f s" % (bary_start))
sp_pgplot.ppgplot.pgsvp(0.07, 0.7, 0.01, 0.05)
sp_pgplot.ppgplot.pgmtxt('T', -2.1, 0.01, 0.0, "%s" % fn)
sp_pgplot.ppgplot.pgsch(0.65)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.01, 0.0, "RA: %s" %RA)
sp_pgplot.ppgplot.pgmtxt('T', -2.5, 0.01, 0.0, "DEC: %s" %dec)
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.01, 0.0, "MJD: %f" %MJD)
sp_pgplot.ppgplot.pgmtxt('T', -5.3, 0.01, 0.0, "Obs date: %s %s %s" %(date[0], date[1], date[2]))
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.35, 0.0, "Telescope: %s" %telescope)
sp_pgplot.ppgplot.pgmtxt('T', -2.5, 0.35, 0.0, "DM: %.2f pc cm\u-3\d" %dm)
if sigma:
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.35, 0.0, "S/N\dMAX\u: %.2f" %sigma)
else:
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.35, 0.0, "S/N\dMAX\u: N/A")
sp_pgplot.ppgplot.pgmtxt('T', -5.3, 0.35, 0.0, "Number of samples: %i" %nbins)
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.65, 0.0, "Number of subbands: %i" %nsub)
sp_pgplot.ppgplot.pgmtxt('T', -2.5, 0.65, 0.0, "Pulse width: %.2f ms" %(pulse_width*1e3))
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.65, 0.0, "Sampling time: %.3f \gms" %(tsamp*1e6))
sp_pgplot.ppgplot.pgmtxt('T', -5.3, 0.65, 0.0, "Bary pulse peak time: %.2f s" %(bary_start))
sp_pgplot.ppgplot.pgiden()
sp_pgplot.ppgplot.pgclos()
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.01, 0.0, "RA: %s" %RA)
sp_pgplot.ppgplot.pgmtxt('T', -2.5, 0.01, 0.0, "DEC: %s" %dec)
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.01, 0.0, "MJD: %f" %MJD)
sp_pgplot.ppgplot.pgmtxt('T', -5.3, 0.01, 0.0, "Obs date: %s %s %s" %(date[0], date[1], date[2]))
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.35, 0.0, "Telescope: %s" %telescope)
sp_pgplot.ppgplot.pgmtxt('T', -2.5, 0.35, 0.0, "DM: %.2f pc cm\u-3\d" %dm)
if sigma:
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.35, 0.0, "S/N\dMAX\u: %.2f" %sigma)
else:
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.35, 0.0, "S/N\dMAX\u: N/A")
sp_pgplot.ppgplot.pgmtxt('T', -5.3, 0.35, 0.0, "Number of samples: %i" %nbins)
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.65, 0.0, "Number of subbands: %i" %nsub)
sp_pgplot.ppgplot.pgmtxt('T', -2.5, 0.65, 0.0, "Pulse width: %.2f ms" %(pulse_width*1e3))
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.65, 0.0, "Sampling time: %.3f \gms" %(tsamp*1e6))
sp_pgplot.ppgplot.pgmtxt('T', -5.3, 0.65, 0.0, "Bary pulse peak time: %.2f s" %(bary_start))
sp_pgplot.ppgplot.pgiden()
sp_pgplot.ppgplot.pgclos()
sp_pgplot.ppgplot.pgbox("BCST", 0, 0, "BCST", 0, 0)
sp_pgplot.ppgplot.pgsch(3)
sp_pgplot.plot_waterfall(array,rangex = [sweeped_start, sweeped_start+sweep_duration],rangey = [min_freq, max_freq],image = 'apjgrey')
sp_pgplot.ppgplot.pgslw(5)
sweepstart = sweeped_start- 0.2*sweep_duration
sp_pgplot.ppgplot.pgsci(0)
sp_pgplot.ppgplot.pgline(delays+sweepstart, freqs)
sp_pgplot.ppgplot.pgsci(1)
#### Figure texts
sp_pgplot.ppgplot.pgsvp(0.05, 0.95, 0.8, 0.9)
sp_pgplot.ppgplot.pgsch(0.65)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.01, 0.0, "RA: %s" %RA)
sp_pgplot.ppgplot.pgmtxt('T', -2.5, 0.01, 0.0, "DEC: %s" %dec)
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.01, 0.0, "MJD: %f" %MJD)
sp_pgplot.ppgplot.pgmtxt('T', -5.3, 0.01, 0.0, "Obs date: %s %s %s" %(date[0], date[1], date[2]))
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.35, 0.0, "Telescope: %s" %telescope)
sp_pgplot.ppgplot.pgmtxt('T', -2.5, 0.35, 0.0, "DM: %.2f pc cm\u-3\d" %dm)
if sigma:
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.35, 0.0, "S/N\dMAX\u: %.2f" %sigma)
else:
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.35, 0.0, "S/N\dMAX\u: N/A")
sp_pgplot.ppgplot.pgmtxt('T', -5.3, 0.35, 0.0, "Number of samples: %i" %nbins)
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.65, 0.0, "Number of subbands: %i" %nsub)
sp_pgplot.ppgplot.pgmtxt('T', -2.5, 0.65, 0.0, "Pulse width: %.2f ms" %(pulse_width*1e3))
sp_pgplot.ppgplot.pgmtxt('T', -3.9, 0.65, 0.0, "Sampling time: %.3f \gms" %(tsamp*1e6))
sp_pgplot.ppgplot.pgmtxt('T', -5.3, 0.65, 0.0, "Bary pulse peak time: %.2f s" %(bary_start))
sp_pgplot.ppgplot.pgiden()
sp_pgplot.ppgplot.pgclos()
sp_pgplot.ppgplot.pgsvp(0.55, 0.97, 0.1, 0.54)
else:
sp_pgplot.ppgplot.pgsvp(0.48, 0.97, 0.1, 0.54)
dms, times, sigmas, widths, filelist = spio.gen_arrays(dm_arr, spfiles, tar, threshold)
sp_pgplot.dm_time_plot(dms, times, sigmas, dm_list, sigma_arr, time_list, Total_observed_time, xwin)
else:
print("You need a .singlepulse.tgz file to plot DM vs Time plot.")
if integrate_spec:
sp_pgplot.ppgplot.pgsvp(0.55, 0.97, 0.1, 0.54)
else:
sp_pgplot.ppgplot.pgsvp(0.48, 0.97, 0.1, 0.54)
sp_pgplot.ppgplot.pgsch(0.8)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgbox("BCNST", 0, 0, "BCNST", 0, 0)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "Time (s)")
sp_pgplot.ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "DM (pc cm\\u-3\\d)")
else:
# sp_pgplot.ppgplot.pgpap(10.25, 10.0/5.0)
sp_pgplot.ppgplot.pgpap(8.0, 1.5)
# Dedispersed waterfall plot - zerodm - OFF
array = spdobj.data_nozerodm_dedisp.astype(np.float64)
sp_pgplot.ppgplot.pgsvp(0.1, 0.70, 0.44, 0.75)
sp_pgplot.ppgplot.pgswin(datastart - start, datastart - start + datanumspectra * datasamp, min_freq, max_freq)
sp_pgplot.ppgplot.pgsch(0.8)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgbox("BCST", 0, 0, "BCNST", 0, 0)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "Observing Frequency (MHz)")
sp_pgplot.plot_waterfall(array, rangex=[datastart - start, datastart - start + datanumspectra * datasamp],
rangey=[min_freq, max_freq], image='apjgrey')
sp_pgplot.ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "DM (pc cm\u-3\d)")
sp_pgplot.ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "Signal-to-noise")
sp_pgplot.ppgplot.pgpt(dm_arr, sigma_arr, 20)
else:
dm_arr = np.array([])
sigma_arr = np.array([])
time_arr = np.array([])
if integrate_spec:
sp_pgplot.ppgplot.pgsvp(0.55, 0.80, 0.65, 0.90)
else:
sp_pgplot.ppgplot.pgsvp(0.48, 0.73, 0.65, 0.90)
sp_pgplot.ppgplot.pgsch(0.8)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgbox("BCNST", 0, 0, "BCNST", 0, 0)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "DM (pc cm\u-3\d)")
sp_pgplot.ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "Signal-to-noise")
# DM vs Time
print("Making arrays for DM vs time plot")
spfiles = singlepulsefiles
threshold = 5.0
if len(spfiles) > 2:
dm_list = list(map(np.float32, list(dm_arr)))
time_list = list(map(np.float32, list(time_arr)))
if integrate_spec:
sp_pgplot.ppgplot.pgsvp(0.55, 0.97, 0.1, 0.54)
else:
sp_pgplot.ppgplot.pgsvp(0.48, 0.97, 0.1, 0.54)
dms, times, sigmas, widths, filelist = spio.gen_arrays(dm_arr, spfiles, tar, threshold)
sp_pgplot.dm_time_plot(dms, times, sigmas, dm_list, sigma_arr, time_list, Total_observed_time, xwin)
else:
sp_pgplot.ppgplot.pgbox("BC", 0, 0, "BC", 0, 0)
sp_pgplot.ppgplot.pgsci(1)
sp_pgplot.ppgplot.pgline(Dedisp_spec, freqs)
sp_pgplot.ppgplot.pgmtxt('R', 1.8, 0.5, 0.5, "Zero-dm filtering - Off")
sp_pgplot.ppgplot.pgsch(0.7)
sp_pgplot.ppgplot.pgmtxt('T', 1.8, 0.5, 0.5, "Spectrum")
sp_pgplot.ppgplot.pgsch(0.8)
# Dedispersed waterfall plot - Zerodm ON
array = spdobj.data_zerodm_dedisp.astype(np.float64)
sp_pgplot.ppgplot.pgsvp(0.1, 0.70, 0.05, 0.36)
sp_pgplot.ppgplot.pgswin(datastart - start, datastart - start + datanumspectra * datasamp, min_freq, max_freq)
sp_pgplot.ppgplot.pgsch(0.8)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgbox("BCNST", 0, 0, "BCNST", 0, 0)
sp_pgplot.ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "Time - %.2f s" % datastart)
sp_pgplot.ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "Observing Frequency (MHz)")
sp_pgplot.plot_waterfall(array, rangex=[datastart - start, datastart - start + datanumspectra * datasamp],
rangey=[min_freq, max_freq], image='apjgrey')
#### Plot Dedispersed Time series - Zerodm filter - On
dedisp_ts = array[::-1].sum(axis=0)
times = np.arange(datanumspectra) * datasamp
if integrate_ts:
sp_pgplot.ppgplot.pgsvp(0.1, 0.7, 0.36, 0.44)
sp_pgplot.ppgplot.pgswin(datastart - start, datastart - start + duration, np.min(dedisp_ts),
1.05 * np.max(dedisp_ts))
sp_pgplot.ppgplot.pgsch(0.8)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgbox("BC", 0, 0, "BC", 0, 0)
sp_pgplot.ppgplot.pgsci(1)
sp_pgplot.ppgplot.pgline(times, dedisp_ts)
sp_pgplot.ppgplot.pgsci(1)
sp_pgplot.ppgplot.pgline(Dedisp_spec, freqs)
sp_pgplot.ppgplot.pgmtxt('R', 1.8, 0.5, 0.5, "Zero-dm filtering - Off")
sp_pgplot.ppgplot.pgsch(0.7)
sp_pgplot.ppgplot.pgmtxt('T', 1.8, 0.5, 0.5, "Spectrum")
sp_pgplot.ppgplot.pgsch(0.8)
# Dedispersed waterfall plot - Zerodm ON
array = spdobj.data_zerodm_dedisp.astype(np.float64)
sp_pgplot.ppgplot.pgsvp(0.1, 0.70, 0.05, 0.36)
sp_pgplot.ppgplot.pgswin(datastart - start, datastart - start + datanumspectra * datasamp, min_freq, max_freq)
sp_pgplot.ppgplot.pgsch(0.8)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgbox("BCNST", 0, 0, "BCNST", 0, 0)
sp_pgplot.ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "Time - %.2f s" % datastart)
sp_pgplot.ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "Observing Frequency (MHz)")
sp_pgplot.plot_waterfall(array, rangex=[datastart - start, datastart - start + datanumspectra * datasamp],
rangey=[min_freq, max_freq], image='apjgrey')
#### Plot Dedispersed Time series - Zerodm filter - On
dedisp_ts = array[::-1].sum(axis=0)
times = np.arange(datanumspectra) * datasamp
if integrate_ts:
sp_pgplot.ppgplot.pgsvp(0.1, 0.7, 0.36, 0.44)
sp_pgplot.ppgplot.pgswin(datastart - start, datastart - start + duration, np.min(dedisp_ts),
1.05 * np.max(dedisp_ts))
sp_pgplot.ppgplot.pgsch(0.8)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgbox("BC", 0, 0, "BC", 0, 0)
sp_pgplot.ppgplot.pgsci(1)
sp_pgplot.ppgplot.pgline(times, dedisp_ts)
errx1 = np.array([0.60 * (datastart - start + duration)])
if integrate_spec:
spectrum_window = spec_width * pulse_width
window_width = int(spectrum_window / datasamp)
# burst_bin = int(datanumspectra*loc_pulse/downsamp)
burst_bin = int(nbins * loc_pulse / downsamp)
on_spec = array[..., burst_bin - window_width:burst_bin + window_width]
Dedisp_spec = on_spec.sum(axis=1)
freqs = np.linspace(min_freq, max_freq, len(Dedisp_spec))
sp_pgplot.ppgplot.pgsvp(0.7, 0.9, 0.44, 0.75)
sp_pgplot.ppgplot.pgswin(np.min(Dedisp_spec), 1.05 * np.max(Dedisp_spec), min_freq, max_freq)
sp_pgplot.ppgplot.pgsch(0.8)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgbox("BC", 0, 0, "BC", 0, 0)
sp_pgplot.ppgplot.pgsci(1)
sp_pgplot.ppgplot.pgline(Dedisp_spec, freqs)
sp_pgplot.ppgplot.pgmtxt('R', 1.8, 0.5, 0.5, "Zero-dm filtering - Off")
sp_pgplot.ppgplot.pgsch(0.7)
sp_pgplot.ppgplot.pgmtxt('T', 1.8, 0.5, 0.5, "Spectrum")
sp_pgplot.ppgplot.pgsch(0.8)
# Dedispersed waterfall plot - Zerodm ON
array = spdobj.data_zerodm_dedisp.astype(np.float64)
sp_pgplot.ppgplot.pgsvp(0.1, 0.70, 0.05, 0.36)
sp_pgplot.ppgplot.pgswin(datastart - start, datastart - start + datanumspectra * datasamp, min_freq, max_freq)
sp_pgplot.ppgplot.pgsch(0.8)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgbox("BCNST", 0, 0, "BCNST", 0, 0)
sp_pgplot.ppgplot.pgmtxt('B', 2.5, 0.5, 0.5, "Time - %.2f s" % datastart)
sp_pgplot.ppgplot.pgmtxt('L', 1.8, 0.5, 0.5, "Observing Frequency (MHz)")
sp_pgplot.plot_waterfall(array, rangex=[datastart - start, datastart - start + datanumspectra * datasamp],
rangey=[min_freq, max_freq], image='apjgrey')
sp_pgplot.ppgplot.pgsvp(0.81, 0.97, 0.64, 0.909)
sp_pgplot.ppgplot.pgsch(0.62)
else:
sp_pgplot.ppgplot.pgsvp(0.745, 0.97, 0.64, 0.909)
sp_pgplot.ppgplot.pgsch(0.7)
sp_pgplot.ppgplot.pgslw(3)
sp_pgplot.ppgplot.pgmtxt('T', -1.1, 0.01, 0.0, "RA: %s" % RA)
sp_pgplot.ppgplot.pgmtxt('T', -2.6, 0.01, 0.0, "DEC: %s" % dec)
sp_pgplot.ppgplot.pgmtxt('T', -4.1, 0.01, 0.0, "MJD: %f" % MJD)
sp_pgplot.ppgplot.pgmtxt('T', -5.6, 0.01, 0.0, "Obs date: %s %s %s" % (date[0], date[1], date[2]))
sp_pgplot.ppgplot.pgmtxt('T', -7.1, 0.01, 0.0, "Telescope: %s" % telescope)
sp_pgplot.ppgplot.pgmtxt('T', -8.6, 0.01, 0.0, "DM: %.2f pc cm\\u-3\\d" % dm)
if sigma:
sp_pgplot.ppgplot.pgmtxt('T', -10.1, 0.01, 0.0, "S/N\\dMAX\\u: %.2f" % sigma)
else:
sp_pgplot.ppgplot.pgmtxt('T', -10.1, 0.01, 0.0, "S/N\\dMAX\\u: N/A")
sp_pgplot.ppgplot.pgmtxt('T', -11.6, 0.01, 0.0, "Number of samples: %i" % nbins)
sp_pgplot.ppgplot.pgmtxt('T', -13.1, 0.01, 0.0, "Number of subbands: %i" % nsub)
sp_pgplot.ppgplot.pgmtxt('T', -14.6, 0.01, 0.0, "Pulse width: %.2f ms" % (pulse_width * 1e3))
sp_pgplot.ppgplot.pgmtxt('T', -16.1, 0.01, 0.0, "Sampling time: %.3f \\gms" % (tsamp * 1e6))
sp_pgplot.ppgplot.pgmtxt('T', -17.6, 0.0, 0.0, "Bary pulse peak time: %.2f s" % (bary_start))
sp_pgplot.ppgplot.pgsvp(0.07, 0.7, 0.01, 0.05)
sp_pgplot.ppgplot.pgmtxt('T', -2.1, 0.01, 0.0, "%s" % fn)
# DM vs SNR
if not man_params:
dm_arr = np.float32(spdobj.dmVt_this_dms)
sigma_arr = np.float32(spdobj.dmVt_this_sigmas)
time_arr = np.float32(spdobj.dmVt_this_times)
if integrate_spec:
sp_pgplot.ppgplot.pgsvp(0.55, 0.80, 0.65, 0.90)
else: