-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptvarmonitor.py
34 lines (29 loc) · 1.16 KB
/
ptvarmonitor.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
28
29
30
31
32
33
34
import pandas as pd
import numpy as np
import matplotlib as plt
import glob
from dataclasses import dataclass
class VarMonitor(object):
def __init__(self, *args, **kawgs):
self.config = 'config'
self.monitor = []
if "config_dir" in kawgs:
self.config = kawgs["config_dir"]
else:
pass
def read_config_files(self, config:str)->pd.DataFrame:
"""Reads in all configuration files from defined directory. Files are read into a custom "c-like" data
structure, PyStruct and appended to monitor class attribute. Function returns a PANDAS DataFrame object."""
for file in glob.glob('{config}/*.config'.format(config=config)):
data = pd.read_csv('{file}'.format(file=file), delimiter=',').replace(' ', np.nan)
self.monitor.append(PyStruct(data['variable_name'][0],
data['epics_name'][0],
data['upper_bound'][0],
data['lower_bound'][0]))
return data
@dataclass
class PyStruct:
name: str = ''
epics_name: str = ''
upper_bound: float = 0.0
lower_bound: float = 0.0