2023-01-29 10:31:30 -07:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
2023-01-29 14:32:28 -07:00
|
|
|
# polar-plot
|
2023-01-29 10:31:30 -07:00
|
|
|
#
|
2023-01-29 16:11:49 -07:00
|
|
|
# Copyright (C) 2022, 2023, Jeff Moe
|
2023-01-29 10:31:30 -07:00
|
|
|
# Copyright (C) 2023, Cees Bassa
|
2023-01-29 14:32:28 -07:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# polar_plot
|
|
|
|
# Generate graphical plot of radio interference.
|
|
|
|
#
|
|
|
|
# Usage:
|
2023-01-29 16:11:49 -07:00
|
|
|
# polar_plot [filename]
|
2023-01-29 14:32:28 -07:00
|
|
|
#
|
|
|
|
# Example:
|
2023-01-29 16:11:49 -07:00
|
|
|
# ./polar-plot data/sample.csv
|
|
|
|
# ./polar-plot data/rtl_power-sample.csv
|
2023-01-29 14:32:28 -07:00
|
|
|
|
2023-01-29 16:33:06 -07:00
|
|
|
import locale
|
2023-01-29 10:31:30 -07:00
|
|
|
import matplotlib.pyplot as plt
|
2023-01-29 16:33:06 -07:00
|
|
|
import numpy as np
|
2023-01-29 16:11:49 -07:00
|
|
|
import pandas as pd
|
|
|
|
import re
|
2023-01-29 16:33:06 -07:00
|
|
|
import seaborn as sns
|
|
|
|
import sys
|
2023-01-29 16:11:49 -07:00
|
|
|
|
2023-01-29 16:33:06 -07:00
|
|
|
locale.setlocale(locale.LC_ALL, "en_US.utf8")
|
|
|
|
plt.rcParams['axes.formatter.use_locale'] = True
|
2023-01-29 10:31:30 -07:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-01-29 16:11:49 -07:00
|
|
|
# Determine what type of file to load to dataframe
|
|
|
|
datafile = sys.argv[1]
|
|
|
|
|
|
|
|
with open(datafile) as f:
|
|
|
|
firstline = f.readline().rstrip()
|
|
|
|
|
|
|
|
if firstline == "1, -38.93":
|
|
|
|
print("Test data from sample.csv")
|
|
|
|
df = pd.read_csv(
|
|
|
|
datafile, skiprows=0, usecols=[0, 1], names=("Azimuth", "Energy")
|
|
|
|
)
|
|
|
|
|
|
|
|
elif re.match(re.compile("20*"), firstline):
|
|
|
|
print("rtl_power CSV file. Not yet supported.")
|
|
|
|
exit()
|
|
|
|
|
|
|
|
else:
|
|
|
|
print("Unknown file type.")
|
|
|
|
exit()
|
|
|
|
|
|
|
|
# Print the Dataframe loaded from CSV
|
|
|
|
with pd.option_context("display.max_rows", None, "display.max_columns", None):
|
|
|
|
print(df)
|
|
|
|
|
|
|
|
# (Empty) Plot here
|
2023-01-29 10:31:30 -07:00
|
|
|
fig = plt.figure(figsize=(8, 8))
|
|
|
|
ax = fig.add_subplot(111, projection="polar")
|
|
|
|
|
|
|
|
ax.set_theta_offset(np.pi / 2.0)
|
|
|
|
ax.set_rticks([90, 60, 30, 0])
|
|
|
|
ax.set_rgrids([90, 60, 30, 0], ["", "30$^\circ$", "60$^\circ$", ""], angle=22.5)
|
|
|
|
ax.grid(True)
|
|
|
|
ax.bar(0, 90).remove()
|
|
|
|
ax.set_rmax(90.0)
|
|
|
|
ax.set_ylim(0.0, 90.0)
|
|
|
|
|
|
|
|
plt.show()
|