Always plot measurement results
Signed-off-by: Fabian P. Schmidt <kerel@mailbox.org>pull/25/head
parent
098406bdd6
commit
720fba5dfa
|
@ -9,6 +9,7 @@ import ephem
|
||||||
import h5py
|
import h5py
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -52,32 +53,40 @@ def extract_peaks(data):
|
||||||
continue
|
continue
|
||||||
rows.append(i)
|
rows.append(i)
|
||||||
|
|
||||||
# Select only maximum values in masked channels
|
points_all = []
|
||||||
points = []
|
points_filtered = []
|
||||||
for i,x in enumerate(np.argmax(data, axis=1)):
|
for i,x in enumerate(np.argmax(data, axis=1)):
|
||||||
if not x in rows:
|
points_all.append([i, x])
|
||||||
continue
|
if x in rows:
|
||||||
points.append([i, x])
|
points_filtered.append([i, x])
|
||||||
points = np.array(points)
|
|
||||||
measurements = np.vstack((wf['relative_time'][points[:,0]],
|
|
||||||
[wf['frequency'][x] for x in points[:,1]]))
|
|
||||||
return snr, measurements, points
|
|
||||||
|
|
||||||
def plot_measurements(wf, data, measurements, snr):
|
points_all = np.array(points_all)
|
||||||
|
points_filtered = np.array(points_filtered)
|
||||||
|
|
||||||
|
if len(points_filtered) == 0:
|
||||||
|
print("WARNING: No measurement passed filter, loosening requirements now.")
|
||||||
|
points_filtered = points_all
|
||||||
|
measurements = None
|
||||||
|
|
||||||
|
measurements = np.vstack((wf['relative_time'][points_filtered[:,0]],
|
||||||
|
[wf['frequency'][x] for x in points_filtered[:,1]]))
|
||||||
|
return snr, measurements, points_filtered
|
||||||
|
|
||||||
|
def plot_measurements_all(wf, data):
|
||||||
plt.plot(wf['relative_time'][:],
|
plt.plot(wf['relative_time'][:],
|
||||||
[wf['frequency'][x] for x in np.argmax(data[:], axis=1)],
|
[wf['frequency'][x] for x in np.argmax(data[:], axis=1)],
|
||||||
'.',
|
'.',
|
||||||
label='all')
|
label='all')
|
||||||
plt.plot(measurements[:,0],
|
|
||||||
measurements[:,1],
|
def plot_measurements_selected(measurements):
|
||||||
|
plt.plot(measurements[0,:],
|
||||||
|
measurements[1,:],
|
||||||
'.',
|
'.',
|
||||||
label='automatic channel mask')
|
label='filtered')
|
||||||
plt.plot(wf['relative_time'][2.4 < snr],
|
|
||||||
[wf['frequency'][x] for x in np.argmax(data[2.4 < snr], axis=1)],
|
def plot_legend(observation_id):
|
||||||
'.',
|
|
||||||
label="SNR > 2.4")
|
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.title("Observation #4991792 - Maximum Values")
|
plt.title("Observation #{} - Maximum Values".format(observation_id))
|
||||||
plt.grid()
|
plt.grid()
|
||||||
plt.xlabel('Elapsed Time / s')
|
plt.xlabel('Elapsed Time / s')
|
||||||
plt.ylabel('rel. Frequency / kHz')
|
plt.ylabel('rel. Frequency / kHz')
|
||||||
|
@ -152,7 +161,10 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
print('Extract measurements...')
|
print('Extract measurements...')
|
||||||
snr, measurements, points = extract_peaks(data)
|
snr, measurements, points = extract_peaks(data)
|
||||||
# plot_measurements(wf, data, measurements, snr)
|
plot_measurements_all(wf, data)
|
||||||
|
plot_measurements_selected(measurements)
|
||||||
|
plot_legend(args.observation_id)
|
||||||
|
|
||||||
m2 = dedoppler(measurements, metadata)
|
m2 = dedoppler(measurements, metadata)
|
||||||
save_rffit_data(output_file, m2, site_id=args.site_id)
|
save_rffit_data(output_file, m2, site_id=args.site_id)
|
||||||
print('Data written in {}'.format(output_file))
|
print('Data written in {}'.format(output_file))
|
||||||
|
|
Loading…
Reference in New Issue