forked from thomaskern/horizongraph_matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata_loader.py
28 lines (21 loc) · 903 Bytes
/
data_loader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pandas
import numpy as np
class DataLoader:
def read_csv(self,filename):
data = pandas.read_csv("./data/"+filename, index_col=0)
y = data.values
x = data.index
labels=data.columns.values
return x, y, labels
def get_data(self, datasets=['simulatedflowdata.csv', 'observedflowdata.csv']):
'''
Load two datasets by name and estimate difference between two.
I'm using % difference here, but any other kind works.
NEED TO IMPLEMENT: check for differences in x and labels between the two datasets
:param datasets: list of csv filenames to load and plot difference
:return: x-axis labels, difference (y), and labels for each panel
'''
x1, y1, labels1 = self.read_csv(datasets[0])
x1, y2, labels2 = self.read_csv(datasets[1])
y_diff = np.divide(y1-y2,y2, out=np.zeros_like(y2,dtype=float), where=y2!=0)
return x1,y_diff, labels1