def func7(): while True: time.sleep(1) poscalc = intersection(utrackr.x, utrackr.y, utrackr2.x, utrackr2.y, utrackr3.x, utrackr3.y) x, y, z = poscalc.position_calculation() print utrackr.timesync.getTimeStamp() + " x: " + str(x) + " y: " + str( y) + " z: " + str(z)
def test_intersection(self): TEST_DATA = [ ("1", "1", ""), ("1", "1", "2"), ("12", "12", "345"), ("12", "1234", "567"), ("12345", "12", "678"), ("efh298fh", "efdweufh", "efuh398fh")] for test in TEST_DATA: l1 = LinkedList(test[0]) l2 = LinkedList(test[1]) intersection_node = create_intersection(l1, l2, LinkedList(test[2])) self.assertEquals(intersection(l1, l2), intersection_node)
def no_intersection(): LL = LinkedList() LL2 = LinkedList() LL.head = Node(1) LL.head.next = Node(7) LL.head.next.next = Node(5) LL.head.next.next.next = Node(4) LL2.head = Node(1) LL2.head.next = Node(7) LL2.head.next.next = Node(5) LL2.head.next.next.next = Node(4) assert None == intersection(LL, LL2)
def intersection(): title = 'Intersection' answer = '0' function1 = request.query.function1 function2 = request.query.function2 function1 = function1.encode('utf8') function2 = function2.encode('utf8') if function1 and function2 != '': answer = inter.intersection(function1, function2) else: answer = 'Please fill in all fields.' return template('intersectionPage.tpl', title=title, answer=answer)
def test_diff_len_intersection(): LL = LinkedList() LL2 = LinkedList() node = Node(4) node2 = Node(5) LL.head = Node(1) LL.head.next = node LL.head.next.next = node2 LL2.head = Node(10) LL2.head.next = Node(11) LL2.head.next.next = node LL2.head.next.next.next = node2 assert node == intersection(LL, LL2)
def __init__(self, time_factor, event_output, smart_lights, smart_cars, sim_time): self.s = sched.scheduler(time.time, time.sleep) ##################################################################### # INITIALIZE SIMULATION PROPERTIES ##################################################################### self.event_output = event_output self.time_factor = time_factor self.smart_lights = smart_lights self.smart_cars = smart_cars self.sim_time = sim_time self.auto_cycle_counter = 0 ##################################################################### # NORTH AVE / LUCKIE ST COMPONENTS ##################################################################### NAVE_LUCKIE_N_DEP_DISTS = [[1, 0, 0], [0, .5, 1]] NAVE_LUCKIE_N_LANES = [ lane(NAVE_LUCKIE_N_DEP_DISTS[0], self.smart_cars), lane(NAVE_LUCKIE_N_DEP_DISTS[1], self.smart_cars) ] NAVE_LUCKIE_N_ARR_DIST = [4, 1, [.5, .5]] NAVE_LUCKIE_E_DEP_DISTS = [[0, 1, 0], [0, .9, 1]] NAVE_LUCKIE_E_LANES = [ lane(NAVE_LUCKIE_E_DEP_DISTS[0], self.smart_cars), lane(NAVE_LUCKIE_E_DEP_DISTS[1], self.smart_cars) ] NAVE_LUCKIE_E_ARR_DIST = [0, 0, [.4, .6]] NAVE_LUCKIE_S_DEP_DISTS = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] NAVE_LUCKIE_S_LANES = [ lane(NAVE_LUCKIE_S_DEP_DISTS[0], self.smart_cars), lane(NAVE_LUCKIE_S_DEP_DISTS[1], self.smart_cars), lane(NAVE_LUCKIE_S_DEP_DISTS[2], self.smart_cars) ] NAVE_LUCKIE_S_ARR_DIST = [4, 1, [.33, .33, .33]] NAVE_LUCKIE_W_DEP_DISTS = [[1, 0, 0], [0, 1, 0], [0, .7, 1]] NAVE_LUCKIE_W_LANES = [ lane(NAVE_LUCKIE_W_DEP_DISTS[0], self.smart_cars), lane(NAVE_LUCKIE_W_DEP_DISTS[1], self.smart_cars), lane(NAVE_LUCKIE_W_DEP_DISTS[2], self.smart_cars) ] NAVE_LUCKIE_W_ARR_DIST = [18, 2, [.2, .4, .4]] NAVE_LUCKIE_N = side("North/Luckie N", NAVE_LUCKIE_N_LANES, NAVE_LUCKIE_N_ARR_DIST, True, self.smart_cars) NAVE_LUCKIE_E = side("North/Luckie E", NAVE_LUCKIE_E_LANES, NAVE_LUCKIE_E_ARR_DIST, False, self.smart_cars) NAVE_LUCKIE_S = side("North/Luckie S", NAVE_LUCKIE_S_LANES, NAVE_LUCKIE_S_ARR_DIST, True, self.smart_cars) NAVE_LUCKIE_W = side("North/Luckie W", NAVE_LUCKIE_W_LANES, NAVE_LUCKIE_W_ARR_DIST, True, self.smart_cars) if smart_lights == True: NAVE_LUCKIE_PHASES = [ phase([NAVE_LUCKIE_S], [[0, 1, 2]], 10), #luckie green and arrow #luckie green and tech pkwy green phase([NAVE_LUCKIE_S, NAVE_LUCKIE_N], [[1, 2], [1]], 10), #tech pkwy green and arrow phase([NAVE_LUCKIE_N], [[0, 1]], 10), #nave west green and arrow phase([NAVE_LUCKIE_W], [[0, 1, 2]], 20), #nave west green and nave east green phase([NAVE_LUCKIE_W, NAVE_LUCKIE_E], [[1, 2], [0, 1]], 75) ] else: NAVE_LUCKIE_PHASES = [ phase([NAVE_LUCKIE_S], [[0, 1, 2]], 15), #luckie green and arrow #luckie green and tech pkwy green phase([NAVE_LUCKIE_S, NAVE_LUCKIE_N], [[1, 2], [1]], 15), #tech pkwy green and arrow phase([NAVE_LUCKIE_N], [[0, 1]], 15), #nave west green and arrow phase([NAVE_LUCKIE_W], [[0, 1, 2]], 10), #nave west green and nave east green phase([NAVE_LUCKIE_W, NAVE_LUCKIE_E], [[1, 2], [0, 1]], 65) ] ##################################################################### # NORTH AVE / TECHWOOD COMPONENTS ##################################################################### NAVE_TECHWOOD_N_DEP_DISTS = [[1, 0, 0], [0, .7, 1]] NAVE_TECHWOOD_N_LANES = [ lane(NAVE_TECHWOOD_N_DEP_DISTS[0], self.smart_cars), lane(NAVE_TECHWOOD_N_DEP_DISTS[1], self.smart_cars) ] NAVE_TECHWOOD_N_ARR_DIST = [5, 1, [.5, .5]] NAVE_TECHWOOD_E_DEP_DISTS = [[1, 0, 0], [0, 1, 0], [0, .8, 1]] NAVE_TECHWOOD_E_LANES = [ lane(NAVE_TECHWOOD_E_DEP_DISTS[0], self.smart_cars), lane(NAVE_TECHWOOD_E_DEP_DISTS[1], self.smart_cars), lane(NAVE_TECHWOOD_E_DEP_DISTS[2], self.smart_cars) ] NAVE_TECHWOOD_E_ARR_DIST = [0, 0, [.2, .4, .4]] NAVE_TECHWOOD_S_DEP_DISTS = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] NAVE_TECHWOOD_S_LANES = [ lane(NAVE_TECHWOOD_S_DEP_DISTS[0], self.smart_cars), lane(NAVE_TECHWOOD_S_DEP_DISTS[1], self.smart_cars), lane(NAVE_TECHWOOD_S_DEP_DISTS[2], self.smart_cars) ] NAVE_TECHWOOD_S_ARR_DIST = [2, 1, [.3, .2, .5]] NAVE_TECHWOOD_W_DEP_DISTS = [[1, 0, 0], [0, 1, 0], [0, .7, 1]] NAVE_TECHWOOD_W_LANES = [ lane(NAVE_TECHWOOD_W_DEP_DISTS[0], self.smart_cars), lane(NAVE_TECHWOOD_W_DEP_DISTS[1], self.smart_cars), lane(NAVE_TECHWOOD_W_DEP_DISTS[2], self.smart_cars) ] NAVE_TECHWOOD_W_ARR_DIST = [0, 0, [.2, .4, .4]] NAVE_TECHWOOD_N = side("North/Techwood N", NAVE_TECHWOOD_N_LANES, NAVE_TECHWOOD_N_ARR_DIST, True, self.smart_cars) NAVE_TECHWOOD_E = side("North/Techwood E", NAVE_TECHWOOD_E_LANES, NAVE_TECHWOOD_E_ARR_DIST, False, self.smart_cars) NAVE_TECHWOOD_S = side("North/Techwood S", NAVE_TECHWOOD_S_LANES, NAVE_TECHWOOD_S_ARR_DIST, True, self.smart_cars) NAVE_TECHWOOD_W = side("North/Techwood W", NAVE_TECHWOOD_W_LANES, NAVE_TECHWOOD_W_ARR_DIST, False, self.smart_cars) NAVE_TECHWOOD_PHASES = [ phase([NAVE_TECHWOOD_S], [[0, 1, 2]], 10), #techwood South arrow and green #techwood S and Techwood N green phase([NAVE_TECHWOOD_S, NAVE_TECHWOOD_N], [[1, 2], [1]], 20), #techwood N green and arrow phase([NAVE_TECHWOOD_N], [[0, 1]], 10), #Nave W green and arrow phase([NAVE_TECHWOOD_W], [[0, 1, 2]], 10), #Nav W and Nave E Green phase([NAVE_TECHWOOD_W, NAVE_TECHWOOD_E], [[1, 2], [1, 2]], 60), #Nave E green and arrow phase([NAVE_TECHWOOD_E], [[0, 1, 2]], 10) ] NAVE_TECHWOOD_N = side("North/Techwood N", NAVE_TECHWOOD_N_LANES, NAVE_TECHWOOD_N_ARR_DIST, True, self.smart_cars) NAVE_TECHWOOD_E = side("North/Techwood E", NAVE_TECHWOOD_E_LANES, NAVE_TECHWOOD_E_ARR_DIST, False, self.smart_cars) NAVE_TECHWOOD_S = side("North/Techwood S", NAVE_TECHWOOD_S_LANES, NAVE_TECHWOOD_S_ARR_DIST, True, self.smart_cars) NAVE_TECHWOOD_W = side("North/Techwood W", NAVE_TECHWOOD_W_LANES, NAVE_TECHWOOD_W_ARR_DIST, False, self.smart_cars) if smart_lights == True: NAVE_TECHWOOD_PHASES = [ phase([NAVE_TECHWOOD_S], [[0, 1, 2]], 5), #techwood South arrow and green #techwood S and Techwood N green phase([NAVE_TECHWOOD_S, NAVE_TECHWOOD_N], [[1, 2], [1]], 10), #techwood N green and arrow phase([NAVE_TECHWOOD_N], [[0, 1]], 5), #Nave W green and arrow phase([NAVE_TECHWOOD_W], [[0, 1, 2]], 15), #Nav W and Nave E Green phase([NAVE_TECHWOOD_W, NAVE_TECHWOOD_E], [[1, 2], [1, 2]], 70), #Nave E green and arrow phase([NAVE_TECHWOOD_E], [[0, 1, 2]], 15) ] else: NAVE_TECHWOOD_PHASES = [ phase([NAVE_TECHWOOD_S], [[0, 1, 2]], 10), #techwood South arrow and green #techwood S and Techwood N green phase([NAVE_TECHWOOD_S, NAVE_TECHWOOD_N], [[1, 2], [1]], 20), #techwood N green and arrow phase([NAVE_TECHWOOD_N], [[0, 1]], 10), #Nave W green and arrow phase([NAVE_TECHWOOD_W], [[0, 1, 2]], 10), #Nav W and Nave E Green phase([NAVE_TECHWOOD_W, NAVE_TECHWOOD_E], [[1, 2], [1, 2]], 60), #Nave E green and arrow phase([NAVE_TECHWOOD_E], [[0, 1, 2]], 10) ] ##################################################################### # OFFRAMP COMPONENTS ##################################################################### OFFRAMP_249_DEP_DISTS = [[1, 0, 0], [0.5, 0, 1]] OFFRAMP_249_LANES = [ lane(OFFRAMP_249_DEP_DISTS[0], self.smart_cars), lane(OFFRAMP_249_DEP_DISTS[1], self.smart_cars) ] OFFRAMP_249_ARR_DIST = [6, 1, [0.5, 0.5]] OFFRAMP_WEST_DEP_DIST = [[0, 1, 0], [0, 1, 0]] OFFRAMP_WEST_LANES = [ lane(OFFRAMP_WEST_DEP_DIST[0], self.smart_cars), lane(OFFRAMP_WEST_DEP_DIST[1], self.smart_cars) ] OFFRAMP_WEST_ARR_DIST = [0, 0, [0.5, 0.5]] OFFRAMP_EAST_DEP_DIST = [[0, 1, 0], [0, 1, 0]] OFFRAMP_EAST_LANES = [ lane(OFFRAMP_EAST_DEP_DIST[0], self.smart_cars), lane(OFFRAMP_EAST_DEP_DIST[1], self.smart_cars) ] OFFRAMP_EAST_ARR_DIST = [16, 2, [0.5, 0.5]] OFFRAMP_249 = side("Offramp 249", OFFRAMP_249_LANES, OFFRAMP_249_ARR_DIST, True, self.smart_cars) OFFRAMP_WEST = side("Offramp West", OFFRAMP_WEST_LANES, OFFRAMP_WEST_ARR_DIST, False, self.smart_cars) OFFRAMP_EAST = side("Offramp East", OFFRAMP_EAST_LANES, OFFRAMP_EAST_ARR_DIST, True, self.smart_cars) if smart_lights == True: OFFRAMP_PHASES = [ phase([OFFRAMP_WEST, OFFRAMP_EAST], [[0, 1], [0, 1]], 60), #Nave e and Nave w green light #off-ramp green lights phase([OFFRAMP_249], [[0, 1]], 15) ] else: OFFRAMP_PHASES = [ phase([OFFRAMP_WEST, OFFRAMP_EAST], [[0, 1], [0, 1]], 40), #Nave e and Nave w green light #off-ramp green lights phase([OFFRAMP_249], [[0, 1]], 20) ] ##################################################################### # INTERSECTION OBJECTS ##################################################################### nave_luckie = intersection( self.s, "North/Luckie", [NAVE_LUCKIE_N, NAVE_LUCKIE_E, NAVE_LUCKIE_S, NAVE_LUCKIE_W], NAVE_LUCKIE_PHASES) nave_techwood = intersection(self.s, "North/Techwood", [ NAVE_TECHWOOD_N, NAVE_TECHWOOD_E, NAVE_TECHWOOD_S, NAVE_TECHWOOD_W ], NAVE_TECHWOOD_PHASES) offramp = intersection(self.s, "Offramp", [OFFRAMP_249, OFFRAMP_EAST, OFFRAMP_WEST], OFFRAMP_PHASES) # interconnect them by setting destinations nave_luckie.sides[0].set_dests([nave_techwood.sides[3], None, None]) nave_luckie.sides[2].set_dests([None, None, nave_techwood.sides[3]]) nave_luckie.sides[3].set_dests([None, nave_techwood.sides[3], None]) nave_techwood.sides[0].set_dests( [offramp.sides[2], None, nave_luckie.sides[1]]) nave_techwood.sides[1].set_dests([None, nave_luckie.sides[1], None]) nave_techwood.sides[2].set_dests( [nave_luckie.sides[1], None, offramp.sides[2]]) nave_techwood.sides[3].set_dests([None, offramp.sides[2], None]) offramp.sides[0].set_dests([None, None, nave_techwood.sides[1]]) offramp.sides[1].set_dests([None, nave_techwood.sides[1], None]) offramp.sides[2].set_dests([None, None, None]) intersections = [nave_luckie, nave_techwood, offramp] self.intersections = intersections
) sys.exit(1) input_path = sys.argv[1] output_path = sys.argv[2] print("Begin Entity Resolution") start_time = time.localtime() read_all(input_path) index_brand() index_model() filtering( ) # Filter on each brand separately, mainly delete useless model names build_reverse_index() multiple_model() intersection() collect_remain() resolve_others() merge_same() split_brand() #model_index_to_file('./model') # 解注释可以打印到文件 solve(output_path) #os.system("python ./judge/judge.py "+output_path) print("Start time: ", end=" ") print(time.strftime("%H:%M:%S", start_time))
import numpy as np import matplotlib.pyplot as plt from coeffs import * import intersection as INT n1=np.array([4,3]) n2=np.array([3,4]) c1=12 c2=12 O=INT.intersection(n1,n2,c1,c2) print(O) len=1001 y1=np.zeros((2,len)) y1[0]=np.linspace(6/7-25,6/7,len) y1[1]=((36/49)/(y1[0]-6/7))+6/7 len=1001 y2=np.zeros((2,len)) y2[0]=np.linspace(6/7,6/7+25,len) y2[1]=((36/49)/(y2[0]-6/7))+6/7 plt.plot(y1[0,:],y1[1,:],color='r') plt.plot(y2[0,:],y2[1,:],color='r') plt.grid() plt.axis('equal') plt.show()
for t2 in np.arange(5, 15, 5): for t1 in np.arange(0, 2.5, 0.5): for plotter in [plt.plot, plt.semilogy]: bvs = [] for f in glob.glob('data/Breakdown [%s_%.1f_%d*.csv' % (dev, t1, t2)): # Read data data = csv.reader(open(f)) iv = map( lambda entry: (float(entry[1]), float(entry[2])), filter(lambda entry: entry[0] == 'DataValue', data)) vvals, ivals = zip(*iv) # Compute breakdown voltage based on 1mA threshold bv = intersection(np.array(vvals), np.array(ivals), np.array([0, 50]), np.array([1e-3, 1e-3])) bvs.append(bv[0][0]) # Set the font dictionaries (for plot title and axis titles) title_font = { 'fontname': 'Arial', 'size': '16', 'color': 'black', 'weight': 'bold', 'verticalalignment': 'bottom' } axis_font = {'fontname': 'Arial', 'size': '12'} # Plot data plt.title('MOSCAP Breakdown I-V %s_%.1f_%d' %
from intersection import intersection poscalc = intersection(388, 184, 336, 286, 240, 190) x, y, z = poscalc.position_calculation() print "x: " + str(x) + " y: " + str(y) + " z: " + str(z)
def vertexandedge(out): Vertex = {} Edge = [] streets = out['S'] street = {} for street_idx in streets: street[street_idx] = streets[street_idx][:] Edge_set = set() Vertex_set = set() compute = [] for street_key_1 in street: for street_key_2 in street: if (street_key_1 != street_key_2 and set([street_key_1, street_key_2]) not in compute): compute.append(set([street_key_1, street_key_2])) p = 0 q = 0 while (p < len(street[street_key_1]) - 1): while (q < len(street[street_key_2]) - 1): intersect = intersection(street[street_key_1][p], street[street_key_1][p + 1], street[street_key_2][q], street[street_key_2][q + 1]) if (intersect != 0 and intersect != "equal"): Vertex_set.update([ street[street_key_1][p], street[street_key_1][p + 1], street[street_key_2][q], street[street_key_2][q + 1], intersect ]) if (intersect not in street[street_key_1] and intersect not in street[street_key_2]): Edge_set.update([ (street[street_key_1][p], intersect), (intersect, street[street_key_1][p + 1]), (street[street_key_2][q], intersect), (intersect, street[street_key_2][q + 1]) ]) if ((street[street_key_1][p], street[street_key_1][p + 1]) in Edge_set): Edge_set.remove( (street[street_key_1][p], street[street_key_1][p + 1])) if ((street[street_key_2][q], street[street_key_2][q + 1]) in Edge_set): Edge_set.remove( (street[street_key_2][q], street[street_key_2][q + 1])) street[street_key_1].insert(p + 1, intersect) street[street_key_2].insert(q + 1, intersect) q = q + 1 elif (intersect in street[street_key_1] and intersect not in street[street_key_2]): Edge_set.update([ (street[street_key_2][q], intersect), (intersect, street[street_key_2][q + 1]) ]) if ((street[street_key_2][q], street[street_key_2][q + 1]) in Edge_set): Edge_set.remove( (street[street_key_2][q], street[street_key_2][q + 1])) street[street_key_2].insert(q + 1, intersect) q = q + 1 elif (intersect in street[street_key_2] and intersect not in street[street_key_1]): Edge_set.update([ (street[street_key_1][p], intersect), (intersect, street[street_key_1][p + 1]) ]) if ((street[street_key_1][p], street[street_key_1][p + 1]) in Edge_set): Edge_set.remove( (street[street_key_1][p], street[street_key_1][p + 1])) street[street_key_1].insert(p + 1, intersect) q = q + 1 elif (intersect in street[street_key_1] and intersect in street[street_key_2]): Edge_set.update([(street[street_key_1][p], street[street_key_1][p + 1]), (street[street_key_2][q], street[street_key_2][q + 1]) ]) q = q + 1 q = 0 p = p + 1 Vertex_data_1 = list(Vertex_set) cnt = 0 for Vertex_mem in Vertex_data_1: cnt = cnt + 1 Vertex[cnt] = Vertex_mem Edge_data = list(Edge_set) Edge = [] for Edge_mem in Edge_data: for Vertex_idx in Vertex: if (Edge_mem[0] == Vertex[Vertex_idx]): a1 = Vertex_idx if (Edge_mem[1] == Vertex[Vertex_idx]): a2 = Vertex_idx Edge.append((a1, a2)) out['V'] = Vertex out['E'] = Edge return out
def test_edgecases(inputs, expected): results = intersection(*inputs) assert results == expected
# -*- coding: utf-8 -*- import intersection # First point Xa_519 = 26242.67 Ya_519 = 11314.51 # Second Point Xb_519 = 25318.11 Yb_519 = 12450.24 # Mesaurements alpha_519 = 38.4325 beta_519 = 73.4894 Yp_519, Xp_519 = intersection.intersection(Xa_519, Ya_519, Xb_519, Yb_519, alpha_519, beta_519, 'left') print("Yp:", format(Yp_519, ".2f"), "m") print("Xp:", format(Xp_519, ".2f"), "m")
def test(self): self.assertEqual(intersection([1, 2, 3, 4, 5], [0, 2, 4]), [2, 4])
V=np.vstack([[25,0],[0,9]]) c=225 P=np.array([1.5,2.5*np.sqrt(3)]) O=np.array([0,0]) n1=P@V e=np.sqrt(1-(a**2/b**2)) F1=np.array([0,b*e]) F2=np.array([0,-b*e]) n2=omat@n1 c1=n2@F1 c2=n2@F2 A1=INT.intersection(n1,n2,c,c1) A2=INT.intersection(n1,n2,c,c2) d1=np.linalg.norm(A1-F1) d2=np.linalg.norm(A2-F2) S=d1*d2 print(S) len=1000 theta=np.linspace(0,2*np.pi,len) ell=np.zeros((2,len)) ell[0,:]=a*np.cos(theta) ell[1,:]=b*np.sin(theta) ell=(ell.T+O).T
print('\nat time 3.3:') print('slope = ' + str(round(slope(statue[0], statue[1], 3.3), 2))) print('f\' = ' + str(round(f_prime(3.3), 2))) print('\nat time 3.4:') print('slope = ' + str(round(slope(statue[0], statue[1], 3.4), 2))) print('f\' = ' + str(round(f_prime(3.4), 2))) print('\n') x = np.linspace(-0.5, 5) print(x) # x,y=intersection(x1,y1,x2,y2) a, b = intersection(x, slope(statue[0], statue[1], x), x, f_prime(x)) a = np.delete(a, 2) b = np.delete(b, 2) plt.plot(x, f(x), label='f(x)') plt.plot(x, f_prime(x), label='f\'(x)') plt.plot(x, slope(7.5, 4, x), label='slope between f(x) and statue') plt.plot(a, b, "*k") plt.plot(statue[1], statue[0], "or") plt.plot(a, f(a), ".k") for i in range(len(a)): plt.text(a[i], f(a[i]), '(' + str(round(a[i], 1)) + ',' + str(round(f(a[i]), 1)) + ')', verticalalignment='bottom') plt.ylim(top=20)
def int_diagram(h_=0.35, b_=1.0, d_1=0.03, d_2=0.03, gamma_c=1.50, gamma_s=1.15, gamma_d=1.35, a_s1=5, a_s2=5, f_ck=40, f_yk=500, alpha_cc=1.00, eccentricity=False): # epsilon values of the steel and the concrete # a. steel strains tension side epsilon_s1 = np.array([ -0.003499, -0.0032, -0.0029, -0.0026, -0.0023, -0.002, -0.0017, -0.0014, -0.0011, -0.0008, -0.0005, -0.0002, 0.0, 0.0004, 0.0007, 0.001, 0.0013, 0.0016, 0.0019, 0.0022, 0.0025, 0.0028, 0.0031, 0.0034, 0.0037, 0.004, 0.0043, 0.0049, 0.0052, 0.0055, 0.006, 0.0065, 0.007, 0.0075, 0.008, 0.009, 0.0095, 0.01, 0.011, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012, 0.012 ]) # b. concrete strains compression side epsilon_c = np.array([ -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0035, -0.0032, -0.0029, -0.0026, -0.0023, -0.002, -0.0017, -0.0014, -0.0011, -0.0008, -0.0005, -0.0002, 0.0 ]) e_steel = 200000 # N/mm2 try: alpha = a_s1 / a_s2 except ZeroDivisionError: # in case a_s2 defined as zero alpha = 0 if alpha_cc < 0.85: # alpha_cc cannot be smaller than 0.85 alpha_cc = 0.85 f_cd = f_ck / gamma_c * alpha_cc f_yd = f_yk / gamma_s d = h_ - d_1 a_s1_ = 0 # indicating naked concrete interaction line alpha_ = 1 # again for naked concrete interaction line min_ecc = min(h_ / 30, 0.02) # min eccentricity as defined in EN1992-1 6.1(4) n_max = f_ck * b_ * d m_min = min_ecc * n_max # mapping the epsilon values as pandas data frame df = pd.DataFrame({'eps_c': epsilon_c, 'eps_s1': epsilon_s1}) # iterating for every epsilon value pair moment = [] n_force = [] moment_reinf = [] n_force_reinf = [] for i in range(len(df.eps_c)): # calling eps_c and eps_s1 from now on as y and x x = df.eps_s1[i] y = df.eps_c[i] if d <= 0 or a_s1 < 0 or a_s2 < 0 or b_ <= 0 or gamma_c < 0 or \ gamma_d < 0 or gamma_s < 0 or d_1 < 0 or d_2 < 0 or alpha_cc <= 0: # parameter problems returns NoneType return # calling for rectangular part if (-0.002 - y) * d / (x - y) > 0: xi1 = min((-0.002 - y) * d / (x - y), h_) else: xi1 = 0 # compression zone height xi2 = min((-y * d) / (x - y), h_) # factor (Hilfswert) h_w = (y - x) / d # compression force of concrete f_c = f_cd * b_ * \ (-xi1 + (xi2 - xi1) * (1000 * y + 250000 * y ** 2) - (xi2 ** 2 - xi1 ** 2) * (500 * h_w + 250000 * h_w * y) + (xi2 ** 3 - xi1 ** 3) * 250000 * h_w ** 2 / 3) # moment concrete m_c = f_cd * b_ * (-0.5 * xi1**2 + 0.5 * (1000 * y + 250000 * y**2) * (xi2**2 - xi1**2) - (1000 + 500000 * y) * h_w / 3 * (xi2**3 - xi1**3) + 62500 * h_w**2 * (xi2**4 - xi1**4)) # eccentricity concrete (avoid division by zero) if m_c == 0 or f_c == 0: e_ausm = h_ / 2 else: e_ausm = h_ / 2 - m_c / f_c # steel strain on the compression side eps_s2 = y - (y - x) / d * d_2 # compression force steel f_s2 = (math.copysign(1, eps_s2) * min( (e_steel * abs(eps_s2)), f_yd) * alpha_ * a_s1_ / 1000) # tension force steel f_s1 = math.copysign(1, x) * min( (e_steel * abs(x)), f_yd) * a_s1_ / 1000 # moment m_r = f_s1 * (h_ / 2 - d_1) - f_s2 * (h_ / 2 - d_2) - f_c * e_ausm # normal force n_r = f_s2 + f_s1 + f_c # m und n for pure concrete moment.append(m_r) n_force.append(n_r) # compression force steel (reinforcement) f_s2_reinf = math.copysign(1, eps_s2) * \ min((e_steel * abs(eps_s2)), f_yd) * alpha * a_s1 / 10000 # tension force steel (reinforcement) f_s1_reinf = math.copysign(1, x) * \ min((e_steel * abs(x)), f_yd) * a_s1 / 10000 # moment (reinforcement) m_r_reinf = (f_s1_reinf * (h_ / 2 - d_1) - f_s2_reinf * (h_ / 2 - d_2) - f_c * e_ausm) # normal force (reinforcement) n_r_reinf = f_s2_reinf + f_s1_reinf + f_c # m und n (reinforcement) moment_reinf.append(m_r_reinf) n_force_reinf.append(n_r_reinf) moment_neg = [] # left side of the diagram (concrete) for i in range(len(moment)): moment_neg.append(float(abs(moment[i]) * -1)) moment_reinf_neg = [] # left side of the diagram (with reinforcement) for i in range(len(moment_reinf)): moment_reinf_neg.append(float(abs(moment_reinf[i]) * -1)) if eccentricity: # if user wants to visualize the eccentricity line limit_line_pos_m = [m_min, m_min] limit_line_neg_m = [-m_min, -m_min] limit_line_n = [0, -n_max] if a_s1 == 0 and a_s2 == 0: # no reinforcements x1, y1 = inter.intersection(np.array(limit_line_neg_m), np.array(limit_line_n), np.array(moment_neg), np.array(n_force)) x2, y2 = inter.intersection(np.array(limit_line_pos_m), np.array(limit_line_n), np.array(moment), np.array(n_force)) elif a_s1 != 0: x1, y1 = inter.intersection(np.array(limit_line_neg_m), np.array(limit_line_n), np.array(moment_reinf_neg), np.array(n_force_reinf)) if a_s2 == 0: # only a_s1 defined x2, y2 = inter.intersection(np.array(limit_line_pos_m), np.array(limit_line_n), np.array(moment), np.array(n_force)) else: # both of them defined x2, y2 = inter.intersection(np.array(limit_line_pos_m), np.array(limit_line_n), np.array(moment_reinf), np.array(n_force_reinf)) elif a_s2 != 0 and a_s1 == 0: x1, y1 = inter.intersection(np.array(limit_line_pos_m), np.array(limit_line_n), np.array(moment), np.array(n_force)) x2, y2 = inter.intersection(np.array(limit_line_pos_m), np.array(limit_line_n), np.array(moment_reinf), np.array(n_force_reinf)) else: raise Exception('Cannot calculate eccentricity') input_values = { 'h': h_, 'b': b_, 'd_1': d_1, 'd_2': d_2, 'gamma_c': gamma_c, 'gamma_s': gamma_s, 'gamma_d': gamma_d, 'a_s1': a_s1, 'a_s2': a_s2, 'f_ck': f_ck, 'f_yk': f_yk, 'alpha_cc': alpha_cc, 'eccentricity': eccentricity } if eccentricity: values = { 'Moment': moment, 'Moment Neg': moment_neg, 'Normal Force': n_force, 'Moment Reinf': moment_reinf, 'Moment Reinf Neg': moment_reinf_neg, 'Normal Force Reinf': n_force_reinf, 'x1_y1': [x1, y1], 'x2_y2': [x2, y2] } else: values = { 'Moment': moment, 'Moment Neg': moment_neg, 'Normal Force': n_force, 'Moment Reinf': moment_reinf, 'Moment Reinf Neg': moment_reinf_neg, 'Normal Force Reinf': n_force_reinf } return input_values, values
def process(): # create empty matrix with size 600x400 card = np.zeros((400, 600)) # for each folder in folder people path = "./people" folders = os.listdir(path) for folder in folders: if "ciphered" in folder: continue person_path = path + "/" + folder files = os.listdir(person_path) files = sorted(files) # img_1 receives frst image img_1 = resources.load_img(person_path + "/" + files[0]) img_1 = resources.img_to_binary_img(img_1) parser = cipher.get_parser() args = parser.parse_args( ['-f', person_path + "/" + files[0], '-p', '1']) base, complement = cipher.execute(args, parser) amplified_base = amplify.amplify(base, 2) amplified_complement = amplify.amplify(complement, 2) summed = amplified_complement + amplified_base summed[summed == 255] = 0 summed[summed > 255] = 255 resources.save_img( amplified_complement, person_path + "_ciphered/" + files[0].split(".")[0].split("/")[-1] + ".png") resources.save_img( summed, person_path + "_ciphered/" + files[0].split(".")[0].split("/")[-1] + "_summed.png") # first object of the map overlap.overlap(card, amplified_complement, 0, 0) print(files) j = 0 # for each img of the rest for i in range(1, len(files)): source = person_path + "/" + files[i] img = resources.load_img(source) img = resources.img_to_binary_img(img) print(files[i]) # intersection share from img img = intersection.intersection(img, img_1, base, complement) img = amplify.amplify(img, 2) summed = img + amplified_base summed[summed == 255] = 0 summed[summed > 255] = 255 resources.save_img( img, person_path + "_ciphered/" + files[i].split(".")[0].split("/")[-1] + ".png") resources.save_img( summed, person_path + "_ciphered/" + files[i].split(".")[0].split("/")[-1] + "_summed.png") if i % 3 == 0: j = 1 overlap.overlap(card, img, j * 200, (i % 3) * 200) amplified_base = printfy.img_to_printed(amplified_base) resources.save_img(amplified_base, person_path + "_ciphered/ciphered_base.png") resources.save_img(card, person_path + "_ciphered/final_map.png")
#definition of the names of proteins to evaluate protein_name=['Erk','AMPK','mTOR'] #threshold definition for upper and lower tail lowThr=[] highThr=[] #upper and lower tail construction indexes=upper_lower_set(Results_tot,Nr,protein_name,lowThr,highThr) #intersection among proteins region_tot=defaultdict(list) for k in range(0,Nr): [region, region_name]=intersection(indexes[k]) for i in range(0,len(region_name)): region_tot[region_name[i]].append(region[i]) MIRIT=[] CloudH_T=[] CloudL_T=[] #for each realization for k in range(0,Nr): #cloud definition NCloudH=0
def test_intersection(self): # Failure message: # expected intersection([1, 2, 3], [2, 3, 4]) to equal [2, 3] self.assertEqual(intersection([1, 2, 3], [2, 3, 4]), [2, 3])
def test_basic(inputs, expected): results = intersection(*inputs) assert results == expected
def cult_I(m, n, input_values, values): """ capacity utilization of linings in tunnels (CULT-I) according to the paper: Performance indicator of tunnel linings under geotechnical uncertainty; Spyridis, Panagiotis; Konstantis, Spyridon; Gakis, Angelos cult_I = sqrt( (N_rel,i^2 + M_rel,i^2) / (N_rel,max^2 + M_rel,max^2) ) :input: m = x coordinate of a point, moment, float n = y coordinate of a point, normal force, float input_values = dict of input values, dict[str:float] values = dict of resulting values from core function, dict[str:float] :return: cult_I: float """ if input_values['a_s1'] == 0: limit_x_pos = values['Moment'] limit_y = values['Normal Force'] n_rel_max = abs(min(limit_y) - max(limit_y)) m_rel_max = abs(max(limit_x_pos)) else: limit_x_pos = values['Moment Reinf'] limit_y = values['Normal Force Reinf'] n_rel_max = abs(min(limit_y) - max(limit_y)) / 2 # take the half m_rel_max = abs(max(limit_x_pos)) if input_values['a_s2'] == 0: limit_x_neg = values['Moment Neg'] else: limit_x_neg = values['Moment Reinf Neg'] limit_x_pos = np.array(limit_x_pos) limit_x_neg = np.array(limit_x_neg) limit_y = np.array(limit_y) horizontal_cut_x = np.array([min(limit_x_neg), max(limit_x_pos)]) horizontal_cut_y = np.array([n, n]) vertical_cut_x = np.array([m, m]) vertical_cut_y = np.array([max(limit_y), min(limit_y)]) if m > 0: x1, _ = inter.intersection(horizontal_cut_x, horizontal_cut_y, limit_x_pos, limit_y) _, y2 = inter.intersection(vertical_cut_x, vertical_cut_y, limit_x_pos, limit_y) if len(x1) == 0 or len(y2) == 0: cult_I = 'outside' return cult_I m_rel_i = x1 - m if len(y2) > 1: n_rel_i = min(abs(y2[0] - n), abs(y2[1] - n)) else: n_rel_i = abs(y2[0] - n) if n_rel_i > n_rel_max: n_rel_i = min( abs(min(limit_y)) - abs(n), max(limit_y) - abs(n)) if m_rel_i < 0: cult_I = 'outside' return cult_I elif m == 0: m_rel_i = m_rel_max n_rel_i = min(abs(min(limit_y)) - abs(n), max(limit_y) - abs(n)) if max(limit_y) < n < min(limit_y): cult_I = 'outside' return cult_I else: x1, _ = inter.intersection(horizontal_cut_x, horizontal_cut_y, limit_x_neg, limit_y) _, y2 = inter.intersection(vertical_cut_x, vertical_cut_y, limit_x_neg, limit_y) if len(x1) == 0 or len(y2) == 0: cult_I = 'outside' return cult_I m_rel_i = x1 - m if len(y2) > 1: n_rel_i = min(abs(y2[0] - n), abs(y2[1] - n)) else: n_rel_i = abs(y2[0] - n) if n_rel_i > n_rel_max: n_rel_i = min( abs(min(limit_y)) - abs(n), max(limit_y) - abs(n)) if m_rel_i > 0: cult_I = 'outside' return cult_I cult_I = np.sqrt((m_rel_i * m_rel_i + n_rel_i * n_rel_i) / (m_rel_max * m_rel_max + n_rel_max * n_rel_max)) if cult_I is not str: if type(cult_I) is np.float64: cult_I = round(cult_I, 3) else: cult_I = round(cult_I[0], 3) return cult_I
def draw_limits(input_file, output_dir, ch='mmm', twoD=False, verbose=False): ''' ############################################################################# ## producing coupling vs r limits for each signal mass and a given channel ## ## also has the option 2D, in order to draw mass vs coupling limits (this ## ## uses the intersections of the 1D limits and the r=1 line) ## ############################################################################# ''' # create signal and limits dictionary limits, masses = get_lim_dict(input_file, output_dir, ch=ch) signals = get_signals() b = np.arange(0., 11, 1) req1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] ixs = OrderedDict() #sort the dictionary after v values limits = OrderedDict(sorted(limits.items(), key=lambda t: t[1]['V'])) ExclusionLimits2D_low = {} ExclusionLimits2D_high = {} for ExclusionLimits2D in [ExclusionLimits2D_low, ExclusionLimits2D_high]: ExclusionLimits2D['masses'] = [] ExclusionLimits2D['x_err'] = [] ExclusionLimits2D['y_exp'] = [] ExclusionLimits2D['y_ep1s'] = [] ExclusionLimits2D['y_ep2s'] = [] ExclusionLimits2D['y_em1s'] = [] ExclusionLimits2D['y_em2s'] = [] for mass in masses: # for m in [1,2,3,4,5,6,7,8,9,10]: # print(colored('doing MASS = %d GeV'%mass,'green')) print('### doing MASS = %d GeV' % mass) y_exp = [] y_ep1s = [] y_ep2s = [] y_em2s = [] y_em1s = [] v2s = [lim for lim in limits if 'M%d_' % mass in lim] b_V2 = [] for v2 in v2s: # if limits[v2].has_key('exp'): if 'exp' in limits[v2]: try: y_exp.append(limits[v2]['exp']) y_ep1s.append(limits[v2]['ep1s']) y_ep2s.append(limits[v2]['ep2s']) y_em1s.append(limits[v2]['em1s']) y_em2s.append(limits[v2]['em2s']) b_V2.append(limits[v2]['V2']) # if m == 5: set_trace() except: set_trace() if len(b_V2) == 0: print( 'combine failed processing this channel, continue doing to next one' ) continue x_err = np.zeros(len(b_V2)) b_V2.sort(reverse=False) for i in range(len(y_exp)): y_ep1s[i] = abs(y_ep1s[i] - y_exp[i]) y_ep2s[i] = abs(y_ep2s[i] - y_exp[i]) y_em1s[i] = abs(y_em1s[i] - y_exp[i]) y_em2s[i] = abs(y_em2s[i] - y_exp[i]) # if Mass == '5' and V == '0.00145602197786': set_trace() exp = rt.TGraph(len(b_V2), np.array(b_V2), np.array(y_exp)) gr1 = rt.TGraphAsymmErrors(len(b_V2), np.array(b_V2), np.array(y_exp), np.array(x_err), np.array(x_err), np.array(y_em1s), np.array(y_ep1s)) gr2 = rt.TGraphAsymmErrors(len(b_V2), np.array(b_V2), np.array(y_exp), np.array(x_err), np.array(x_err), np.array(y_em2s), np.array(y_ep2s)) rt.gStyle.SetOptStat(0000) # B_V2 = np.logspace(-11, -1, 10, base=10) # B_Y = np.logspace(-4, 4, 10, base=10) B_V2 = np.logspace(-11, 1, 120, base=10) B_Y = np.logspace(-4, 9, 150, base=10) r1g = rt.TGraph(len(B_V2), np.array(B_V2), np.ones(len(B_V2))) r1g.SetLineColor(rt.kRed + 1) r1g.SetLineWidth(1) framer = rt.TH2F('framer', 'framer', len(B_V2) - 1, B_V2, len(B_Y) - 1, B_Y) # framer.GetYaxis().SetRangeUser(0.0001,10000) # framer.GetXaxis().SetRangeUser(0.00000000001, 0.1) framer.GetYaxis().SetRangeUser(0.0001, 1000000000) framer.GetXaxis().SetRangeUser(0.00000000001, 10.) if ch == 'mmm': framer.SetTitle('m_{N} = %d GeV, #mu#mu#mu; |V_{#mu N}|^{2}; r' % mass) if ch == 'eee': framer.SetTitle('m_{N} = %d GeV, eee; |V_{e N}|^{2}; r' % mass) if ch == 'mem_OS': framer.SetTitle('m_{N} = %d GeV, #mu#mue OS; |V_{#mu N}|^{2}; r' % mass) if ch == 'mem_SS': framer.SetTitle('m_{N} = %d GeV, #mu#mue SS; |V_{#mu N}|^{2}; r' % mass) if ch == 'eem_OS': framer.SetTitle('m_{N} = %d GeV, ee#mu OS; |V_{e N}|^{2}; r' % mass) if ch == 'eem_SS': framer.SetTitle('m_{N} = %d GeV, ee#mu SS; |V_{e N}|^{2}; r' % mass) exp.SetMarkerStyle(22) exp.SetMarkerSize(1) exp.SetMarkerColor(rt.kRed + 2) exp.SetLineColor(rt.kRed + 2) gr1.SetFillColor(rt.kGreen + 2) gr1.SetLineColor(rt.kGreen + 2) gr1.SetLineWidth(2) gr2.SetFillColor(rt.kOrange) gr2.SetLineColor(rt.kOrange) gr2.SetLineWidth(2) can = rt.TCanvas('limits', 'limits') can.cd() can.SetLogy() can.SetLogx() # can.SetBottomMargin(0.15) framer.Draw() # can.Update() gr2.Draw('same, E1') gr2.Draw('same, E3') # can.Update() gr1.Draw('same, E1') gr1.Draw('same, E3') # can.Update() exp.Draw('same, LP') # can.Update() r1g.Draw('same') # can.Update() leg = rt.TLegend(.4, .75, .8, .88) leg.AddEntry(exp, 'Expected', 'LP') leg.AddEntry(gr1, 'Expected #pm 1 #sigma', 'E3') leg.AddEntry(gr2, 'Expected #pm 2 #sigma', 'E3') leg.Draw('apez same') # plotfactory.showlogopreliminary() plotfactory.showlumi('N#rightarrow%s; mass = %d GeV' % (ch, mass)) can.Update() #calculate and plot the intersection # if mass != 5: continue intersection_exp_x, intersection_exp_y = intersection( np.array(b_V2), np.array(y_exp), np.array(b_V2), np.ones(len(b_V2))) intersection_ep1_x, intersection_ep1_y = intersection( np.array(b_V2), np.array(y_exp) + np.array(y_ep1s), np.array(b_V2), np.ones(len(b_V2))) intersection_ep2_x, intersection_ep2_y = intersection( np.array(b_V2), np.array(y_exp) + np.array(y_ep2s), np.array(b_V2), np.ones(len(b_V2))) intersection_em1_x, intersection_em1_y = intersection( np.array(b_V2), np.array(y_exp) - np.array(y_em1s), np.array(b_V2), np.ones(len(b_V2))) intersection_em2_x, intersection_em2_y = intersection( np.array(b_V2), np.array(y_exp) - np.array(y_em2s), np.array(b_V2), np.ones(len(b_V2))) containsEmptyArrays = False for intersections in [ intersection_exp_x, intersection_ep1_x, intersection_ep2_x, intersection_em1_x, intersection_em2_x ]: if len(intersections) == 0: containsEmptyArrays = True continue if containsEmptyArrays: continue if mass == 5: continue intersection_exp = rt.TGraph(len(intersection_exp_x), np.array(intersection_exp_x), np.array(intersection_exp_y)) intersection_ep1 = rt.TGraph(len(intersection_ep1_x), np.array(intersection_ep1_x), np.array(intersection_ep1_y)) intersection_ep2 = rt.TGraph(len(intersection_ep2_x), np.array(intersection_ep2_x), np.array(intersection_ep2_y)) intersection_em1 = rt.TGraph(len(intersection_em1_x), np.array(intersection_em1_x), np.array(intersection_em1_y)) intersection_em2 = rt.TGraph(len(intersection_em2_x), np.array(intersection_em2_x), np.array(intersection_em2_y)) intersection_exp.SetMarkerColor(rt.kRed + 2) intersection_ep1.SetMarkerColor(rt.kGreen + 2) intersection_ep2.SetMarkerColor(rt.kOrange) intersection_em1.SetMarkerColor(rt.kGreen + 2) intersection_em2.SetMarkerColor(rt.kOrange) for intersectionPoints in [ intersection_exp, intersection_ep1, intersection_ep2, intersection_em1, intersection_em2 ]: intersectionPoints.SetMarkerStyle(29) intersectionPoints.SetMarkerSize(2) intersectionPoints.Draw('same, P') minNumberOfIntersections = 10 for intersections in [ intersection_exp_x, intersection_ep1_x, intersection_ep2_x, intersection_em1_x, intersection_em2_x ]: if len(intersections) < minNumberOfIntersections: minNumberOfIntersections = len(intersections) for i in range(2): try: if i == 0: index = 0 ExclusionLimits2D_low['masses'].append(float(mass)) ExclusionLimits2D_low['x_err'].append(0.) ExclusionLimits2D_low['y_exp'].append( float(min(intersection_exp_x))) ExclusionLimits2D_low['y_ep1s'].append( abs( float(min(intersection_ep1_x)) - float(min(intersection_exp_x)))) ExclusionLimits2D_low['y_ep2s'].append( abs( float(min(intersection_ep2_x)) - float(min(intersection_exp_x)))) ExclusionLimits2D_low['y_em1s'].append( abs( float(min(intersection_exp_x)) - float(min(intersection_em1_x)))) ExclusionLimits2D_low['y_em2s'].append( abs( float(min(intersection_exp_x)) - float(min(intersection_em2_x)))) if (i == 1) and (minNumberOfIntersections > 1): index = -1 ExclusionLimits2D_high['masses'].append(float(mass)) ExclusionLimits2D_high['x_err'].append(0.) ExclusionLimits2D_high['y_exp'].append( float(max(intersection_exp_x))) ExclusionLimits2D_high['y_ep1s'].append( abs( float(max(intersection_em1_x)) - float(max(intersection_exp_x)))) ExclusionLimits2D_high['y_ep2s'].append( abs( float(max(intersection_em2_x)) - float(max(intersection_exp_x)))) ExclusionLimits2D_high['y_em1s'].append( abs( float(max(intersection_exp_x)) - float(max(intersection_ep1_x)))) ExclusionLimits2D_high['y_em2s'].append( abs( float(max(intersection_exp_x)) - float(max(intersection_ep2_x)))) except: print('exception!!!!!!') set_trace() # if mass == 8: set_trace() if not os.path.isdir(output_dir + 'pdf'): os.mkdir(output_dir + 'pdf') if not os.path.isdir(output_dir + 'png'): os.mkdir(output_dir + 'png') if not os.path.isdir(output_dir + 'root'): os.mkdir(output_dir + 'root') can.SaveAs(output_dir + 'pdf/M%d_%s_root.pdf' % (mass, ch)) can.SaveAs(output_dir + 'png/M%d_%s_root.png' % (mass, ch)) can.SaveAs(output_dir + 'root/M%d_%s_root.root' % (mass, ch)) return ExclusionLimits2D_low, ExclusionLimits2D_high
def test_empty_list(self): self.assertEquals(intersection(LinkedList(), LinkedList()), None)
# -*- coding: utf-8 -*- import intersection # First point Xa = 26242.67 Ya = 11314.51 # Second Point Xb = 25318.11 Yb = 12450.24 # Mesaurements alpha = 38.4325 beta = 73.4894 Yp, Xp = intersection.intersection(Xa, Ya, Xb, Yb, alpha, beta, 'left') print("Yp:", format(Yp, ".2f"), "m") print("Xp:", format(Xp, ".2f"), "m")
plt.title('HNL m = %s GeV %s' % (mass, signal_type)) plt.legend() plt.ticklabel_format(axis='x', style='sci', scilimits=(0, 0)) plt.yscale('linear') plt.savefig('%s/limit_m_%s_lin.pdf' % (plotDir, mass)) plt.savefig('%s/limit_m_%s_lin.png' % (plotDir, mass)) plt.yscale('log') plt.xscale('log') plt.savefig('%s/limit_m_%s_log.pdf' % (plotDir, mass)) plt.savefig('%s/limit_m_%s_log.png' % (plotDir, mass)) # save the crossing for 2D limits limits2D[mass] = OrderedDict() # find the intersections x_minus_two, y = intersection(np.array(v2s), np.array(minus_two), np.array(v2s), np.ones(len(v2s))) x_minus_one, y = intersection(np.array(v2s), np.array(minus_one), np.array(v2s), np.ones(len(v2s))) x_central, y = intersection(np.array(v2s), np.array(central), np.array(v2s), np.ones(len(v2s))) x_plus_one, y = intersection(np.array(v2s), np.array(plus_one), np.array(v2s), np.ones(len(v2s))) x_plus_two, y = intersection(np.array(v2s), np.array(plus_two), np.array(v2s), np.ones(len(v2s))) if not opt.run_blind: x_obs, y = intersection(np.array(v2s), np.array(obs), np.array(v2s), np.ones(len(v2s))) limits2D[mass]['exp_minus_two'] = x_minus_two limits2D[mass]['exp_minus_one'] = x_minus_one limits2D[mass]['exp_central'] = x_central
def move_btn_cmd(self, *args): """Move button command""" self.offset = 100 / mc.floatFieldGrp(self.move, q=True, value=True)[0] it.intersection(self.offset)
def test_single_node(self): list = LinkedList("a") self.assertEquals(intersection(list, list), list.head.next)
def newIntersection(self, iid, model, cellh, cellv): itsc = intersection(iid, model, self.TIME) itsc.cellh = cellh itsc.cellv = cellv self.intersection.append(itsc) return itsc
import numpy as np import matplotlib.pyplot as plt from coeffs import * import intersection as INT O1=np.array([1,0]) F=0 r=np.sqrt(np.linalg.norm(O1)**2+F) n=np.array([1,1]) a1=3 m=omat@n a2=m@O1 O=INT.intersection(n,m,a1,a2) O2=2*O-O1 print(O2) print(r) A=np.array([5,-2]) B=np.array([-1,4]) AB=line_gen(A,B) len=500 circle=np.zeros((2,len)) theta=np.linspace(0,2*np.pi,len) circle[0,:]=r*np.cos(theta) circle[1,:]=r*np.sin(theta) C1=(circle.T+O1).T C2=(circle.T+O2).T
def main(): while True: try: #fetch the input input_command = raw_input() #check the input a, c, r, g = reg_exp(input_command) # if input is in correct format if a or c or r or g: #extract street names from class StreetList names_list = [temp.street_name for temp in street_temp] coor_list = [temp.street_coor for temp in street_temp] if a or c: #extract coordinates street_name = re.findall('\".+\"', input_command)[0] street_name = street_name.lower() street_coor = extract_coor(input_command) if a: if street_name in names_list: show_error( "Error: Street already exists, cannot add.") else: street_temp.append( StreetList(street_name, street_coor)) #show_output("Street added.") if c: if street_name in names_list: #extract index of street to be changed and change coordinates street_temp[names_list.index( street_name)].street_coor = street_coor #show_output("Street changed.") else: show_error( "Error: Street doesn't exist, cannot change.") if r: street_name = re.findall('\".+\"', input_command)[0] street_name = street_name.lower() if street_name in names_list: del street_temp[names_list.index(street_name)] #show_output("Street removed.") else: show_error( "Error: Street doesn't exist, cannot remove.") if g: #display_graph(coor_list) vne.vertices = [] vne.edges = [] #extracting number of streets for for loops nos = len(street_temp) for first_street in range(nos - 1): #extracting number of coordinates for desired street noc_1 = len(street_temp[first_street].street_coor) for coor_num_1 in range(noc_1 - 1): for second_street in range(first_street + 1, nos): noc_2 = len( street_temp[second_street].street_coor) for coor_num_2 in range(noc_2 - 1): line1_src = street_temp[ first_street].street_coor[coor_num_1] line1_des = street_temp[ first_street].street_coor[coor_num_1 + 1] line2_src = street_temp[ second_street].street_coor[coor_num_2] line2_des = street_temp[ second_street].street_coor[coor_num_2 + 1] intersect_point = intersection( array(line1_src), array(line1_des), array(line2_src), array(line2_des)) if intersect_point is not None: vne.vertex(line1_src) vne.vertex(line1_des) vne.vertex(line2_src) vne.vertex(line2_des) vne.vertex(intersect_point) #extract index of respective coordinates for edges p1 = vne.vertex_index(line1_src) p2 = vne.vertex_index(line1_des) p3 = vne.vertex_index(line2_src) p4 = vne.vertex_index(line2_des) pi = vne.vertex_index(intersect_point) # adding edges vne.edge(p1, pi) vne.edge(p2, pi) vne.edge(p3, pi) vne.edge(p4, pi) print(vne) #print intersect_point # if input is not in correct format else: show_error("Error: Incorrect input format, please try again.") except: break
def check_btn_cmd(self, *args): """Check button command""" it.intersection()