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
|
||||
|
||||
@@ -3,7 +3,6 @@ from typing import Any
|
||||
|
||||
from pymongo import MongoClient
|
||||
from pymongo.collection import Collection
|
||||
from pymongo.cursor import Cursor
|
||||
from pymongo.errors import ConnectionFailure
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import json
|
||||
import logging
|
||||
import textwrap
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, time
|
||||
from typing import Any
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import logging
|
||||
from io import TextIOWrapper
|
||||
from typing import Any
|
||||
|
||||
try:
|
||||
from utilsv2 import utils
|
||||
|
||||
@@ -2,7 +2,6 @@ import time
|
||||
from datetime import datetime
|
||||
|
||||
import numpy as np
|
||||
from pymongo import MongoClient
|
||||
|
||||
|
||||
def print_filters(filters):
|
||||
|
||||
@@ -30,3 +30,7 @@ def toInt(v: str) -> int | None:
|
||||
return int(v)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
|
||||
def print_ym(dt: datetime) -> str:
|
||||
return dt.strftime("%Y-%m")
|
||||
|
||||
Reference in New Issue
Block a user