misc
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
from matplotlib import pyplot as plt
|
||||
from datetime import datetime
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
from utilsv2 import stats, utils
|
||||
|
||||
|
||||
class Plotter:
|
||||
pass
|
||||
def __init__(self) -> None:
|
||||
self.x = []
|
||||
self.y = []
|
||||
self.figure = None
|
||||
self.ax = None
|
||||
|
||||
def plot_bars(self):
|
||||
pass
|
||||
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
|
||||
@@ -15,3 +28,47 @@ class Plotter:
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user