-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrta_model.py
50 lines (40 loc) · 1.58 KB
/
rta_model.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from peewee import SqliteDatabase, Model, IntegerField, CharField, FloatField, DateTimeField, CompositeKey, ForeignKeyField
import os
path = os.environ.get('RTA_SQLITE_PATH', '/scratch/rta/rta.sqlite')
print('Path to the sqlite db is {}'.format(path))
if not os.access(path, os.W_OK):
print('Could not read sqlite file')
raise IOError('could not read sqlite file')
database = SqliteDatabase(path, **{})
class BaseModel(Model):
class Meta:
database = database
class FactRun(BaseModel):
end_time = DateTimeField(null=True)
health = CharField(null=True)
night = IntegerField()
ontime_seconds = FloatField(null=True)
run = IntegerField(db_column='run_id')
source = CharField(null=True)
start_time = DateTimeField(null=True)
class Meta:
db_table = 'fact_run'
indexes = (
(('night', 'run'), True),
)
primary_key = CompositeKey('night', 'run')
class Signal(BaseModel):
analysis_timestamp = DateTimeField(null=True)
estimated_energy = FloatField()
event_timestamp = DateTimeField(null=True, primary_key=True)
night = ForeignKeyField(db_column='night', rel_model=FactRun, to_field='night')
prediction = FloatField()
run = ForeignKeyField(db_column='run_id', rel_model=FactRun, related_name='fact_run_run_set', to_field='run')
theta_off_1 = FloatField(null=True)
theta_off_2 = FloatField(null=True)
theta_off_3 = FloatField(null=True)
theta_off_4 = FloatField(null=True)
theta_off_5 = FloatField(null=True)
theta_on = FloatField()
class Meta:
db_table = 'signal'