75 lines
1.8 KiB
Python
75 lines
1.8 KiB
Python
from datetime import datetime
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
from utilsv2 import stats, utils
|
|
|
|
|
|
class Plotter:
|
|
def __init__(self) -> None:
|
|
self.x = []
|
|
self.y = []
|
|
self.figure = None
|
|
self.ax = None
|
|
|
|
def plot_bars(self, title: str, isDepth: bool = False):
|
|
self.figure, self.ax = plt.subplots()
|
|
|
|
self.ax.bar(self.x, self.y)
|
|
self.ax.set_title(title)
|
|
plt.show()
|
|
|
|
def plot_lin(self):
|
|
pass
|
|
|
|
def plot_box(self):
|
|
pass
|
|
|
|
def adjust_x(self):
|
|
pass
|
|
|
|
def add_x_values(self, xvalues):
|
|
self.x = xvalues
|
|
|
|
def add_y_values(self, yvalues):
|
|
self.y = yvalues
|
|
|
|
@staticmethod
|
|
def concat_data_day(data):
|
|
pass
|
|
|
|
@staticmethod
|
|
def concat_data_month(data):
|
|
x = []
|
|
y_vals = {"e": [], "m": [], "d": []}
|
|
|
|
currMonth: datetime = data[0]["DateTime"]
|
|
currMonth_str = utils.print_ym(currMonth)
|
|
|
|
x.append(currMonth_str)
|
|
e = 0
|
|
m = []
|
|
d = []
|
|
idx = 0
|
|
while idx <= len(data):
|
|
if data[idx]["DateTime"].month == currMonth.month and idx < len(data):
|
|
e += 1
|
|
m.append(data[idx]["Magnitudes"]["L"]["Magnitude"])
|
|
d.append(data[idx]["Depth"])
|
|
idx += 1
|
|
else:
|
|
y_vals["e"].append(e)
|
|
y_vals["m"].append(np.average(m))
|
|
y_vals["d"].append(np.average(d))
|
|
|
|
currMonth = data[idx]["DateTime"]
|
|
currMonth_str = utils.print_ym(currMonth)
|
|
|
|
x.append(currMonth_str)
|
|
e = 0
|
|
m = []
|
|
d = []
|
|
|
|
return x, y_vals
|