def runMaster(pdb, rmsdcut): Master.createPDS( type='query', pdb=pdb, ) Master.masterSearch(query=changeExt(pdb, 'pds'), targetList=dblist, seqOut=changeExt(pdb, 'seq'), matchOut=changeExt(pdb, 'match'), rmsdCut=rmsdcut, topN=args.c1)
def main(): battlesimulator = Master() battlesimulator.introMessage() setupPlayers = SetupPlayers() setupPlayers.askPlayer() battlesimulator.displayStats(Warrior(1, 2, 3), Warrior(4, 5, 6)) warriorSet = WarriorSet(Warrior(1, 2, 3), Warrior(4, 5, 6)) warriorSet.printWarriors() simulation = Simulation() simulation.setWarriors(Warrior(1, 2, 3), Warrior(4, 5, 6)) simulation.run()
def press(btn): global text global path_to_save if btn == "SCAN": pass elif btn == "Done": app.hideSubWindow("After Processing") app.openPage("Paper Analysis", 4) elif btn == "START": app.showSubWindow("During Processing") path_to_linear = app.getEntry("path_to_black_white") path_to_color = app.getEntry("path_to_color") spreadsheet = Master.main(path_to_linear + '/', path_to_color + '/') excel.create_checking_sheet(spreadsheet) app.hideSubWindow("During Processing") app.showSubWindow("After Processing") elif btn == "Open File": os.system("see CheckSheet.xlsx") elif btn == "SAVE": path_to_save = app.saveBox(title="Save the Record File", fileName="Record", dirName=None, fileExt=".xlsx", fileTypes=None, asFile=None, parent=None) text = app.getTextArea("Details") excel.create_master_sheet(text, path_to_save)
def launch(self) -> None: ''' This is a REQUIRED method.\n Logic to actually begin the analysis. ''' self.dbCursor, self.dbConnection = sqlite_database.open_connection( self.githubRepo) # Unsure of what this code does due to lack of knowledge on how the database works Master.Logic(username=self.githubUser, repository=self.githubRepo, token=self.githubToken, tokenList=self.githubTokenList, cursor=self.dbCursor, connection=self.dbConnection).program()
def Snapshot(Client, filename, start=8): import Tag_Database as Tags M.Read(Client, Tags.CU_V) variables = vars(Tags) variables = np.array(list(variables.items())) variables = variables[start:] #variables[:,1] = variables[:,1].astype(int) #variables = variables[variables[:,1].argsort()] Tag_List = [] for item in variables: Tag_List.append([item[1], False]) temp_list = [] temp_list.append(M.Gather(Client, Tag_List, count=20, sleep_time=0.010)) with open(filename, 'w') as f: #Opening a file with the current date and time for num, line in enumerate(temp_list[0]): f.write(variables[num, 0] + ": " + str(line).strip("([])") + '\n') #Writing each line in that file f.close() #Closing the file to save it
def start(): global myMap global start args = request.args if start: myMap.find_nodes() start = False pair = False measure = False slam = False if args.get("pair") == "true": myMap.pair_nodes() print("Pairing") pair = True if args.get("measure") == "true": myMap.calculate_dist() print("Measuring") pair = True measure = True if args.get("slam") == "true": print("Slamming") myMap.distances = Master.run(myMap.data) pair = True measure = True slam = True pygame.display.quit() time.sleep(1) #pygame.quit() #print(args) return render_template( "public/index.html", myMap=myMap, start=True, pair=pair, measure=measure, slam=slam )
messagebox.showerror('Closed Browser', e) killProcess('chromedriver.exe') browser.quit() root.destroy() sys.exit() if length: print(length) prog.stop() prog.configure(mode='determinate') prog["maximum"]=length runT = Thread(target = narrow.pullOptions) runT.setDaemon(True) runT.start() if __name__ == '__main__': i = renderUserInfo() username = i[0] _pass = i[1] browser = Master.createBrowser(url='https://cln.utoronto.ca/home.htm',headless=False,blockImages=False,hideConsole=True) try: navigate(username,_pass) except LatencyException as e: messagebox.showerror('Internet Issues', e) except WebDriverException as e: messagebox.showerror('Chrome Closed', e) finally: browser.quit() killProcess('chromedriver.exe')
if not os.path.isfile(oseqf): continue olen = sum([1 for x in open(oseqf)]) if olen >= args.topn: omatchf = General.changeExt(oseqf, 'match') os.system('ln -s ' + oseqf + ' ' + seqout) os.system('ln -s ' + omatchf + ' ' + matchout) continue ### sub.call(['cp', pdb, ldir]) os.chdir(ldir) # run Master, bbrmsd is default try: Master.createPDS(pdb, True) if args.gap == None: Master.masterSearch(General.changeExt(pdb,'pds'), '/data/scratch/grigoryanlab/localDBs/'+args.db[0]+'/list', header = args.head, topN = args.topn, rmsdcut = rmsdeff, bbrmsd = (not args.carmsd)) else: if len(segments) == 1: os.chdir(odir) continue Master.masterSearch(General.changeExt(pdb,'pds'), '/data/scratch/grigoryanlab/localDBs/'+args.db[0]+'/list', header = args.head, topN = args.topn, rmsdcut = rmsdeff, gapLen = args.gap, outType = 'match', bbrmsd = (not args.carmsd)) if args.minn != None: # count lines in the current seq file nhit = 0 with open(seqout) as sf: for l in sf: nhit += 1 if nhit < args.minn:
#sites = ['meda'] # loop for each site for site in sites: print ('*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#') print (site) counter = 1; success = False while success == False: # create the folder where the month site data are going to be stored L0 = os.path.join(path1,site,'L0') if not os.path.exists(L0): os.makedirs(L0) os.makedirs(L0 + '/stat') # the route of each site folder route0 = os.path.join(path,site,'raw') # merge the data appended_data = Master.merge_files(route0, skip_rows = [0,2,3], include = ['Minuto']) # name of the columns to be extracted cols, _ = Master.col_name(site, appended_data, Timestamp = True, Record = True) # re-arrange the columns order appended_data = appended_data[cols] # convert the first data column into datetime64 appended_data['TIMESTAMP'] = pd.to_datetime(appended_data['TIMESTAMP'], dayfirst=False) #appended_data['TIMESTAMP'] = pd.to_datetime(appended_data['TIMESTAMP'], dayfirst = False, errors = 'coerce') #idx = appended_data[appended_data['TIMESTAMP'].isnull()].index appended_data, oldest, youngest = Master.fill_missing_measurements(appended_data) # get the last data month uploaded # 'site+_RECORD.dat' is file with the record of the upload dates Rrd = os.path.join('/home/met/data/',site,'L0',site+'_record.txt') # check the record F, R1, FileDate = Master.record(site, Rrd, oldest, youngest) # 'date2' is the string of the first date to be taken
from mpi4py import MPI import time from Worker import * from Master import * from IO import * from graph import * comm = MPI.COMM_WORLD rank = comm.Get_rank() size = comm.Get_size() if rank == size - 1: # master process master = Master(rank, size - 1, comm) master.Run() else: worker = Worker("../graph/large.graph", rank, size - 1, comm) worker.Local_Graph() worker.Local_Step()
- Read the Starting current of the Dump - At the beginning of each run, check to insure no human intervention has occurred with the write, if it has, kill the loop, continue to produce graphs and txt file - Add the appropriate step to each magnet - Read the current many times and then take the average of that current and store it alongside the written values for the magnets - Every step of the way check if the current has dropped below a specified threshold, if it has, then walk the magnets backs where they came from by the steps taken, plus the same amount of read steps going the other way. - Repeat the same safety checks, always check each step that the current hasn't reached a lowpoint beyond the threshold - When it has, or it reaches the end, turn the magnets back around to walk back to where they started. - Repeat for the other set of magnets (Vertical) - Plot and produce txt file with Magnet settings in the left column and current readbacks in the right ''' #Establish a connection to the PLC Client = M.Make_Client('10.50.0.10') #Dog Leg Target_Tag = Tags.Recirculator_Halfway #Importing the tag value from our Tag Database Target_Tag_2 = Tags.Recirculator_Bypass Threshold_Percent = 0 #Float. The percentage of beam that we want to collect in order to turn the Dog Leg around Zoom_In_Factor = 1 #This is how much we want to zoomn in if we are interested in an artifact at the center of the dog leg or want higher precision in the center #Starting the loop to read the current collected #Take the starting value of the Target Tag, use for the threshold read_steps = 40 #Integer. Number of steps to be taken in the Dog Leg. Must be an integer count = 10 #Integer. How many points will be recorded at each step and averaged over.
GameControl.restart() finish = False if first: turn = GameRule.PLAYER1 else: turn = GameRule.PLAYER2 # Individual Game while not finish: if GameControl.whos_turn() == turn: Monkey.take_move() else: Master.take_move(player_first=first) GameControl.print_game() finish = GameControl.is_end() # For statistics all_history.add(tuple(GameControl.history)) # Determine winner if GameControl.winner() == GameRule.PLAYER1 and not first or ( GameControl.winner() == GameRule.PLAYER2 and first): print("**Master wins**") m += 1 elif GameControl.winner() == GameRule.PLAYER2 and not first or ( GameControl.winner() == GameRule.PLAYER1 and first):
- Read Collected current - Repeat in ascending order - Repeat in descending order until reaching starting value - Plot - Save plot and txt file w/ snapshot as header ''' import matplotlib.pyplot as plt from datetime import datetime import time import numpy as np import Master as M import Tag_Database as Tags Client = M.Make_Client('10.50.0.10') End_Value = float(input("What is the ending amperage that you want to ramp the magnet to? (Amps) ")) #Grabbing all of our data for the system snapshot ################################################# Pulsing_Status = bool(M.Read(Client, Tags.Pulsing_Output, Bool = True)) Emission_Setpoint = M.Read(Client, Tags.Emission_Set) if Pulsing_Status: Emission_Actual = M.Read(Client, Tags.Emitted_Current, Average = True, count = 50, sleep_time = 0.010) else: Emission_Actual = M.Read(Client, Tags.Emitted_Current, Average = True, count = 20, sleep_time = 0.010) IR_Temp = M.Read(Client, Tags.IR_Temp)
import GPIB_FUNCS as GPIB #Importing our GPIB communication functions for easier comprehension and use import pyvisa #import GPIB communication module import time #imports time to sleep program temporarily import Master as M import Tag_Database as Tags Client = M.Make_Client('10.50.0.10') #Connecting to PLC print(M.Read(Client, Tags.Oscope_Reset, Bool = True)) print(M.Read(Client, Tags.Regulation_Setpoint_Reset, Bool = True)) print(M.Read(Client, Tags.Error_Signal_Regulation, Bool = True)) print(M.Read(Client, Tags.Pulsing_Output, Bool = True)) #for i in range(100): # M.Write(Client,55555, i) # print(i) # time.sleep(0.1) #Pulsing_Tag = Tags.Pulsing_Output #Assign Modbus address here Running_Tag = Tags.Error_Signal_Regulation #Assign Modbus address here #Reset_Tag = Tags.Error_Signal_Reset #Assign Modbus address here #Regulation_Setpoint_Tag = Tags.Regulation_Setpoint_Reset #Assign Modbus address here RM = pyvisa.ResourceManager() #pyVISA device manager Resources = RM.list_resources() #Printing out all detected device IDs print(Resources) SG = RM.open_resource("GPIB0::10::INSTR") OS = RM.open_resource("GPIB0::16::INSTR") time.sleep(2)
M.Read(Client, Tags.CU_V) variables = vars(Tags) variables = np.array(list(variables.items())) variables = variables[start:] #variables[:,1] = variables[:,1].astype(int) #variables = variables[variables[:,1].argsort()] Tag_List = [] for item in variables: Tag_List.append([item[1], False]) temp_list = [] temp_list.append(M.Gather(Client, Tag_List, count=20, sleep_time=0.010)) with open(filename, 'w') as f: #Opening a file with the current date and time for num, line in enumerate(temp_list[0]): f.write(variables[num, 0] + ": " + str(line).strip("([])") + '\n') #Writing each line in that file f.close() #Closing the file to save it now = datetime.today().strftime( '%y%m%d_%H%M' ) #Taking the current time in YYMMDD_HHmm format to save the plot and the txt file filename = now + '.txt' Client = M.Make_Client('10.50.0.10') Snapshot(Client, filename)
def test(self): Master.main()
import GPIB_FUNCS as GPIB #Importing our GPIB communication functions for easier comprehension and use import pyvisa #import GPIB communication module import time #imports time to sleep program temporarily import Master as M import numpy as np import Tag_Database as Tags from datetime import datetime import os def flasher(times): for _ in range(times): os.system('color DF') time.sleep(0.2) os.system('color 0F') Client = M.Make_Client('10.50.0.10') Pulsing_Tag = Tags.Pulsing_Output #Assign Modbus address here Running_Tag = Tags.Error_Signal_Regulation #Assign Modbus address here Reset_Tag = Tags.Oscope_Reset #Assign Modbus address here Regulation_Setpoint_Tag = Tags.Regulation_Setpoint_Reset #Assign Modbus address here Regulation_Entry_Tag = Tags.Regulation_Float #The input tag for this guy RM = pyvisa.ResourceManager() #pyVISA device manager Resources = RM.list_resources() #Printing out all detected device IDs print(Resources) try: SG = RM.open_resource(Resources[0]) #Opening the Signal generator as an object OS = RM.open_resource(Resources[1]) #Opening the oscilloscope as an object Start_Freq = float(SG.query("FREQ:CW?"))
import Master m = Master.master() m.start()
import Master as M import numpy as np import Tag_Database as Tags import os import time Client = M.Make_Client("10.50.0.10") M.Read(Client, Tags.CU_V) start = 134 os.system("Color 8a") variables = vars(Tags) variables = np.array(list(variables.items())) variables = variables[start:] #variables[:,1] = variables[:,1].astype(int) #variables = variables[variables[:,1].argsort()] Tag_List = [] for item in variables: if "Emitted_Current" in item[0]: Tag_List.append([item[1], True]) else: Tag_List.append([item[1], False]) while True: temp_list = [] a = time.time() temp_list.append(M.Gather(Client, Tag_List, count=20, sleep_time=0.010)) os.system('cls') print(time.time() - a)
from Master import * from Worker import * import random import sys import time """ Main of the implementation execute the Implementation. """ # create a Transaction with parameter if __name__ == '__main__': master = Master(name="Master") master.start() # start the Master Thread senders_receivers = [ "Marc", "Luc", "Antoine", "Mathieu", "Jean", "Patrick", "Stephane", "Junior" ] # list of Person to execute Transactions request maxAmount = sys.maxsize # initial Amount to the biggest interger in the system workers = [] # workers initialisations failedWorkers = [] # failed or malicious Workers workerNumber = 5 # numbers of Workers for i in range(1, workerNumber + 1): workers.append(StartWorker(name=f"Worker {i}")) master.addWorker(workers[i - 1]) # Present Workers to the Master for i in range(100): indexSender = random.randint(0, len(senders_receivers) -
pdb, pos = mut.p, mut.dir if not pdb in pdbs: pdbs.append(pdb) if not pos in positions: positions.append(pos) # run confind for all structures for pdb in pdbs: pdbf = args.i + '/' + pdb + '.pdb' assert os.path.isfile( pdbf), 'the pdb file ' + pdbf + ' does not exist; quit...' confind_out = changeExt(pdbf, 'conf') if os.path.isfile(confind_out): continue else: # run confind Master.confind(p=pdbf, o=confind_out, rLib=PATH_rotLib) # find homologs H**o = [] if args.homof != None: H**o = Analyze.findHomo(args.homof) # contact identification pos2cons = {} pos2pdb = {} odir = os.getcwd() for pos in positions: os.chdir(odir) if os.path.isdir(pos): os.system('rm -rf %s/*' % pos)
#!/usr/bin/env python from Master import * master = Master() master.createTable([{ 'key1': 'varchar(256)' }, { 'key2': 'int' }, { 'key3': 'varchar(1)' }, { 'key4': 'int' }, { 'res': 'int' }]) params = [['a', 'b', 'c', 'd'], [1, 2, 3, 4], ['x', 'y', 'z'], [10, 20, 30, 40]] master.setInputParams(params) master.start()
import Master as M from datetime import datetime import sys config_file_path = str(sys.argv[-1]) Tunnel, PLC_IP = M.config_reader(config_file_path, "Snapshot") Client = M.Make_Client(PLC_IP) now = datetime.today().strftime('%y%m%d_%H%M%S') #Taking the current time in YYMMDD_HHmm format to save the plot and the txt file M.Snapshot(Client, Tunnel, filename = f'.\Output Data\{Tunnel}\Snapshots\{now}_snapshot.txt')
class Painter(Frame): total = 1 mas = Master.Master() scaling = 10.0 intersection_Size = 4 ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##### # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### INITIALIZATION ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##### # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##### # def __init__(self, master=None): self.initializeFrame(master) self.initializeMap() self.after(10, self.update) def initializeFrame(self, master): Frame.__init__(self, master) Pack.config(self) self.createWidgets() def initializeMap(self): self.mas.printState() # Draw the intersections and streets for inter in self.mas.m.intersections: self.drawIntersection(inter, self.scaling * self.mas.m.intersections[inter][0], self.scaling * self.mas.m.intersections[inter][1]) for street in self.mas.m.streets: self.drawStreet(street) for car in self.mas.cars: self.drawCar(car) ############################################## ### stepping function ### ############################################## def update(self, *args): # Let the Master class do a time step self.mas.run(self.total) self.total += 1 self.mas.printCars() for car in self.mas.cars: if car.needsUpdate: self.updateCar(car) car.needsUpdate = False self.after(70, self.update) def updateCar(self, car): dx = self.getDX(car) dy = self.getDY(car) self.draw.move(car.name, dx, dy) def drawIntersection(self, label, x, y): self.draw.create_rectangle(x-self.intersection_Size, y-self.intersection_Size, x+self.intersection_Size ,y+self.intersection_Size ,tags=label, fill="blue") def drawStreet(self, street): x0 = self.mas.m.intersections[street[0]][0] * self.scaling y0 = self.mas.m.intersections[street[0]][1] * self.scaling x1 = self.mas.m.intersections[street[1]][0] * self.scaling y1 = self.mas.m.intersections[street[1]][1] * self.scaling #self.draw.create_rectangle(x0-1, y0-1, x1+1, y1) self.draw.create_line(x0, y0, x1, y1, fill="red",) def drawCar(self, car): x = self.getXY(car.curPos)[0] y = self.getXY(car.curPos)[1] self.draw.create_rectangle(x - 3, y - 3, x + 3, y + 3, tags=car.name, fill="green") def getXY(self, carPos): streetID = carPos[0] street = self.mas.m.streets[streetID] length = float(street[2]) x0 = self.mas.m.intersections[street[0]][0] * self.scaling y0 = self.mas.m.intersections[street[0]][1] * self.scaling x1 = self.mas.m.intersections[street[1]][0] * self.scaling y1 = self.mas.m.intersections[street[1]][1] * self.scaling direction = [x1 - x0, y1 - y0] progress = float(carPos[1]) return [x0 + progress/length * direction[0], y0 + progress/length * direction[1]] def getDX(self, car): return self.getXY(car.curPos)[0] - self.getXY(car.oldPos)[0] def getDY(self, car): return self.getXY(car.curPos)[1] - self.getXY(car.oldPos)[1] def createWidgets(self): self.QUIT = Button(self, text='QUIT', foreground='red', command=self.quit) self.QUIT.pack(side=BOTTOM, fill=BOTH) self.draw = Canvas(self, width="10i", height="10i") #self.speed = Scale(self, orient=HORIZONTAL, from_=-100, to=100) #self.speed.pack(side=BOTTOM, fill=X) # all of these work.. #self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue") self.draw.pack(side=LEFT)
#Adjust T scan Parameters Horizontal_Delta = .1 Vertical_Delta = .1 Resolution = 40 #Adjust Grid Parameters Grid_Resolution_Horizontal = 4 Grid_Resolution_Vertical = 5 #For the client IP = '192.168.1.2' Client = M.Make_Client(IP) WFH_Start = M.Read(Client, WFH_Tag) WFV_Start = M.Read(Client, WFV_Tag) ###### #Walking us to our starting point ###### for i in range(1, Grid_Resolution + 1): WFH_Write_Value = WFH_Start - i/2 * (Horizontal_Delta/Grid_Resolution) WFV_Write_Value = WFV_Start + i/2 * (Vertical_Delta/Grid_Resolution) M.Write(Client, WFH_Tag, WFH_Write_Value) M.Write(Client, WFV_Tag, WFV_Write_Value)
# prepare starting conformation p = parsePDB(args.p, chain = 'A') # assume the receptor is chain A # parse the range rangeS = [] for r in args.range: r = r.split('-') (start, end) = (r[0], r[-1]) end = str(int(end)+1) rangeS.append(start +':'+end) rangeS = ' '.join(rangeS) pocket = p.select('resnum '+ rangeS) writePDB('_pocket.pdb', pocket.copy()) # binding pocket # use master to create pds files Master.createPDS('_pocket.pdb') tem = '_'+General.removePath(args.m) os.system('cp '+args.m +' '+tem) Master.createPDS(tem, query= False) # search pocket in the template Master.masterSearch('_pocket.pds', str.replace(tem, 'pdb', 'pds'), bbrmsd = False, topN =1, rmsdcut = 5.0) # generate full match file for the template Master.matchInFile('_pocket.pds', '__pocket.match', '_match', 'full') ptem = parsePDB('_match/full1.pdb') # this is the superimposed templated structure assert ptem.numChains() == 2 chains = [] for chain in ptem.iterChains(): chains.append(chain) if chains[0].numResidues() < chains[1].numResidues(): # identify the peptide chain pepchain = chains[0]
- Read Collected current - Repeat in ascending order - Repeat in descending order until reaching starting value - Plot - Save plot and txt file ''' import matplotlib.pyplot as plt from datetime import datetime import time import numpy as np import Master as M import Tag_Database_East as Tags Client = M.Make_Client('192.168.1.6') End_Value = float( input( "What is the ending amperage that you want to ramp the magnet to? (Amps) " )) #Uncomment to make variable number of runs #Runs = int(input("How many runs do you want the Dipole to make? ")) Runs = 1 #Number of times you want to ramp to the input value and back to the start Dipole_Tag = Tags.DP1 #Modbus address of the magnet we are writing to Step_size = .001 #Step Size, in Amps, that we are taking to reach our goal Read = Tags.DBA_Bypass #Modbus address of the value we want to read while we scan the magnet count = 20 #Number of times we want to average the Read Tag value
Gun_Vac, Gun_Cross, SRF_Cavity_Vac, HE_Sraight_Vac, Insulating_Vac, E_Station_Vac ] Temps = [ BH_OC_Temp, DBA_Pipe_Temp, Cu_Gun_Temp, HE_Straight_Col, DBA_Dump_CHWR, DBA_Dump_CHWS, Tuner_Plate_Temp, Gate_Valve_Downstream_Temp, Gate_Valve_Upstream_Temp, Loop_Bypass_CHWS, Loop_Bypass_CHWR, DBA_Coupler, Coupler_Shoulder, Solenoid_4_Temp, Solenoid_5_Temp ] DST_Conversion = 3 if time.localtime().tm_isdst == 1: DST_Conversion = 4 Client = M.Make_Client("10.50.0.10") while True: start_time = time.time() temp_list = [time.time() * 10**3 - DST_Conversion * 60 * 60 * 1000] for Tag in Vacuums: temp_list.append(M.Read(Client, Tag)) file = open("Data.txt", 'a') file.write(str(temp_list).strip("[]") + "\n") file.close() with open("Data.txt", "r+") as file: contents = file.readlines() if np.shape(contents)[0] > txt_file_length:
bias harmonic field both on and off to help compensate for change in position of the cathode. This data is used to determine the strength of our accelerating fields and to help determine running parameters. Example of how to use it: - Run it ''' import Master as M import Tag_Database as Tags import numpy as np import matplotlib.pyplot as plt import time time_1 = time.time() Client = M.Make_Client("10.50.0.10") M.Read(Client, Tags.WF1H ) #Arbitrary read to establish trust (I think this part is weird to me) ################################################################ ### Initialize ################################################# ################################################################ V0_resolution = 50 #Resolution of steps taken in both cutoff measurements Num_sawtooths_1 = 1 #number of points taken in the first cutoff Num_sawtooths_2 = 1 #second cutoff ################################################################ ### Grab the operator input of V0 ranges ####################### ################################################################
- At the beginning of each write, check to insure no human intervention has occurred with the write, if it has, kill the loop, continue to produce graphs and txt file - Add the appropriate step to each magnet - Read the current many times and then take the average of that current and store it alongside the written values for the magnets - Every step of the way check if the current has dropped below a specified threshold, if it has, then walk the magnets backs where they came from by the steps taken, plus the same amount of read steps going the other way. - Repeat the same safety checks, always check each step that the current hasn't reached a lowpoint beyond the threshold - When it has, or it reaches the end, turn the magnets back around to walk back to where they started. - Repeat for the other set of magnets (Vertical) - Plot and produce txt file with Magnet settings in the left column and current readbacks in the right - Analyze the data and output the middle of the FWHM - Give the user the option to ramp to the optimal values ''' #Establish a connection to the PLC Client = M.Make_Client('10.50.0.20') start_time = time.time() #Dog Leg Move_To_Optimum = False Target_Tag = Tags.Recirculator_Halfway #Int or Str. Which Tag we are reading, 11109 is Loop bypass dump as of 01/01/2020 Target_Tag_2 = Tags.Recirculator_Bypass Threshold_Percent = 35 #Float. The percentage of beam that we want to collect in order to turn the Dog Leg around Zoom_In_Factor = 1 #This is how much we want to zoomn in if we are interested in an artifact at the center of the dog leg or want higher precision in the center Scale_Factor = 0.91 #This is how much we want to scale off of the excel documents used prior to Dog Legs #Starting the loop to read the current collected
import xlsxwriter import glob import os import pandas as pd #import Master as M import sys # insert at 1, 0 is the script path (or '' in REPL) sys.path.insert(1, '..\\') import Master as M import Tag_Database_West as Tags plot_type = 'png' Tunnel, PLC_IP, os_address, Runs, Step_Size, count, Oscope = M.config_reader( 'dp1_scan_config.txt', "Dipole Scan") # print(Tunnel, PLC_IP, os_address, Runs, Step_Size, count, Oscope) # print(type(Tunnel), type(PLC_IP), type(os_address), type(Runs), type(Step_Size), type(count), type(Oscope)) Client = M.Make_Client(PLC_IP) End_Value = float( input( "What is the ending amperage that you want to ramp the magnet to? (Amps) " )) now = datetime.today().strftime( '%y%m%d_%H%M%S' ) #Taking the current time in YYMMDD_HHmm format to save the plot and the txt file
- Repeat for the other set of magnets (Vertical) - Plot and produce txt file with Magnet settings in the left column and current readbacks in the right ''' import Master as M import time import matplotlib.pyplot as plt import numpy as np from datetime import datetime import Tag_Database as Tags #Establish a connection to the PLC Client = M.Make_Client('192.168.1.6') start_time = time.time() #Dog Leg Target_Tag = Tags.RF_Beam_Mon #Int or Str. Which Tag we are reading, we are interested in the RF Beam monitor currently Threshold_Percent = 0 #Float. The percentage of beam that we want to collect in order to turn the Dog Leg around Zoom_In_Factor = 1 #This is how much we want to zoom in if we are interested in an artifact at the center of the dog leg or want higher precision in the center Scale_Factor = 1 #This is how much we want to scale off of the excel documents used prior to Dog Legs mm_factor = 1 #Starting the loop to read the current collected #Take the starting value of the Target Tag, use for the threshold