Commit f19c36cb authored by Romain Baptiste Dominique Albert's avatar Romain Baptiste Dominique Albert
Browse files

Merge remote-tracking branch 'origin/integrated_swept' into circle-fit-integrated-swept

parents ad51a530 6fb78292
......@@ -346,8 +346,8 @@ class Notch(circuit):
phi0=self.phi0,
weights=self._weights,
max_nfev=kwargs['maxfev'])
self.Ql, self.absQc, self.fr, self.phi1 = \
np.abs(self._cir_fit_pars[0])
self.Ql, self.absQc, self.fr, self.phi1 = self._cir_fit_pars[0]
self.absQc = np.abs(self.absQc)
self.finalfit = 'full'
else:
......@@ -380,8 +380,9 @@ class Notch(circuit):
phi0=self.phi0,
weights=self._weights,
max_nfev=kwargs['maxfev'])
self.Ql, self.absQc, self.fr, self.phi1 = \
np.abs(self._cir_fit_pars[0])
self.Ql, self.absQc, self.fr, self.phi1 = self._cir_fit_pars[0]
self.absQc = np.abs(self.absQc)
else:
self._cir_fit_pars = ft.fit_mag_notch(self.freq,
self.circle_norm,
......@@ -477,7 +478,8 @@ class Reflection(circuit):
self._weights)
# Calculate quality factors
self.Ql, self.absQc, self.fr, self.phi1, self.c = \
np.abs(self._cir_fit_pars[0])
self._cir_fit_pars[0]
self.absQc = np.abs(self.absQc)
self.finalfit = 'mag' # Indicator which final fit was used
self.Qc_real = self.absQc
self.Qi = 1. / (1. / self.Ql - 1. / self.Qc_real)
......@@ -506,7 +508,8 @@ class Reflection(circuit):
self._weights)
# Calculate quality factors
self.Ql, self.absQc, self.fr, self.phi1, self.c = \
np.abs(self._cir_fit_pars[0])
self._cir_fit_pars[0]
self.absQc = np.abs(self.absQc)
# Calculate errors
self.e = errcalc.get_errors_refl(self)
......
......@@ -39,14 +39,14 @@ def plot_rawdata(module, engine='b', fig=None, **kwargs):
if engine[0].lower() == 'b':
# Real/Imaginary
fig1 = plot_ReIm(module,engine=engine,fit=False, **kwargs)
fig1 = plot_ReIm(module, engine=engine, fit=False, **kwargs)
# Mag over freq
fig2 = plot_MagFreq(module, engine=engine, fit=False, **kwargs)
# Phase over freq
kwargs['x_range'] = fig2.x_range
fig3 = plot_PhaseFreq(module, engine=engine, fit=False, **kwargs)
fig = gridplot([fig1, fig2, fig3], ncols=3, plot_width=300,
plot_height=300)
fig = gridplot([fig1, fig2, fig3], ncols=3, width=300, height=300)
show(fig)
elif engine[0].lower() == 'p':
......@@ -73,12 +73,12 @@ def plot_cfit(module, engine='bokeh', fig=None, **kwargs):
# Mag over freq
fig2 = plot_MagFreq(module, engine=engine, fit=True, **kwargs)
# Phase over freq
kwargs['x_range'] = fig2.x_range
fig3 = plot_PhaseFreq(module, engine=engine, fit=True, **kwargs)
# Normalized circle
fig4 = plot_NormCircle(module, engine=engine, fit=True)
fig = gridplot([fig2, fig3, fig1, fig4], ncols=2, plot_height=350,
plot_width=350)
fig = gridplot([fig2, fig3, fig1, fig4], ncols=2, height=350, width=350)
show(fig)
elif engine[0].lower() == 'p':
......@@ -279,7 +279,7 @@ def plot_PhaseFreq(module, engine='b', fit=True, **kwargs):
))
# Figure
fig = figure(tools=TOOLS)
fig = figure(tools=TOOLS, **kwargs)
fig.xaxis.axis_label = 'Frequency (GHz)'
fig.yaxis.axis_label = 'Phase (deg)'
c3 = fig.line('freq', 'phase', source=source_data, line_width=2)
......
......@@ -40,8 +40,8 @@ class DA(Instrument):
def __init__(self, id_string, channel=0, driver=None, database=True, **kwargs):
# Device parameters ####################################################
super().__init__(id_string, kwargs, driver, database)
self.ch = int(channel)
super().__init__(id_string, kwargs=kwargs, driver=driver,
database=database)
self.devtype = 'DA'
# Import and load drivers ##############################################
......
......@@ -153,6 +153,20 @@ class E5080(VNAKeysight):
com_str = ":SENS{}:BAND:RES".format(channel)
return float(self.com(com_str, BW))
def set_trigger(self):
"""Set trigger to bus and activated the continuous measurement."""
self.com(':TRIG:SEQ:SOUR', 'MAN')
self.com('INIT:CONT', 'ON')
def reset_trigger(self):
"""Set trigger to internal and turn off the averaging trigger."""
self.com(':TRIG:AVER', 'OFF')
self.com(':TRIG:SEQ:SOUR', 'INT')
def send_trigger(self):
""" Send the trigger to initiate the measurement. """
self.com(':INIT', '')
def Spar(self, Par='?', Trace=1):
if type(Par) != str:
......
......@@ -6,6 +6,7 @@ import socketserver
import re
import pickle
import socket
import psutil
import traceback
parser = argparse.ArgumentParser(description='Server for an instrument driver')
......@@ -16,6 +17,14 @@ parser.add_argument('port', metavar=9001, type=int,
help='Port')
# Helper functions to obtain ip adresses
def get_ip_addresses(family):
for interface, snics in psutil.net_if_addrs().items():
for snic in snics:
if snic.family == family:
yield (interface, snic.address)
class Server(socketserver.StreamRequestHandler):
"""
Request handler for instruments.
......@@ -47,7 +56,11 @@ class Server(socketserver.StreamRequestHandler):
if __name__ == '__main__':
host = socket.gethostname()
# Hostnames may be tricky if there are multiple ethernet adapters. We
# always want the address starting with 192.168.XXX.XXX
ipv4s = list(get_ip_addresses(socket.AF_INET))
host = [i for _, i in ipv4s if i[:7] == "192.168"][0]
args = parser.parse_args()
port = args.port
......
......@@ -27,10 +27,11 @@ class PS(Instrument):
errors you can try to set it to False
"""
def __init__(self, id_string, driver=None, database=True):
def __init__(self, id_string, driver=None, database=True, **kwargs):
# Device parameters ####################################################
super().__init__(id_string, kwargs, driver, database)
super().__init__(id_string, kwargs=kwargs, driver=driver,
database=database)
self.devtype = 'PS'
# Import and load drivers ##############################################
......
......@@ -44,7 +44,8 @@ class SA(Instrument):
" now driver and not cryostat any longer!")
# Device parameters ####################################################
super().__init__(id_string, kwargs, driver, database)
super().__init__(id_string, kwargs=kwargs, driver=driver,
database=database)
self.devtype = 'SA'
# Import and load drivers ##############################################
......
......@@ -44,16 +44,10 @@ class SG(Instrument):
database=True, **kwargs):
# Device parameters ####################################################
super().__init__(id_string, kwargs, driver, database)
super().__init__(id_string, kwargs=kwargs, driver=driver,
database=database)
if isinstance(channel, int):
self.ch = channel
else:
# Prevent stupid mistakes
raise Exception("Incorrect channel. Please check! Second argument is"
" now channel and not cryostat any longer!")
self.devtype = 'SG'
# Load specific drivers ################################################
id_string = id_string.upper()
if id_string == 'FANTA4':
......
......@@ -36,8 +36,8 @@ class InstrumentEmpty():
class Instrument:
def __init__(self, id_string, kwargs, channel=1,
driver=None, database=True):
def __init__(self, id_string, kwargs, driver=None, database=True,
channel=1):
# Device Parameters ####################################################
try:
......
......@@ -140,6 +140,9 @@ def check_db(instrument):
return d
else:
print("No database mode.")
except PendingRollbackError:
db.session.rollback()
db.session.commit()
......
Markdown is supported
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