-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
43 lines (37 loc) · 1.18 KB
/
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
import torch
from lume_model.torch import PyTorchModel
def r_dist(x, y):
r = torch.sqrt(x**2 + y**2)
return r
class PyTorchModelCompoundPV(PyTorchModel):
def __init__(
self,
model_file,
input_variables,
output_variables,
input_transformers,
output_transformers,
output_format,
feature_order,
output_order,
default_vals: torch.Tensor,
):
super().__init__(
model_file,
input_variables,
output_variables,
input_transformers,
output_transformers,
output_format,
feature_order,
output_order,
)
self.default_values = default_vals
def _prepare_inputs(self, input_variables):
"""override this function to modify the dictionary for any compound PVs/features
that we don't measure directly from the machine"""
model_vals = super()._prepare_inputs(input_variables)
xrms = model_vals.pop("CAMR:IN20:186:XRMS")
yrms = model_vals.pop("CAMR:IN20:186:YRMS")
model_vals["CAMR:IN20:186:R_DIST"] = r_dist(xrms, yrms).double()
return model_vals