#list for corrector magnet values
magnet_values = [0 for i in range(len(magnet_list))]

while (cont == 'y'):
	if sandbox != 'y':

		#import current state
		#Get initial quad values
		q1_init, q2_init, q3_init, q4_init= GetQuads()

		#Tuning Q1 and Q2
		#take picture with all at init values
		SetQuads(q1_init, q2_init, 0, 0)
		sleep(10)
		all_nom_im= SaveIm('allNom', viewer)
		sleep(2)

		#take picture with all at zero
		SetQuads(0, 0, 0, 0)
		pos_1= GetBeamPos(all_nom_im, viewer)
		sleep(10) #might need to increase this if the jumps in current are big
		all_zero_im= SaveIm('allZero', viewer)
		sleep(2)

		#take picture with Q1 at half # CHANGED.... Q2 also half
		SetQuads(q1_init/2, q2_init/2, 0, 0)
		pos_2= GetBeamPos(all_zero_im, viewer)
		sleep(10)
		q1_half_im= SaveIm('q1half', viewer)
		sleep(2)
Ejemplo n.º 2
0
from setup import SaveIm, SetCorr, GetCorr, SetQuads, GetQuads, GetBeamPos, Dist, GaussProc, cont

while (cont == 'yes'):
	
	#import current state
	#Get initial corrector values
	h13_init, v13_init, h31_init, v31_init= GetCorr()
	#Get initial quad values
	q1_init, q2_init, q3_init, q4_init= GetQuads()

	#Tuning Q1 and Q2

	#take picture with all at init values
	SetQuads(q1_init, q2_init, 0, 0)
	sleep(7)
	all_nom_im= SaveIm('allNom')

	#take picture with all at zero
	SetQuads(0, 0, 0, 0)
	sleep(7) #might need to increase this if the jumps in current are big
	all_zero_im= SaveIm('allZero')

	#take picture with Q1 at half
	SetQuads(q1_init/2, q2_init, 0, 0)
	sleep(7)
	q1_half_im= SaveIm('q1half')

	#take picture with Q2 at half
	SetQuads(q1_init, q2_init/2, 0, 0)
	sleep(7)
	q2_half_im= SaveIm('q2half')
Ejemplo n.º 3
0
def scanDipoles(b_small, b_big):

    #set number of steps (from previous experience scanning although might need adjustments)
    bs_stepsize = small_step
    bb_stepsize = big_step

    #initial nominal quad values
    q0_init, q1_init = GetMagnet(quad_pair[0]), GetMagnet(quad_pair[1])

    for i in range(total_steps):

        print(f"Step {i+1} out of {total_steps} large steps.")
        #get initial current of dipoles 
        bs_init = GetMagnet(b_small) 
        bb_init = GetMagnet(b_big)

        #one magnet goes down 0.06 A, the other 0.02 A x 3
        SetMagnet( b_big, bb_init - bb_stepsize)

        for j in range(0, int(bb_stepsize/bs_stepsize)): 
            #ramps down this magnet in small steps multiple of the large step
            SetMagnet( b_small,   bs_init - bs_stepsize*(j+1))

            sleep(5)        

            #changing quads and taking pictures at 4 tunes
            #take picture with all at init values
            all_nom_im= SaveIm('allNom', viewer)

            #take picture with all at zero
            SetMagnet(quad_pair[0], 0)
            SetMagnet(quad_pair[1], 0)
            pos_1= GetBeamPos(all_nom_im, viewer)
            sleep(5) #might need to increase this if the jumps in current are big
            all_zero_im= SaveIm('allZero', viewer)

            #take picture with first quad at half
            SetMagnet(quad_pair[0], q0_init/2)
            pos_2= GetBeamPos(all_zero_im, viewer)
            sleep(5)
            q0_half_im= SaveIm('q0half', viewer)

            #take picture with second quad at half
            SetMagnet(quad_pair[1], q1_init/2)
            pos_3= GetBeamPos(q0_half_im, viewer)
            sleep(5)
            q01_half_im= SaveIm('q01half', viewer)

            #return quads to original values
            SetMagnet(quad_pair[0], q0_init)
            SetMagnet(quad_pair[1], q1_init)

            pos_4= GetBeamPos(q01_half_im, viewer)

            #peak/intensity
            #pk_1 = pos_1[2:]
            #pk_2 = pos_2[2:]
            #pk_3 = pos_3[2:]
            #pk_4 = pos_4[2:]
            #centroid positions
            pos_1 = pos_1[0:2]
            pos_2 = pos_2[0:2]
            pos_3 = pos_3[0:2]
            pos_4 = pos_4[0:2]

		
            #get quadratic distance from centroids
            print(f"Centroids:\n({pos_1[0]:.2f}, {pos_1[1]:.2f})\n({pos_2[0]:.2f}, {pos_2[1]:.2f})\n({pos_3[0]:.2f}, {pos_3[1]:.2f})\n({pos_4[0]:.2f}, {pos_4[1]:.2f})")            

            distance= Dist(pos_1, pos_2, pos_3, pos_4)
            print(f"Dist= {distance:.5f}")

            bs_hall = GetHall(b_small)
            bb_hall = GetHall(b_big)

            bs_i = GetMagnet(b_small)
            bb_i = GetMagnet(b_big)

            #save i, hall values and distance to file
            f= open(f"{b_small}_{b_big}_Distance_{timestring}.txt", "a+")
            f.write(f'{bs_i:.3f}\t{bb_i:.3f}\t{bs_hall:.7f}\t{bb_hall:.7f}\t{distance:.4f}\t{pos_1[0]:.4f}\t{all_nom_im}\n')
            f.close()

        #####################

        if (abs(bs_hall - bb_hall) > dHall):
            #if they are different, match again			
            matchHall()   
        else:
            print(f"Fields: {bs_hall:.6f}, {bb_hall:.6f}, dHall: {((bs_hall - bb_hall)/bs_hall*100):.5f}%")
Ejemplo n.º 4
0
def scanDipoles(b_small, b_big):

    #set number of steps (from previous experience scanning although might need adjustments)
    bs_stepsize = small_step
    bb_stepsize = big_step

    #initial nominal quad values
    q0_init, q1_init = GetMagnet(quad_pair[0]), GetMagnet(quad_pair[1])
    #q2_init = GetMagnet("q11")

    for i in range(total_steps):

        print(f"Step {i+1} out of {total_steps} large steps.")
        #get initial current of dipoles
        bs_init = GetMagnet(b_small)
        bb_init = GetMagnet(b_big)

        for j in range(0,
                       int(bb_stepsize / bs_stepsize) + extra_small_step
                       ):  ## ADDED TWO MORE STEPS FOR THE FIELDS TO OVERLAP

            #changing quads and taking pictures at 4 tunes
            #take picture with all at init values
            all_nom_im = SaveIm('allNom', viewer)

            #take picture with q11 nom, q12 7/6
            #            SetMagnet(quad_pair[0], q0_init)
            SetMagnet(quad_pair[0], 40)
            SetMagnet(quad_pair[1], q1_init)
            #SetMagnet("q11", q2_init)
            pos_1 = GetBeamPos(all_nom_im, viewer)
            sleep(
                5
            )  #might need to increase this if the jumps in current are big
            all_zero_im = SaveIm('Q11_40', viewer)

            #take picture with q11 8/10 and q12 nom
            SetMagnet(quad_pair[0], q0_init)
            #            SetMagnet(quad_pair[1], q1_init-17)
            SetMagnet(quad_pair[1], 20)
            #SetMagnet("q11", q2_init)
            pos_2 = GetBeamPos(all_zero_im, viewer)
            sleep(5)
            q0_half_im = SaveIm('Q13_20', viewer)

            #take picture with q11 *3/4, and q12 *11/12
            SetMagnet(quad_pair[0], 52)
            SetMagnet(quad_pair[1], 35)
            #SetMagnet("q11", 40)
            pos_3 = GetBeamPos(q0_half_im, viewer)
            sleep(5)
            q01_half_im = SaveIm('Q11_52_Q13_35', viewer)

            #return quads to original values
            SetMagnet(quad_pair[0], q0_init)
            SetMagnet(quad_pair[1], q1_init)
            #SetMagnet("q11", q2_init)

            pos_4 = GetBeamPos(q01_half_im, viewer)

            #peak/intensity
            #pk_1 = pos_1[2:]
            #pk_2 = pos_2[2:]
            #pk_3 = pos_3[2:]
            #pk_4 = pos_4[2:]
            #centroid positions
            pos_1 = pos_1[0:2]
            pos_2 = pos_2[0:2]
            pos_3 = pos_3[0:2]
            pos_4 = pos_4[0:2]

            #get quadratic distance from centroids
            print(
                f"Centroids:\n({pos_1[0]:.2f}, {pos_1[1]:.2f})\n({pos_2[0]:.2f}, {pos_2[1]:.2f})\n({pos_3[0]:.2f}, {pos_3[1]:.2f})\n({pos_4[0]:.2f}, {pos_4[1]:.2f})"
            )

            distance = Dist(pos_1, pos_2, pos_3, pos_4, True)[0]
            print(f"Dist= {distance:.5f}")

            bs_hall = GetHall(b_small)
            bb_hall = GetHall(b_big)

            bs_i = GetMagnet(b_small)
            bb_i = GetMagnet(b_big)

            #save i, hall values and distance to file
            f = open(f"{b_small}_{b_big}_Distance_{timestring}.txt", "a+")
            f.write(
                f'{bs_i:.3f}\t{bb_i:.3f}\t{bs_hall:.7f}\t{bb_hall:.7f}\t{distance:.4f}\t{pos_1[0]:.4f}\t{all_nom_im}\n'
            )
            f.close()
            #ramps down this magnet in small steps multiple of the large step
            SetMagnet(b_small, bs_init - bs_stepsize * (j + 1))

        #one magnet goes down 0.06 A, the other 0.02 A x 3
        #SetMagnet( b_big, bb_init - bb_stepsize)

        #####################

        #if (abs(bs_hall - bb_hall) > dHall):
        #if they are different, match again
        matchHall()
        #else:
        bs_hall = GetHall(b_small)
        bb_hall = GetHall(b_big)
        print(
            f"Fields: {bs_hall:.6f}, {bb_hall:.6f}, dHall: {((bs_hall - bb_hall)/bs_hall*100):.5f}%"
        )
Ejemplo n.º 5
0
def scanDipoles(b_small, b_big):

    #set number of steps (from previous experience scanning although might need adjustments)
    bs_stepsize = small_step
    bb_stepsize = big_step

    #initial nominal quad values
    q0_init, q1_init = GetMagnet(quad_pair[0]), GetMagnet(quad_pair[1])

    for i in range(total_steps):

        print(f"Step {i+1} out of {total_steps} large steps.")
        #get initial current of dipoles
        bs_init = GetMagnet(b_small)
        bb_init = GetMagnet(b_big)
        #SetMagnet( b_big, bb_init - bb_stepsize)
        SetMagnet(b_small, bs_init - bs_stepsize)

        #changing quads and taking pictures at 4 tunes
        #take picture with all at init values
        all_nom_im = SaveIm('allNom', viewer)

        #take picture with q14 nom, q15 *8/11
        SetMagnet(quad_pair[0], q0_init)
        SetMagnet(quad_pair[1], -15.000)
        pos_1 = GetBeamPos(all_nom_im, viewer)
        sleep(5)  #might need to increase this if the jumps in current are big
        all_zero_im = SaveIm('Q15_minus15', viewer)

        #take picture with q14 *1/2 and q15 nom
        SetMagnet(quad_pair[0], 15.000)
        SetMagnet(quad_pair[1], q1_init)
        pos_2 = GetBeamPos(all_zero_im, viewer)
        sleep(5)
        q0_half_im = SaveIm('Q14_15', viewer)

        #take picture with q14 zero, and q15 zero
        SetMagnet(quad_pair[0], 10.000)
        SetMagnet(quad_pair[1], -10.000)
        pos_3 = GetBeamPos(q0_half_im, viewer)
        sleep(5)
        q01_half_im = SaveIm('bothTen', viewer)

        #return quads to original values
        SetMagnet(quad_pair[0], q0_init)
        SetMagnet(quad_pair[1], q1_init)

        pos_4 = GetBeamPos(q01_half_im, viewer)

        #peak/intensity
        #pk_1 = pos_1[2:]
        #pk_2 = pos_2[2:]
        #pk_3 = pos_3[2:]
        #pk_4 = pos_4[2:]
        #centroid positions
        pos_1 = pos_1[0:2]
        pos_2 = pos_2[0:2]
        pos_3 = pos_3[0:2]
        pos_4 = pos_4[0:2]

        #get quadratic distance from centroids
        print(
            f"Centroids:\n({pos_1[0]:.2f}, {pos_1[1]:.2f})\n({pos_2[0]:.2f}, {pos_2[1]:.2f})\n({pos_3[0]:.2f}, {pos_3[1]:.2f})\n({pos_4[0]:.2f}, {pos_4[1]:.2f})"
        )

        distance = Dist(pos_1, pos_2, pos_3, pos_4, True)[0]
        print(f"Dist= {distance:.5f}")

        bs_hall = GetHall(b_small)
        bb_hall = GetHall(b_big)

        bs_i = GetMagnet(b_small)
        bb_i = GetMagnet(b_big)

        #save i, hall values and distance to file
        f = open(f"{b_small}_{b_big}_Distance_{timestring}.txt", "a+")
        f.write(
            f'{bs_i:.3f}\t{bb_i:.3f}\t{bs_hall:.7f}\t{bb_hall:.7f}\t{distance:.4f}\t{pos_1[0]:.4f}\t{all_nom_im}\n'
        )
        f.close()
Ejemplo n.º 6
0
    if (abs(b1_nmr - b2_nmr) >
            dNMR):  # changed b1_nmr_h to b1_nmr and similarly for b2_nmr_h
        matchNMR()
    else:
        print(
            f"Fields: {b1_nmr:.6f}, {b2_nmr:.6f}, dNMR: {((b1_nmr - b2_nmr)/b1_nmr*100):.5f}%"
        )

#compare current dist with previous, once I pass the min, stop, set back to Imin, cycle
    q1_init, q2_init, q3_init, q4_init = GetQuads()

    #Tuning Q3 and Q4
    #take picture with all at init values
    SetQuads(q1_init, q2_init, q3_init, q4_init)
    sleep(1)
    all_nom_im = SaveIm('allNom', viewer)

    #take picture with all at zero
    SetQuads(q1_init, q2_init, q3_init, -90)
    pos_1 = GetBeamPos(all_nom_im, viewer)
    sleep(5)  #might need to increase this if the jumps in current are big
    all_zero_im = SaveIm('Q4_neg90', viewer)

    #take picture with Q3 at half
    SetQuads(q1_init, q2_init, q3_init * 2 / 3, q4_init)
    pos_2 = GetBeamPos(all_zero_im, viewer)
    sleep(5)
    q3_half_im = SaveIm('q3_2-3', viewer)

    #take picture with Q2 at half
    SetQuads(q1_init, q2_init, q3_init, q4_init * 2 / 3)
Ejemplo n.º 7
0
magnet_values = [0 for i in range(len(magnet_list))]

while (cont == 'y'):
    if sandbox != 'y':

        #import current state
        #Get initial quad values
        #~ q1_init, q2_init, q3_init, q4_init= GetQuads()
        q6_init = GetMagnet('q6')
        q9_init = GetMagnet('q9')

        #Tuning Q8 and Q9
        #take picture with all at init values
        #~ SetQuads(q1_init, q2_init, 0, 0)
        #~ sleep(10)
        all_nom_im = SaveIm('allNom', viewer)
        sleep(2)

        #take picture with all at zero
        #~ SetQuads(0, 0, 0, 0)
        #~ SetMagnet('q8', 0)
        #~ SetMagnet('q9', 0)
        #~ pos_1= GetBeamPos(all_nom_im, viewer)
        #~ sleep(10) #might need to increase this if the jumps in current are big
        #~ all_zero_im= SaveIm('allZero', viewer)
        #~ sleep(2)

        #take picture with q8 2/3 and q9 nom
        #~ SetQuads(q1_init/2, q2_init/2, 0, 0)
        SetMagnet('q6', q6_init / 2)
        SetMagnet('q9', q9_init)
Ejemplo n.º 8
0
               {'name': 'v13', 'type': 'continuous', 'domain': (-5, 5)},  \
               {'name': 'h31', 'type': 'continuous', 'domain': (-10, 10)},\
               {'name': 'v31', 'type': 'continuous', 'domain': (-1, 5)}]
space = Design_space(spaceArray)

# Main optimizing loop
while (cont == 'y'):
	peak_found = True

	# Import current state by
	#  Gets current settings from control system
	q1_init, q2_init, q3_init, q4_init= GetQuads()

	# Take picture with all magnets at initial values
    # Take image of beam (this is image #1)
	all_nom_im= SaveIm('allNom', viewer)

	sleep(2) # wait for image to process

	# Take picture with all quadrupoles at zero
	SetQuads(0, 0, 0, 0)

    # Analyze image #1 and get positions and peak intensity
	pos_1= GetBeamPos(all_nom_im, viewer) # x and y positions
	pk_1 = pos_1[2:4]  # peak intensitites

	if pk_1[0] <int_limit:
        # No beam found at these settings
		peak_found = False
        # Set magnets to desired values
		SetQuads(q1_init, q2_init, q3_init, q4_init) 
Ejemplo n.º 9
0
def scanDipoles(b_small, b_big):

    #set number of steps (from previous experience scanning although might need adjustments)
    bs_stepsize = small_step
    bb_stepsize = big_step

    #initial nominal quad values
    q0_init, q1_init = GetMagnet(quad_pair[0]), GetMagnet(quad_pair[1])

    for i in range(total_steps):

        print(f"Step {i+1} out of {total_steps} large steps.")
        #get initial current of dipoles
        bs_init = GetMagnet(b_small)
        bb_init = GetMagnet(b_big)

        #set NMR teslameter to read B1 probe to save time later
        caput(set_probe, b1_probe)

        for j in range(0,
                       int(bb_stepsize / bs_stepsize) +
                       4):  ## ADDED TWO MORE STEPS FOR THE FIELDS TO OVERLAP

            #changing quads and taking pictures at 4 tunes
            #take picture with all at init values
            all_nom_im = SaveIm('allNom', viewer)

            #take picture with q8 nom, q9 half
            SetMagnet(quad_pair[0], q0_init * 2 / 3)
            SetMagnet(quad_pair[1], q1_init)
            pos_1 = GetBeamPos(all_nom_im, viewer)
            sleep(
                5
            )  #might need to increase this if the jumps in current are big
            all_zero_im = SaveIm('Q3_2-3', viewer)

            #take picture with q8/2 and q9/2
            SetMagnet(quad_pair[0], q0_init)
            SetMagnet(quad_pair[1], q1_init * 2 / 3)
            pos_2 = GetBeamPos(all_zero_im, viewer)
            sleep(5)
            q0_half_im = SaveIm('Q4_2-3', viewer)

            #take picture with 4/3 q8 and 5/4 q9
            SetMagnet(quad_pair[0], q0_init)
            SetMagnet(quad_pair[1], -90)
            pos_3 = GetBeamPos(q0_half_im, viewer)
            sleep(5)
            q01_half_im = SaveIm('Q4_neg90', viewer)

            #return quads to original values
            SetMagnet(quad_pair[0], q0_init)
            SetMagnet(quad_pair[1], q1_init)

            pos_4 = GetBeamPos(q01_half_im, viewer)

            #centroid positions
            pos_1 = pos_1[0:2]
            pos_2 = pos_2[0:2]
            pos_3 = pos_3[0:2]
            pos_4 = pos_4[0:2]

            #get quadratic distance from centroids
            print(
                f"Centroids:\n({pos_1[0]:.2f}, {pos_1[1]:.2f})\n({pos_2[0]:.2f}, {pos_2[1]:.2f})\n({pos_3[0]:.2f}, {pos_3[1]:.2f})\n({pos_4[0]:.2f}, {pos_4[1]:.2f})"
            )

            distance = Dist(pos_1, pos_2, pos_3, pos_4)
            print(f"Dist= {distance:.5f}")

            #get NMR fields
            if (b_small == 'b1'):
                #saving the new actual nmr value of B1
                bs_nmr = caget(tlm_reading)
                #change b2 and compare
                #saving the new actual nmr value
                caput(set_probe, b2_probe)
                sleep(10)
                bb_nmr = caget(tlm_reading)
            elif (b_small == 'b2'):
                #saving the new actual nmr value of B1
                bb_nmr = caget(tlm_reading)
                #change b2 and compare
                #saving the new actual nmr value
                caput(set_probe, b2_probe)
                sleep(10)
                bs_nmr = caget(tlm_reading)

            bs_i = GetMagnet(b_small)
            bb_i = GetMagnet(b_big)

            #save i, hall values and distance to file
            f = open(f"{b_small}_{b_big}_Distance_{timestring}.txt", "a+")
            f.write(
                f'{bs_i:.3f}\t{bb_i:.3f}\t{bs_nmr:.7f}\t{bb_nmr:.7f}\t{distance:.4f}\t{pos_1[0]:.4f}\t{all_nom_im}\n'
            )
            f.close()

            #ramps down this magnet in small steps multiple of the large step
            SetMagnet(b_small, bs_init - bs_stepsize * (j + 1))

        #this magnet goes down a big step
        SetMagnet(b_big, bb_init - bb_stepsize)

        #####################

        matchNMR()
Ejemplo n.º 10
0
            dNMR):  # changed b1_nmr_h to b1_nmr and similarly for b2_nmr_h
        matchNMR()
    else:
        print(
            f"Fields: {b1_nmr:.6f}, {b2_nmr:.6f}, dNMR: {((b1_nmr - b2_nmr)/b1_nmr*100):.5f}%"
        )

#compare current dist with previous, once I pass the min, stop, set back to Imin, cycle
    q1_init, q2_init, q3_init, q4_init = GetQuads()
    q5_init = GetMagnet('q5')

    #Tuning Q3 and Q4
    #take picture with all at init values
    SetQuads(q1_init, q2_init, q3_init, q4_init)
    sleep(1)
    all_nom_im = SaveIm('allNom', viewer)

    #take picture with all at zero
    SetQuads(q1_init, q2_init, 90, q4_init)
    pos_1 = GetBeamPos(all_nom_im, viewer)
    sleep(5)  #might need to increase this if the jumps in current are big
    q3_90_im = SaveIm('q3_90', viewer)

    #take picture with Q3 at half
    SetQuads(q1_init, q2_init, q3_init, -90)
    pos_2 = GetBeamPos(q3_90_im, viewer)
    sleep(5)
    q4_90_im = SaveIm('q4_90', viewer)

    #take picture with Q2 at half
    SetQuads(q1_init, q2_init, q3_init, q4_init)
Ejemplo n.º 11
0
#				'q4' : [-83.13, -72.716],
#				'q5' : [ 47.54,  55.68],
#				'q6' : [ 75.72,  76.18],
#				'q7' : [-26.81, -24.18]
#				}
			
			#print the phase space
			print(q_ps)			

			# Creating GP stuff
			# Domain is phase space for each corrector magnet in Amps!
			spaceArray = [ {'name': q, 'type': 'continuous', 'domain': (q_ps[q][0], q_ps[q][1])} for q in magnet_list ]
			space = Design_space(spaceArray)

			#take picture at init values
			init_im = SaveIm('init', viewer)
			sleep(2)

			#get initial beam spot width
			pos_init = GetBeamPos(init_im, viewer)

			#widths (+/- 34.13%)
			wid_init = (pos_init[5] - pos_init[4])
			gp_im = init_im
			#x_init = pos_init[0]
			x_init = 409 
			# CHANGED from x_init to 400 to refer to pos at nominal, below and when saving the file 
			x_gp = pos_init[0]
			wid_y= pos_init[7] - pos_init[6]
			wid_gp = wid_init 	
Ejemplo n.º 12
0
#timestamp = "06-09_20-24"
viewer = 'D1542'  #when optimizing through JENSA we always use this viewer

np.set_printoptions(precision=2)

while (count < 21):

    #import current state
    #Get initial quad values
    q1_init, q2_init, q3_init, q4_init = GetQuads()

    #Tuning Q1 and Q2
    #take picture with all at init values
    SetQuads(q1_init, q2_init, q3_init, q4_init)
    sleep(10)
    all_nom_im = SaveIm('allNom', viewer)
    sleep(2)

    #take picture with all at zero
    SetQuads(q1_init / 2, q2_init, q3_init, q4_init)
    pos_1 = GetBeamPos(all_nom_im, viewer)
    sleep(10)  #might need to increase this if the jumps in current are big
    q1_half_im = SaveIm('q1half', viewer)
    sleep(2)

    #take picture with Q1 at half # CHANGED.... Q2 also half
    SetQuads(q1_init, q2_init, q3_init / 2, q4_init)
    pos_2 = GetBeamPos(q1_half_im, viewer)
    sleep(10)
    q3_half_im = SaveIm('q3half', viewer)
    sleep(2)
Ejemplo n.º 13
0
while (cont == 'y'):
    if sandbox != 'y':

        #import current state
        #Get initial quad values
        q1_init, q2_init, q3_init, q4_init = GetQuads()

        q6_init = GetMagnet("q6")
        #q8_init = GetMagnet("q8")

        #Tuning Q1 and Q2
        #take picture with all at init values
        #SetQuads(q1_init, q2_init,  q3_init, q4_init)

        #~ sleep(10)
        all_nom_im = SaveIm('allNom', viewer)
        sleep(2)

        #take picture with all at zero
        #~ SetQuads(0, 0, 0, 0)
        #~ SetMagnet('q8', 0)
        #~ SetMagnet('q9', 0)
        #~ pos_1= GetBeamPos(all_nom_im, viewer)
        #~ sleep(10) #might need to increase this if the jumps in current are big
        #~ all_zero_im= SaveIm('allZero', viewer)
        #~ sleep(2)

        #take picture with q1 1/2 and q2 1/2
        SetQuads(q1_init, q2_init / 2, q3_init, q4_init)
        #~ SetMagnet('q1', q8_init*2/3)
        #SetMagnet('q1', -30.0)
Ejemplo n.º 14
0
#initial nominal quad values
q0_init, q1_init = GetMagnet(quad_pair[0]), GetMagnet(quad_pair[1])

while (cont == 'y'):
    if sandbox != 'y':

        #import current state
        #Get initial quad values
        #~ q1_init, q2_init, q3_init, q4_init= GetQuads()

        #Tuning Q1 and Q2
        #take picture with all at init values
        #~ SetQuads(q1_init, q2_init,  q3_init, q4_init)
        #~ sleep(10)
        all_nom_im = SaveIm('allNom', viewer)
        sleep(2)

        #take picture with q1 *1/2, q2 nom
        SetMagnet(quad_pair[0], q0_init / 2)
        SetMagnet(quad_pair[1], q1_init)
        pos_1 = GetBeamPos(all_nom_im, viewer)
        pk_1 = pos_1[2]  # CHANGED FROM 6 BY F. MONTES

        if (count_iter == 0):
            init_peak = pk_1

        if (count_iter > 0 and pk_1 < init_peak * 0.05):
            print("Beam off viewer. Skipping iteration.")
            distance = 1000
        else:
Ejemplo n.º 15
0
            q_ps = {
                q: [0.85 * q_init[q], 1.15 * q_init[q]]
                for q in magnet_list
            }

            # Creating GP stuff
            # Domain is phase space for each corrector magnet in Amps!
            spaceArray = [{
                'name': q,
                'type': 'continuous',
                'domain': (q_ps[q][0], q_ps[q][1])
            } for q in magnet_list]
            space = Design_space(spaceArray)

            #take picture at init values
            init_im = SaveIm('init', viewer)
            sleep(2)

            #get initial beam spot width
            pos_init = GetBeamPos(init_im, viewer)

            #widths (+/- 34.13%)
            wid_init = (pos_init[5] - pos_init[4])
            wid_gp = wid_init

        else:
            magnet_values = [random.uniform(-10, 10) for q in magnet_list]
            spaceArray = [{
                'name': q,
                'type': 'continuous',
                'domain': (-10, 10)
#initial nominal quad values
q0_init, q1_init = GetMagnet(quad_pair[0]), GetMagnet(quad_pair[1])

while (cont == 'y'):
    if sandbox != 'y':

        #import current state
        #Get initial quad values
        #~ q1_init, q2_init, q3_init, q4_init= GetQuads()

        #Tuning Q14 and Q15
        #take picture with all at init values
        #~ SetQuads(q1_init, q2_init,  q3_init, q4_init)
        sleep(3)
        all_nom_im = SaveIm('allNom', viewer)
        sleep(2)

        #take picture with q14 *2/3, q15 *9/10
        SetMagnet(quad_pair[0], -40)
        #SetMagnet(quad_pair[1], q1_init*9/10)
        pos_1 = GetBeamPos(all_nom_im, viewer)
        pk_1 = pos_1[2]

        if (count_iter == 0):
            init_peak = pk_1

        if (count_iter > 0 and pk_1 < init_peak * 0.05):
            print("Beam off viewer. Skipping iteration.")
            distance = 1000
        else:
Ejemplo n.º 17
0
magnet_values = [0 for i in range(len(magnet_list))]

while (cont == 'y'):
	if sandbox != 'y':

		#import current state
		#Get initial quad values
		#~ q1_init, q2_init, q3_init, q4_init= GetQuads()
		q8_init = GetMagnet('q8')
		q9_init = GetMagnet('q9')

		#Tuning Q8 and Q9
		#take picture with all at init values
		#~ SetQuads(q1_init, q2_init, 0, 0)
		#~ sleep(10)
		all_nom_im= SaveIm('allNom', viewer)
		sleep(2)

		#take picture with all at zero
		#~ SetQuads(0, 0, 0, 0)
		#~ SetMagnet('q8', 0)
		#~ SetMagnet('q9', 0)
		#~ pos_1= GetBeamPos(all_nom_im, viewer)
		#~ sleep(10) #might need to increase this if the jumps in current are big
		#~ all_zero_im= SaveIm('allZero', viewer)
		#~ sleep(2)

		#take picture with q8 2/3 and q9 nom
		#~ SetQuads(q1_init/2, q2_init/2, 0, 0)
		SetMagnet('q8', q8_init*2/3)
		SetMagnet('q9', q9_init)