From 5b47eae88f0801ba9c9a33f5aab5aaa007fe319a Mon Sep 17 00:00:00 2001 From: Daniel Brown <ddb@star.sr.bham.ac.uk> Date: Fri, 15 May 2015 16:21:51 +0100 Subject: [PATCH] adding worst error to EI object, also fixing parsing for pd, qnoised and qshots --- bin/test_fsig.py | 13 +++++++------ pykat/SIfloat.py | 7 ++++++- pykat/detectors.py | 24 +++++++++++++++++++++--- pykat/optics/romhom.py | 5 +++-- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/bin/test_fsig.py b/bin/test_fsig.py index 66ccfa1..e26ceb3 100644 --- a/bin/test_fsig.py +++ b/bin/test_fsig.py @@ -15,16 +15,17 @@ m m2 0.99 0.01 -0.1 n3 n4 attr m2 m 1 # mech sus1 -ad up_refl 0 n1 -ad low_refl 0 n1 +ad up_refl $fs n1 +ad low_refl $fs n1 qd refl_A 0 0 n1 qd refl_Q 0 90 n1 qd tran_A 0 0 n4 qd tran_Q 0 90 n4 -put up_refl f $x1 -put low_refl f $mx1 +qnoised qnd 1 $fs max n4 +qshot qsd 1 $fs max n4 +pd1 p1 $fs max n4 yaxis log re:im @@ -47,10 +48,10 @@ a_up = out.y[:,0] + out.y[:,1]*1j a_lo = out.y[:,2] + out.y[:,3]*-1j pl.figure(1) -pl.loglog(out.x, np.abs(a_up + a_lo), out.x, np.abs((a_up - a_lo) / (1j))) +pl.loglog(out.x, out["p1"]) pl.xlabel(out.xlabel) pl.title("Reflection quadratures with no relative carrier phase") pl.legend(["Amplitude","Phase"]) -#pl.show() +pl.show() kat.remove(kat.signals) \ No newline at end of file diff --git a/pykat/SIfloat.py b/pykat/SIfloat.py index aa65c9e..d6e16ab 100644 --- a/pykat/SIfloat.py +++ b/pykat/SIfloat.py @@ -25,8 +25,13 @@ __suffix = {'y': 'e-24', # yocto 'P': 'e15' # peta } +__exceptions = ["$fs", "$mfs"] + def SIfloat(value): - if value==None: + if value is None: + return value + + if value in __exceptions: return value value = np.array(value) diff --git a/pykat/detectors.py b/pykat/detectors.py index 9fb0bd6..4609caa 100644 --- a/pykat/detectors.py +++ b/pykat/detectors.py @@ -597,7 +597,13 @@ class pd(Detector1): alt_str = "*" for n in range(1, 1+self.num_demods): - fphi_str += " {0:.16g}".format(float(self.__getattribute__("f"+str(n)))) + _f = self.__getattribute__("f"+str(n)) + + if _f == "$fs": + fphi_str += " $fs" + else: + fphi_str += " {0:.16g}".format(float(_f)) + phi_val = self.__getattribute__("phi"+str(n)) if phi_val != None: @@ -703,7 +709,13 @@ class qnoised(pd): alt_str = "*" for n in range(1, 1+self.num_demods): - fphi_str += " {0:.16g}".format(float(self.__getattribute__("f"+str(n)))) + _f = self.__getattribute__("f"+str(n)) + + if _f == "$fs": + fphi_str += " $fs" + else: + fphi_str += " {0:.16g}".format(float(_f)) + phi_val = self.__getattribute__("phi"+str(n)) if phi_val != None: @@ -795,7 +807,13 @@ class qshot(pd): alt_str = "*" for n in range(1, 1+self.num_demods): - fphi_str += " {0:.16g}".format(float(self.__getattribute__("f"+str(n)))) + _f = self.__getattribute__("f"+str(n)) + + if _f == "$fs": + fphi_str += " $fs" + else: + fphi_str += " {0:.16g}".format(float(_f)) + phi_val = self.__getattribute__("phi"+str(n)) if phi_val != None: diff --git a/pykat/optics/romhom.py b/pykat/optics/romhom.py index 5680c7a..de6eaa6 100644 --- a/pykat/optics/romhom.py +++ b/pykat/optics/romhom.py @@ -22,7 +22,7 @@ from scipy.integrate import newton_cotes from multiprocessing import Process, Queue, Array, Value, Event -EmpiricalInterpolant = collections.namedtuple('EmpiricalInterpolant', 'B nodes node_indices limits x') +EmpiricalInterpolant = collections.namedtuple('EmpiricalInterpolant', 'B nodes node_indices limits x worst_error') ReducedBasis = collections.namedtuple('ReducedBasis', 'RB limits x') ROMLimits = collections.namedtuple('ROMLimits', 'zmin zmax w0min w0max R mapSamples max_order') @@ -795,7 +795,8 @@ def MakeROMFromHDF5(hdf5Filename, greedyFilename=None, EIFilename=None, tol=1e-1 nodes=np.array(x_nodes).squeeze(), node_indices=np.array(EI_indices).squeeze(), limits=limits, - x=x.squeeze()) + x=x.squeeze(), + worst_error=worst_error) if EIFilename is not None: with open("%s.p" % EIFilename, 'wb') as f: -- GitLab