added parameter files and fixed a few issues

This commit is contained in:
2022-10-12 17:03:19 +02:00
parent f7c6cc271c
commit ee17250afa
5 changed files with 4569 additions and 8 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,9 @@
from epics import PV
from slic.core.adjustable import Adjustable, PVAdjustable
from slic.utils import json_load
from model import parallel2gap
from slic.utils import unpickle
from models.parallel_model import parallel2gap
from time import sleep
UND_PERIOD = 38.0
@ -37,12 +39,21 @@ class UndPhases(Adjustable):
self.phases = [UndPhase(i + SUFFIX, params[i]) for i in und_names]
def get_current_value(self):
#raise NotImplementedError #TODO: how to do that?
return 123
def set_target_value(self, value):
tasks = [p.set_target_value(value) for p in self.phases]
for t in tasks:
t.wait()
def is_moving(self):
return any(p.is_moving() for p in self.phases)
class UndPhase(Adjustable):
"""
@ -59,7 +70,8 @@ class UndPhase(Adjustable):
def get_current_value(self):
raise NotImplementedError #TODO: how to do that?
#raise NotImplementedError #TODO: how to do that?
return 123
def set_target_value(self, value):
@ -86,14 +98,17 @@ class UndShiftRadialBase(PVAdjustable): #TODO: better name?
def __init__(self, ID, accuracy=0.001):
super().__init__(ID + "-SET", ID + "-TL", accuracy=accuracy)
self.pv_on = PV(ID + "-ON")
self.pv_on = PV(ID + "-ONOFF")
self.pv_go = PV(ID + "-GO")
def set_target_value(self, value):
t = super().set_target_value(value)
sleep(0.3)
print('wait1')
sleep(0.9)
print('wait2')
self.pv_on.put(1)
sleep(0.3)
print('wait3')
sleep(0.9)
self.pv_go.put(1)
t.wait()
@ -136,13 +151,26 @@ class UndTotalK:
if __name__ == "__main__":
#phase = 123
phase = 90
phase = 95
check_phase(phase)
alldata = unpickle('./UE38_meas_and_fit_data.pickle')
params = alldata['fitdata']
measdata = alldata['measdata']
print('\n')
print(type(params))
print(params.keys())
params = json_load("UE38_all_parallel_parameters.json")
print('\n')
print(type(params))
print(params.keys())
ups = UndPhases("SATUN-PHASES", params)
ups.set_target_value(phase).wait()
sleep(1)
print(ups.phases[0], ups.phases[0].shift)
ups.phases[0].set_target_value(phase).wait()
print(ups.phases[0], ups.phases[0].shift)

View File

@ -2,7 +2,7 @@ import numpy as np
from scipy.optimize import fsolve
def parallel2gap(K, phi, undudict):
def antiparallel2gap(K, phi, undudict):
gLH = K2gap(K, undudict['K-value_LH'])
if phi >= 0.0:
gLV = K2gap(K, undudict['K-value_LV+'])
@ -25,3 +25,22 @@ def K2gap(Kval, fitparam):
## TODO: implement them properly:
def __antiparallel2gap(K, phi, undudict):
gLH = K2gap(K, undudict['K-value_LH'])
if phi >= 0.0:
fullpol2Kfit_app()
else:
gLV = K2gap(K, undudict['K-value_LV-'])
gC = K2gap(K, undudict['K-value_C-'])
dgLV = gLV - gLH
dgC = gC - gLH - dgLV/2
return gLH + dgLV * np.sin(0.5 * phi)**2 + dgC * np.sin(phi)**2
def fullpol2Kfit_apm(shiftlist, amp1, amp2, amp3, KLH, dKLV, dK45):
return KLH + dKLV * np.sin((0.5 * shiftlist)*ratio)**2 + dK45 * np.sin(shiftlist*ratio)**2 + amp1 * np.sin(2*shiftlist*ratio) + amp2 * np.sin((2.0 * shiftlist)*ratio)**2 + amp3 * np.cos(6*shiftlist*ratio)
def fullpol2Kfit_app(shiftlist, amp1, amp2, amp3, KLH, dKLV, dK45):
return KLH + dKLV * np.sin((0.5 * shiftlist)*ratio)**2 + dK45 * np.sin(shiftlist*ratio)**2 + amp1 * np.sin(2*shiftlist*ratio) + amp2 * np.sin((2.0 * shiftlist)*ratio)**2 + amp3 * np.cos(8*shiftlist*ratio)