Skip to content

Commit

Permalink
Update rfi_plotter.py
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCoto authored Feb 22, 2020
1 parent fea3c26 commit d12c6cf
Showing 1 changed file with 9 additions and 41 deletions.
50 changes: 9 additions & 41 deletions rfi_plotter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
if True:
try:
import matplotlib
matplotlib.use('Agg')

Expand Down Expand Up @@ -35,27 +35,19 @@ def decibel(x):
exec(args.fminimum)
exec(args.fmaximum)

#freq=300000000
frequency=freq
#samp_rate=2400000
#nchan=1024
#nbin=23436

#Load data
z=1000*(np.fromfile("0.dat", dtype="float32").reshape(-1, nchan)/nbin)
allarrays=[]
#N=1 #amount_of_.dat_files

#N = amount of .dat files
for i in range(int(n)):
final = 1000*(np.fromfile(str(i)+".dat", dtype="float32").reshape(-1, nchan)/nbin)
#print(final.shape)
allarrays.append(final)
z_final = np.concatenate(allarrays,axis=1)
#print(type(z_final))
#print(z_final.shape)
#z_final[z_final > 4000] = 4000

#Define numpy array for Power vs Time plot
#w = np.mean(a=z, axis=1)

#Number of sub-integrations
nsub = z_final.shape[0]
Expand All @@ -67,21 +59,17 @@ def decibel(x):
tint = float(nbin*nchan)/samp_rate
t = tint*np.arange(nsub)

#v = np.arange(0, np.max(t)+tint, tint)

#Compute frequency axis (convert to MHz)
allfreq=[]
for i in range(int(n)):
freq = np.linspace((frequency+samp_rate*i)-0.5*samp_rate, (frequency+samp_rate*i)+0.5*samp_rate, nchan, endpoint=False)*1e-6
allfreq.append(freq)
freq = np.concatenate(allfreq)
#print(999,freq)
#freq = freq*i
#print(freq.shape)

#Initialize plot
fig = plt.figure(figsize=(5*n,20.25))
gs = GridSpec(1,1) #2,1

gs = GridSpec(1,1)
#Plot average spectrum
ax1 = fig.add_subplot(gs[0,0])
ax1.plot(freq, decibel(zmean), '#3182bd')
Expand All @@ -95,28 +83,8 @@ def decibel(x):
ax1.annotate('Frequency range scanned: '+str(float(fminimum)/1000000)+'-'+str(float(fmaximum)/1000000)+' MHz ($\\Delta\\nu$ = '+str(float((fmaximum)-float(fminimum))/1000000)+' MHz)\nBandwidth per spectrum: '+str(float(samp_rate)/1000000)+' MHz\nIntegration time per spectrum: '+str(dur)+" sec\nNumber of channels per spectrum (FFT size): "+str(nchan), xy=(17, 1179), xycoords='axes points', size=32, ha='left', va='top', color='brown')
ax1.grid()

#Plot dynamic spectrum
#ax2 = fig.add_subplot(gs[1,0])
#ax2.imshow(decibel(z_final), origin="lower", interpolation="None", aspect="auto",
# extent=[np.min(freq), np.max(freq), np.min(t), np.max(t)])
#ax2.ticklabel_format(useOffset=False)
#ax2.set_xlabel("Frequency (MHz)")
#ax2.set_ylabel("Time (s)")
#ax2.set_title("Dynamic Spectrum (Waterfall)")

#Plot Power vs Time
#ax3 = fig.add_subplot(gs[1,:])
#ax3.plot(v,w)
#ax3.axvline(x=9180, color='blue', linestyle='--', linewidth=2)
#ax3.axvline(x=8100, color='red', linestyle='--', linewidth=2)
#ax3.axvline(x=7200, color='orange', linestyle='--', linewidth=2)
#ax3.set_xlim(0,np.max(t)+tint)
#ax3.set_xlabel("Time (s)")
#ax3.set_ylabel("Relative Power")
#ax3.set_title("Power vs Time")

plt.tight_layout()
plt.savefig("rfi_plot.png")
#except Exception as e:
# print(e)
# pass
except Exception as e:
print(e)
pass

0 comments on commit d12c6cf

Please sign in to comment.