Commit 489129df authored by Daniel Brown's avatar Daniel Brown
Browse files

fixing fsig parsing of 'fsig signal frequency'. Adding code to allow surface motions.

parent 449bf621
......@@ -321,6 +321,11 @@ class AbstractMirrorComponent(Component):
self.__Frx = Param("Frx", self, None, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="Frx")
self.__Fry = Param("Fry", self, None, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="Fry")
self.__Fs0 = Param("Fs0", self, None, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="Fs0")
self.__Fs1 = Param("Fs1", self, None, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="Fs1")
self.__Fs0 = Param("s0", self, None, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="s0")
self.__Fs1 = Param("s1", self, None, canFsig=True, isPutable=False, isPutter=False, isTunable=False, fsig_name="s1")
self._default_fsig_param = self.__phi
@property
......
......@@ -382,6 +382,7 @@ class Signals(object):
return rtn
@property
def name(self):
# if we don't have any signals yet then use a dummy name
......@@ -389,7 +390,7 @@ class Signals(object):
# so need to get the name of at least one of them
# as if you tune one you tune them all
if len(self.targets) == 0:
return "fsignal"
return self._default_name
else:
return self.targets[0].name
......@@ -408,6 +409,7 @@ class Signals(object):
def f(self,value): self.__f.value = SIfloat(value)
def __init__(self, kat):
self._default_name = "fsignal"
self.targets = []
self._params = []
self.__f = Param("f", self, 1)
......@@ -429,6 +431,11 @@ class Signals(object):
def getFinesseText(self):
rtn = []
if len(self.targets) == 0 and self.f != 0:
rtn.append("fsig {name} {frequency}"
.format(name = self.name,
frequency=str(self.f)))
else:
for t in self.targets:
rtn.extend(t.getFinesseText())
......@@ -1003,6 +1010,10 @@ class kat(object):
name = str(v[1])
if len(v) == 3:
self.signals._default_name = name
self.signals.f = SIfloat(v[2])
else:
if v[2] not in self.__components:
raise pkex.BasePyKatException("Could not find the component '{0}'. Line: '{1}'".format(v[2], line))
......@@ -1014,7 +1025,10 @@ class kat(object):
param_name = None
amp = None
if len(v) == 5:
if len(v) == 3:
self.signals._default_name = name
freq = SIfloat(v[3])
elif len(v) == 5:
#param is None
freq = SIfloat(v[3])
phase = SIfloat(v[4])
......@@ -1044,6 +1058,7 @@ class kat(object):
raise pkex.BasePyKatException("'{0}' isnot a valid fsig command".format(line))
self.signals.f = freq
param = None
if param_name is None:
......
......@@ -16,6 +16,7 @@ from __future__ import print_function
from pykat.optics.romhom import makeWeightsNew
from scipy.interpolate import interp2d, interp1d
from pykat.maths.zernike import *
from pykat.exceptions import BasePyKatException
import numpy as np
import math
......@@ -108,11 +109,11 @@ class surfacemap(object):
@property
def x(self):
return self.step_size[0] * (np.array(range(1, self.data.shape[0]+1)) - self.center[0])
return self.step_size[0] * (np.array(range(0, self.data.shape[0])) - self.center[0])
@property
def y(self):
return self.step_size[1] * (np.array(range(1, self.data.shape[1]+1))- self.center[1])
return self.step_size[1] * (np.array(range(0, self.data.shape[1]))- self.center[1])
@property
def size(self):
......@@ -120,7 +121,7 @@ class surfacemap(object):
@property
def offset(self):
return np.array(self.step_size)*(np.array(self.center) - 1/2. - np.array(self.size)/2.0)
return np.array(self.step_size)*(np.array(self.center) - (np.array(self.size)-1)/2.0)
@property
def ROMWeights(self):
......@@ -176,6 +177,11 @@ class surfacemap(object):
return np.sqrt(1.0 - data)
else:
return np.sqrt(1.0 - data[:, ::-1])
elif "surface_motion" in self.type:
if direction == "reflection_front":
return data
else:
return data[:, ::-1]
else:
raise BasePyKatException("Map type needs handling")
......@@ -193,6 +199,9 @@ class surfacemap(object):
return np.sqrt(1.0 - data)
else:
return np.sqrt(1.0 - data[:, ::-1])
elif "surface_motion" in self.type:
return np.ones(data.shape)
else:
raise BasePyKatException("Map type needs handling")
......@@ -274,10 +283,10 @@ class surfacemap(object):
D = interp2d(self.x, self.y, self.data, **kwargs)
data = D(nx-self.offset[0], ny-self.offset[0])
data = D(nx-self.offset[0], ny-self.offset[1])
Dx = interp1d(nx, np.arange(1,len(nx)+1))
Dy = interp1d(ny, np.arange(1,len(ny)+1))
Dx = interp1d(nx, np.arange(0,len(nx)))
Dy = interp1d(ny, np.arange(0,len(ny)))
self.center = (Dx(0), Dy(0))
self.step_size = (nx[1]-nx[0], ny[1]-ny[0])
......@@ -313,7 +322,7 @@ class surfacemap(object):
yrange = 100*self.y
fig = pylab.figure()
axes = pylab.pcolormesh(xrange, yrange, self.data, vmin=zmin, vmax=zmax)
axes = pylab.pcolormesh(xrange, yrange, self.data*self.scaling, vmin=zmin, vmax=zmax)
pylab.xlabel('x [cm]')
pylab.ylabel('y [cm]')
......@@ -406,11 +415,11 @@ class mergedmap:
@property
def x(self):
return self.step_size[0] * (np.array(range(1, self.size[0]+1)) - self.center[0])
return self.step_size[0] * (np.array(range(0, self.size[0])) - self.center[0])
@property
def y(self):
return self.step_size[1] * (np.array(range(1, self.size[1]+1))- self.center[1])
return self.step_size[1] * (np.array(range(0, self.size[1])) - self.center[1])
@property
def size(self):
......@@ -418,7 +427,7 @@ class mergedmap:
@property
def offset(self):
return np.array(self.step_size)*(np.array(self.center) - 1/2. - np.array(self.size)/2.0)
return np.array(self.step_size)*(np.array(self.center) - (np.array(self.size)-1)/2.0)
@property
def ROMWeights(self):
......
......@@ -481,6 +481,7 @@ def MakeROMFromHDF5(hdf5Filename, greedyFilename=None, EIFilename=None, tol=1e-1
V[m][l] = RB_matrix[l][EI_indices[m]] # Part of (5) of Algorithm 2: making V_{ij}
invV = inv(V[0:len(EI_indices), 0:len(EI_indices)])
B = B_matrix(invV, np.array(RB_matrix))
_TS = TS[str(next_RB_index)]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment