def booter(self, address): self.VNA = CreateObject("AgilentNA.AgilentNA") init_list = [ 'Simulate={0}'.format(self.simulate), #'QueryInstrStatus=true' ] init_str = ','.join(init_list) print init_str log_debug(self.VNA.Initialize(self.address, False, False, init_str)) self.ch1 = self.VNA.Channels["Channel1"] if not self.simulate: print self.VNA.System2.IO.IO.LockRsrc() if get_tag(self, 'abort', 'do', False): self.VNA_abort() #self.VNA_write("CALC:PAR:DEL:ALL") self.error_query() #log_debug(self.VNA.System2.WaitForOperationComplete(self.timeout)) #self.error_query() self.measS11 = self.ch1.Measurements["Measurement1"] self.measS21 = self.ch1.Measurements["Measurement2"] self.measS12 = self.ch1.Measurements["Measurement3"] self.measS22 = self.ch1.Measurements["Measurement4"] if self.simulate: self.stop_freq = 4.0e9 #sleep(1) #self.measS11.Create(1, 1) #self.error_query() #sleep(1) #self.measS11.Delete() #self.synchronize() self.error_query()
def plot_JDF(cls): xmin = minx([]) xmax = maxx([]) ymin = miny([]) ymax = maxy([]) cls.jdf.get_member("xy_offsets").reset(cls.jdf) xy_off = cls.jdf.xy_offsets log_debug(2) for p in cls.jdf.patterns: a = cls.agent_dict[p.name] reset_properties(a) #fix updating of properties reset_property(a, "polylist") log_debug(a) verts = [] for chip in xy_off.get(p.name, []): sPoly(a, x_off=chip[0] * 1.0e-6, y_off=chip[1] * 1.0e-6, vs=verts) log_debug(a) cls.plot.set_data(a.name, verts, a.color) log_debug(a) xmin = min([minx(verts), xmin]) xmax = max([maxx(verts), xmax]) ymin = min([miny(verts), ymin]) ymax = max([maxy(verts), ymax]) log_debug(1) cls.plot.set_xlim(xmin, xmax) cls.plot.set_ylim(ymin, ymax) cls.plot.draw()
def _observe_abort(self, change): """observer for abort, logs abort""" if self.abort: if self.busy: log_debug("ABORTED: {0}".format(self.name)) else: self.abort = False
def booter(self, address): self.VNA=CreateObject("AgilentNA.AgilentNA") init_list=['Simulate={0}'.format(self.simulate), #'QueryInstrStatus=true' ] init_str=','.join(init_list) print init_str log_debug(self.VNA.Initialize(self.address, False, False, init_str)) self.ch1=self.VNA.Channels["Channel1"] if not self.simulate: print self.VNA.System2.IO.IO.LockRsrc() if get_tag(self, 'abort', 'do', False): self.VNA_abort() #self.VNA_write("CALC:PAR:DEL:ALL") self.error_query() #log_debug(self.VNA.System2.WaitForOperationComplete(self.timeout)) #self.error_query() self.measS11=self.ch1.Measurements["Measurement1"] self.measS21=self.ch1.Measurements["Measurement2"] self.measS12=self.ch1.Measurements["Measurement3"] self.measS22=self.ch1.Measurements["Measurement4"] if self.simulate: self.stop_freq=4.0e9 #sleep(1) #self.measS11.Create(1, 1) #self.error_query() #sleep(1) #self.measS11.Delete() #self.synchronize() self.error_query()
def plot_JDF(cls): xmin=minx([]) xmax=maxx([]) ymin=miny([]) ymax=maxy([]) cls.jdf.get_member("xy_offsets").reset(cls.jdf) xy_off=cls.jdf.xy_offsets log_debug(2) for p in cls.jdf.patterns: a=cls.agent_dict[p.name] reset_properties(a) #fix updating of properties reset_property(a, "polylist") log_debug(a) verts=[] for chip in xy_off.get(p.name, []): sPoly(a, x_off=chip[0]*1.0e-6, y_off=chip[1]*1.0e-6, vs=verts) log_debug(a) pf=cls.plot.plot_dict.get(a.name+"_plot", None) if pf is None: cls.plot.polygon(verts, color=a.color, plot_name=a.name+"_plot") else: pf.alter_xy(verts, color=a.color) log_debug(a) xmin=min([minx(verts), xmin]) xmax=max([maxx(verts), xmax]) ymin=min([miny(verts), ymin]) ymax=max([maxy(verts), ymax]) log_debug(1) cls.plot.set_xlim(xmin, xmax) cls.plot.set_ylim(ymin, ymax) cls.plot.draw()
def _observe_abort(self, change): """observer for abort, logs abort""" if self.abort: if self.busy: log_debug("ABORTED: {0}".format(self.name)) else: self.abort=False
def receive(self, name, **kwargs): """performs receive of parameter name i.e. executing associated get_cmd with value checking""" get_cmd = get_tag(self, name, 'get_cmd') if self.status == "Active": if get_cmd != None: if not hasattr(get_cmd, "pname"): get_cmd = log_func(get_cmd, name) set_tag(self, name, get_cmd=get_cmd) self.receive_log(name) Instrument.busy = True value = get_cmd(self, **kwargs) log_debug(value) Instrument.busy = False temp = get_tag(self, name, 'send_now', self.send_now) set_tag(self, name, send_now=False) value = get_value_check(self, name, value) setattr(self, name, value) set_tag(self, name, send_now=temp) else: log_warning( "WARNING: {instr} {name} get_cmd doesn't exist".format( instr=self.name, name=name)) else: log_warning("WARNING: Instrument {instr} not active".format( instr=self.name))
def new_func(self, *args, **kwargs): """logs the call of an instance method and autoinserts kwargs""" if get_tag(self, pname, "log", False): log_debug(log_message.format(getattr(self, "name", ""), func_name), n=1) if len(args) == 0: members = self.members().keys() for param in get_run_params(new_func): if param in members: if param in kwargs: try: setattr(self, param, kwargs[param]) except TypeError: set_tag(self, param, do=kwargs[param]) else: if param in get_property_names(self): self.get_member(param).reset(self) value = getattr(self, param) value = set_value_map(self, param, value) kwargs[param] = value #if hasattr(obj, "chief"): #not working. how to get return value? # objargs=(obj,)+args # return_value=do_it_if_needed(obj.chief, self.func, *objargs, **kwargs) #else: return func(self, *args, **kwargs)
def closer(self): for key in self.S_names: if getattr(self, 'do'+key): getattr(self, 'meas'+key).Delete() #self.VNA_abort() if not self.simulate: print self.VNA.System2.IO.IO.UnlockRsrc() log_debug(self.VNA.Close()) for n in self.loop(10): if self.VNA.Release()==0: break
def full_fano_fit(self): p = [200e6,4.5e9, 0.002, 0.022, 0.1] fit_func, resid_func=fano_dict[self.fit_type] var=self.MagAbsFilt**2 flux_par=self.flux_par freqs=self.frequency log_debug("started fano fitting") fit_params=[self.fano_fit(n, var, flux_par, freqs, resid_func, p) for n in range(len(self.frequency))] fit_params=array(zip(*fit_params)) log_debug("ended fano fitting") return fit_params
def closer(self): for key in self.S_names: if getattr(self, 'do' + key): getattr(self, 'meas' + key).Delete() #self.VNA_abort() if not self.simulate: print self.VNA.System2.IO.IO.UnlockRsrc() log_debug(self.VNA.Close()) for n in self.loop(10): if self.VNA.Release() == 0: break
def new_func(self, *args, **kwargs): if new_func.log: log_debug(new_func.log_message.format(getattr(self, "name", ""), new_func.func_name), n=2) for param in new_func.run_params[len(args):]: if param not in kwargs: kwargs[param]=getattr(self, param) if new_func.threaded: #doesn't return value from thread names=[thread.name for thread in self.thread_list if new_func.func_name in thread.name] return self.add_thread("{0} {1}".format(new_func.func_name, len(names)), func, *((self,)+args), **kwargs) else: return func(self, *args, **kwargs) return func(self, *args, **kwargs)
def full_fano_fit(self): p = [200e6, 4.5e9, 0.002, 0.022, 0.1] fit_func, resid_func = fano_dict[self.fit_type] var = self.MagAbsFilt**2 flux_par = self.flux_par freqs = self.frequency log_debug("started fano fitting") fit_params = [ self.fano_fit(n, var, flux_par, freqs, resid_func, p) for n in range(len(self.frequency)) ] fit_params = array(zip(*fit_params)) log_debug("ended fano fitting") return fit_params
def observe_doSs(self, change): log_debug(change) if change['type']=='update': Sname=change["name"][2:] if change.get("oldvalue", False): log_debug('del old meas') log_debug(getattr(self, 'meas'+Sname).Delete()) self.error_query() elif change["value"]: ReceiverPort=int(Sname[1]) SourcePort=int(Sname[2]) log_debug(ReceiverPort, SourcePort) if Sname not in self.query_measurements().values(): self.writer("CALC:PAR:DEF:EXT MEAS{0},{0}".format(Sname)) log_debug(getattr(self, 'meas'+Sname).Create(ReceiverPort, SourcePort)) self.error_query() print self.query_measurements() sleep(1) getattr(self, 'meas'+Sname).Format=0
def observe_doSs(self, change): log_debug(change) if change['type'] == 'update': Sname = change["name"][2:] if change.get("oldvalue", False): log_debug('del old meas') log_debug(getattr(self, 'meas' + Sname).Delete()) self.error_query() elif change["value"]: ReceiverPort = int(Sname[1]) SourcePort = int(Sname[2]) log_debug(ReceiverPort, SourcePort) if Sname not in self.query_measurements().values(): self.writer("CALC:PAR:DEF:EXT MEAS{0},{0}".format(Sname)) log_debug( getattr(self, 'meas' + Sname).Create(ReceiverPort, SourcePort)) self.error_query() print self.query_measurements() sleep(1) getattr(self, 'meas' + Sname).Format = 0
def receive(self, name, **kwargs): """performs receive of parameter name i.e. executing associated get_cmd with value checking""" get_cmd=get_tag(self, name, 'get_cmd') if self.status=="Active": if get_cmd!=None: if not hasattr(get_cmd, "pname"): get_cmd=log_func(get_cmd, name) set_tag(self, name, get_cmd=get_cmd) self.receive_log(name) Instrument.busy=True value=get_cmd(self, **kwargs) log_debug(value) Instrument.busy=False temp=get_tag(self, name, 'send_now', self.send_now) set_tag(self, name, send_now=False) value=get_value_check(self, name, value) setattr(self, name, value) set_tag(self, name, send_now=temp) else: log_warning("WARNING: {instr} {name} get_cmd doesn't exist".format(instr=self.name, name=name)) else: log_warning("WARNING: Instrument {instr} not active".format(instr=self.name))
def a(self): from time import sleep log_debug("a_called") for n in range(5): log_debug(n) if self.abort: break sleep(0.4) log_debug("a_endded")
def new_func(self, *args, **kwargs): """logs the call of an instance method and autoinserts kwargs""" if get_tag(self, name, "log", False): log_debug("RAN: {}".format(name), n=1) if len(args)==0: members=self.members() for param in get_run_params(new_func): if param in members: if param in kwargs: try: setattr(self, param, kwargs[param]) except TypeError: pass else: if param in get_property_names(self): self.get_member(param).reset(self) value=getattr(self, param) #value=set_value_map(obj, param, value) kwargs[param]=value #if hasattr(obj, "chief"): #not working. how to get return value? # objargs=(obj,)+args # return_value=do_it_if_needed(obj.chief, self.func, *objargs, **kwargs) #else: return func(self, *args, **kwargs)
def add_poly_plot(self, n, verts, cn="green", polyname=""): #for n,p in enumerate(self.polylist): log_debug("drawing polygon #: {0}".format(n)) #npoints = p.verts #n_gon(center=p, r=2, nsides=nsides) nxarray, nyarray = transpose(verts) self.pd.set_data("x" + str(n), nxarray) self.pd.set_data("y" + str(n), nyarray) log_debug("data set") self.plot.plot(("x"+str(n), "y"+str(n)), type="polygon", face_color=cn, #colors[nsides], hittest_type="poly" )[0] log_debug("plot occured")
def do_data_save(self): save_txt_data(self.dir_path + self.divider, self.data) log_debug("Data saved to txt file at: {0}".format(self.file_path))
def do_data_save(self): rewrite_hdf5(self.save_file, self.data_buffer) log_debug("Data saved to hdf5 file at: {0}".format(self.file_path))
def full_fano_fit(self): log_debug("started fano fitting") fit_params=[self.fano_fit(n) for n in self.indices] fit_params=array(zip(*fit_params)) log_debug("ended fano fitting") return fit_params
# -*- coding: utf-8 -*- """ Created on Thu Jan 15 10:37:40 2015 @author: thomasaref Just a handy stand alone for testing GPIB instruments """ from taref.instruments.GPIB import GPIB_Instrument, InstrumentError from atom.api import Unicode, Float, Enum, Int, Bool from taref.core.atom_extension import private_property, safe_log_debug from time import sleep from taref.core.log import log_debug log_debug('hji') def get_voltage(self): """gets voltage, header on or off, and overload""" result = self.asker('OD') if result[0] not in ('N', 'E'): header = 0 else: header = 1 if result[0] == 'E': overload = True else: overload = False mode = 'V' if header == 1: mode = result[3]
def colormesh(self, zname, *args, **kwargs): print "yooyoy" log_debug(zname) self.clts[zname]=self.axe.pcolormesh(*args, **kwargs) self.xyfs[zname]=XYFormat(plotter=self, name=zname) log_debug(self.xyfs)
def changer(self, change): log_debug(change)
def error_query(self): for n in range(11): err_query=self.VNA.Utility.ErrorQuery() log_debug(err_query, n=3) if err_query[0]==0: break
def log_save(self): log_debug("Data saved to text file at: {0}".format(self.file_path))
def another_f(self): print msg("that", n=5) log_debug("this") log_debug("this", n=100) fb=f_top() print fb.f_locals
return 'LiNbYZ' @private_property def view_window2(self): from enaml import imports with imports(): from taref.saw.idt_e import IDT_View return IDT_View(idt=self) if __name__ == "__main__": from taref.core.shower import shower a = IDT() b = IDT() log_debug(a.K2, b.K2) a.Dvv = 5 print a._get_Dvv(4) log_debug(a.get_member("K2").fget.fset_list) log_debug(a.get_member("K2").fset(a, 3)) log_debug(a.get_member("K2").fset) print a.K2, b.K2 for param in a.all_params: print get_tag(a, param, "unit") shower(a) print a.call_func( "eta", a=0.2e-6, g=0.8e-6) #, vf=array([500.0, 600.0]), lbda0=array([0.5e-6, 0.6e-6])) a.plot_data("f0", lbda0=linspace(0.1e-6, 1.0e-6, 10000))
def _default_material(self): return 'LiNbYZ' @private_property def view_window2(self): from enaml import imports with imports(): from taref.saw.idt_e import IDT_View return IDT_View(idt=self) if __name__=="__main__": from taref.core.shower import shower a=IDT() b=IDT() log_debug(a.K2, b.K2) a.Dvv=5 print a._get_Dvv(4) log_debug(a.get_member("K2").fget.fset_list) log_debug(a.get_member("K2").fset(a, 3)) log_debug(a.get_member("K2").fset) print a.K2, b.K2 for param in a.all_params: print get_tag(a, param, "unit") shower(a) print a.call_func("eta", a=0.2e-6, g=0.8e-6)#, vf=array([500.0, 600.0]), lbda0=array([0.5e-6, 0.6e-6])) a.plot_data("f0", lbda0=linspace(0.1e-6, 1.0e-6, 10000)) print a.get_tag("lbda0", "unit_factor") show()
def do_data_save(self): save_txt_data(self.dir_path+self.divider, self.data) log_debug("Data saved to txt file at: {0}".format(self.file_path))
linewidth=4.0e-6, color="purple") glm_cross=Symmetric_Cross(name="GLM_CROSS", height=1000.0e-6, linewidth=20.0e-6, color="red") small_glm_cross=Symmetric_Cross(name="SMALL_GLM_CROSS", height=250.0e-6, linewidth=25.0e-6, color="red") align_cross_horiz=Cross(name="ALIGN_HORIZ", height=450.0e-6, width=4000.0e-6, linewidth=50.0e-6, color="red") align_cross_vert=Cross(name="ALIGN_VERT", height=4000.0e-6, width=450.0e-6, linewidth=20.0e-6, color="red") big_A=Digit(name="BIG_A", digit="A", digit_height=2500.0e-6, lettering_width=350.0e-6) big_B=Digit(name="BIG_B", digit="B", digit_height=2500.0e-6, lettering_width=350.0e-6) big_C=Digit(name="BIG_C", digit="C", digit_height=2500.0e-6, lettering_width=350.0e-6) big_D=Digit(name="BIG_D", digit="D", digit_height=2500.0e-6, lettering_width=350.0e-6) photo_cross=Symmetric_Cross(name="PHOTO_CROSS", height=100.0e-6, linewidth=10.0e-6) inv_photo_cross=Symmetric_Inverse_Cross(name="INV_PHOTO_CROSS", height=120.0e-6, linewidth=12.0e-6) #dashed_line_horiz=Dashed_Line_Horiz(name="DASHED_LINE_HORIZ") horiz_long_line=Rectangle(name="HORIZ_LONG_LINE", height=1.0e-3, width=85.0e-3) vert_long_line=Rectangle(name="VERT_LONG_LINE", height=85.0e-3, width=1.0e-3) horiz_short_line=Rectangle(name="HORIZ_SHORT_LINE", height=0.5e-3, width=40.0e-3) vert_short_line=Rectangle(name="VERT_SHORT_LINE", height=40.0e-3, width=0.5e-3) wafer_align=Wafer_Aligner(name="HORIZ_W_ALIGN") wafer_align=Wafer_Aligner(name="VERT_W_ALIGN", angle=90.0) pads.jdf.input_jdf=jdf_text log_debug(pads.agent_dict.keys()) pads.show()
def error_query(self): for n in range(11): err_query = self.VNA.Utility.ErrorQuery() log_debug(err_query, n=3) if err_query[0] == 0: break
def colormesh(self, zname, *args, **kwargs): print "yooyoy" log_debug(zname) self.clts[zname] = self.axe.pcolormesh(*args, **kwargs) self.xyfs[zname] = XYFormat(plotter=self, name=zname) log_debug(self.xyfs)
# -*- coding: utf-8 -*- """ Created on Thu Jan 15 10:37:40 2015 @author: thomasaref Just a handy stand alone for testing GPIB instruments """ from taref.instruments.GPIB import GPIB_Instrument, InstrumentError from atom.api import Unicode, Float, Enum, Int, Bool from taref.core.atom_extension import private_property, safe_log_debug from time import sleep from taref.core.log import log_debug log_debug('hji') def get_voltage(self): """gets voltage, header on or off, and overload""" result=self.asker('OD') if result[0] not in ('N', 'E'): header=0 else: header=1 if result[0]=='E': overload=True else: overload=False mode='V' if header==1: mode=result[3]
# -*- coding: utf-8 -*- """ Created on Mon Jan 11 11:16:33 2016 @author: thomasaref """ from taref.core.log import log_debug log_debug("hello")
def _observe_b(self, change): log_debug(change)
Rn=(7.62e3+7.96e3)/2.0 #Calculated values Ic=pi*Delta/(2.0*e)/Rn #Ambegaokar Baratoff formula Ejmax=hbar*Ic/(2.0*e) if finger_type=="single": Cq=W*Npq*epsinf #Morgan else: Cq=sqrt(2.0)*W*Npq*epsinf #Morgan #Cq=W*Npq*epsinf #Morgan Ec=e**2/(2.0*Cq) log_debug( (qdt.Ct, Cq)) log_debug( (qdt.Ec, Ec)) def flux_rescale(yoko, offset=0.09): #return (yoko-0.07)*0.198 return (yoko-offset)*0.195 def flux_parabola(flux_over_flux0): Ej = Ejmax*absolute(cos(pi*flux_over_flux0)) E0 = sqrt(8.0*Ej*Ec)*0.5 - Ec/4.0 E1 = sqrt(8.0*Ej*Ec)*1.5 - (Ec/12.0)*(6.0+6.0+3.0) return (E1-E0)/h def detuning(f0, flux_over_flux0): return 2.0*pi*(f0 - flux_parabola(flux_over_flux0))
def another_f(self): print msg("that", n=5) log_debug("this") log_debug("this", n=100) fb = f_top() print fb.f_locals
jdf.arrays.append(JDF_Array(array_num=n+1, assigns=[JDF_Assign(assign_type=['P({0})'.format(n+1)], shot_assign=patterns[p].get("shot_mod", ""), #pos_assign=patterns[p].get("pos", [(1,1)]) assign_comment=p)])) jdf.arrays[0].assigns.append(JDF_Assign(assign_type=['A({0})'.format(n+1)], assign_comment=p)) jdf.distribute_coords() return jdf if __name__=="__main__": a=JDF_Top() log_debug(a.agent_dict) jdf_data="""JOB/W 'IDT',4,-4.2 ; For exposure on YZ-cut LiNbO3, Cop+ZEP., q-wafer D GLMPOS P=(4000,-40000),Q=(40000,-4000) ;D wafer PATH ARRAY (7500,8,5000)/(-7500,8,5000) ; D wafer CHMPOS M1=(1500, 1500) ASSIGN A(1)+A(2)+A(15) -> ((1,1), (7,2), (6,4)) ;D32080 with two IDTs and Squid connect ASSIGN A(1)+A(3)+A(15) -> ((2,1), (8,2), (7,4)) ;S32080 with two IDTs and Squid connect ASSIGN A(1)+A(4)+A(15) -> ((3,1), (1,3), (1,5), (2,7)) ;S32050 with two IDTs and Squid connect ASSIGN A(1)+A(5)+A(15) -> ((4,1), (2,3), (2,5), (3,7)) ;D32050 with two IDTs and Squid connect ASSIGN A(1)+A(6)+A(15) -> ((5,1), (3,3), (3,5), (4,7)) ;D9050 with two IDTs and Squid connect ASSIGN A(1)+A(7)+A(15) -> ((6,1), (4,3), (4,5), (1,8)) ;S9050 with two IDTs and Squid connect ASSIGN A(1)+A(8)+A(15) -> ((7,1), (5,3), (5,5)) ;S9080 with two IDTs and Squid connect
Rn = (7.62e3 + 7.96e3) / 2.0 #Calculated values Ic = pi * Delta / (2.0 * e) / Rn #Ambegaokar Baratoff formula Ejmax = hbar * Ic / (2.0 * e) if finger_type == "single": Cq = W * Npq * epsinf #Morgan else: Cq = sqrt(2.0) * W * Npq * epsinf #Morgan #Cq=W*Npq*epsinf #Morgan Ec = e**2 / (2.0 * Cq) log_debug((qdt.Ct, Cq)) log_debug((qdt.Ec, Ec)) def flux_rescale(yoko, offset=0.09): #return (yoko-0.07)*0.198 return (yoko - offset) * 0.195 def flux_parabola(flux_over_flux0): Ej = Ejmax * absolute(cos(pi * flux_over_flux0)) E0 = sqrt(8.0 * Ej * Ec) * 0.5 - Ec / 4.0 E1 = sqrt(8.0 * Ej * Ec) * 1.5 - (Ec / 12.0) * (6.0 + 6.0 + 3.0) return (E1 - E0) / h