def build_biome(self): global grid, pixel_grid, GRID_SIZE plt.figure() DIRECTION = [[-1, 1], [0, 1]] # value to add up # axis to change pos_x = rndm(0, GRID_SIZE - 1) pos_y = rndm(0, GRID_SIZE - 1) pos = [pos_x, pos_y] desired_area = rndm(self.min_area, self.max_area) grid[pos_x][pos_y] = self.color pixel_ = Pixel(self.name, self.deep_ocean_range, self.color, pos) pixel_grid[pos_x][pos_y] = pixel_ x_map = [] y_map = [] while self.curr_area < desired_area: random_dir = [DIRECTION[0][rndm(0, 1)], DIRECTION[1][rndm(0, 1)]] pos[random_dir[1]] += random_dir[0] if not (0 <= pos[0] < GRID_SIZE and 0 <= pos[1] < GRID_SIZE): pos[random_dir[1]] -= random_dir[0] continue if not checker[pos[0]][pos[1]]: grid[pos[0]][pos[1]] = self.color pixel_ = Pixel(self.name, self.deep_ocean_range, self.color, [pos[0], pos[1]]) pixel_grid[pos[0]][ pos[1]] = pixel_ ## NOT ADDING TO THE GRID!! checker[pos[0]][pos[1]] = True x_map.append(pos[0]) y_map.append(pos[1]) self.curr_area += 1 plt.clf() plt.xlim(0, GRID_SIZE) plt.ylim(0, GRID_SIZE) plt.plot(x_map, y_map, "bs") plt.tight_layout() plt.draw() plt.pause(0.00001)
# generate with open(fname, "w") as fout: # loop on events i = 0 while i < NEVENTS: header = [99] * 10 header[0] = len(PDGs) + 1 # daughters + mother header[4] = BeamPolarization # array to store all the particles in the event counter = 1 parts = [] # generate mother P = PMin + rndm() * (PMax - PMin) Phi = PhiMin + rndm() * (PhiMax - PhiMin) Theta = ThetaMin + rndm() * (ThetaMax - ThetaMin) vm = TLorentzVector(P * math.sin(Theta) * math.cos(Phi), P * math.sin(Theta) * math.sin(Phi), P * math.cos(Theta), math.sqrt(P * P + MotherMass * MotherMass)) r = abs(gauss(0., VR)) f = rndm() * 2 * math.pi vertex = (Vx + r * math.cos(f), Vy + r * math.sin(f), VzMin + rndm() * (VzMax - VzMin)) parts.append(storeParticle(PDGmother, vm, vertex, 0))
def getobstacles(self): n = self.xmax * self.ymax // 4 return [(rndm(0, self.xmax - 1), rndm(0, self.ymax - 1)) for i in range(n)]
BeamPolarization = -1 # not useful with open(ofilename, "w") as fout: # loop on events for i in range(1, NEVENTS + 1): vertex = (0.0, 0.0, 0.0) counter = 0 parts = [] pelectron = TVector3() pelectron.SetMagThetaPhi(5, math.radians(15), math.radians(180)) phi = 180 * rndm() pgammaC = TVector3() pgammaC.SetMagThetaPhi(Eg, math.radians(15), math.radians(0)) vnorm = pgammaC.Orthogonal() pgamma1 = TVector3() pgamma1.SetMagThetaPhi(Eg, math.radians(15), math.radians(0)) pgamma1.Rotate(math.radians(Phi / 2.), vnorm) pgamma1.Rotate(math.radians(phi), pgammaC) pgamma2 = TVector3() pgamma2.SetMagThetaPhi(Eg, math.radians(15), math.radians(0)) pgamma2.Rotate(math.radians(Phi / 2.), vnorm) pgamma2.Rotate(math.radians(phi - 180), pgammaC)
fname = random.choice(fnames).strip() lname = random.choice(lnames).strip() driver.get( "https://docs.google.com/forms/d/e/M5YKuPkrAOiStNGgokb_0aOK173lsj-1FAIpQLScicob_MvnDQ7p-asw/viewform?vc=0&c=0&w=1" ) elem = driver.find_element_by_xpath( "//input[@aria-label='Your Full Name ']") elem.clear() elem.send_keys(fname + ' ' + lname) elem = driver.find_element_by_xpath( "//input[@aria-label='Your Contact Number']") elem.clear() elem.send_keys(random.choice(numbers).strip()) elem = driver.find_element_by_xpath("//input[@aria-label='Your Email ID']") elem.clear() elem.send_keys((fname + lname).lower() + str(rndm())[2:5] + '@gmail.com') picker = '//div[@aria-posinset="' + str(int(str(rndm())[2:3]) % 3 + 1) + '"]' driver.find_element_by_xpath(picker).click() elem = driver.find_element_by_xpath( "//input[@aria-label='College Name and City']") elem.clear() elem.send_keys(random.choice(colleges).strip()) elem = driver.find_element_by_xpath( "//input[@aria-label='Current Location']") elem.clear() elem.send_keys(random.choice(locations).strip()) driver.find_element_by_xpath("//div[@aria-label='Full -Time']").click() driver.find_element_by_xpath( "//span[@class='appsMaterialWizButtonPaperbuttonLabel quantumWizButtonPaperbuttonLabel exportLabel']" ).click()
numbers = [] with open('C:\\Users\\Rajdeep\\Desktop\\firstnames.txt') as f: for item in f: fnames.append(item) with open('C:\\Users\\Rajdeep\\Desktop\\lastnames2.txt') as f: for item in f: lnames.append(item) with open('C:\\Users\\Rajdeep\\Desktop\\colleges.txt') as f: for item in f: colleges.append(item) with open('C:\\Users\\Rajdeep\\Desktop\\locations.txt') as f: for item in f: locations.append(item) with open('C:\\Users\\Rajdeep\\Desktop\\numbers.txt') as f: for item in f: numbers.append(item) for i in range(3): fname = random.choice(fnames).strip()[:-1] lname = random.choice(lnames).strip() print((fname + ' ' + lname) + ' studies at ' + random.choice(colleges).strip() + ' is from ' + random.choice(locations).strip() + ' can be called at ' + random.choice(numbers).strip() + ' and can be reached at ' + (fname + lname).lower() + str(rndm())[2:5] + '@gmail.com') print() for i in range(50): print(int(str(rndm())[2:3]) % 3 + 1)
from random import normalvariate as rndm # read in ctrl data,(size: NSTATES x 1),add noise to get pertrurbed values # inputs: path to ctrl data, # output: s0file.dat = control data (ctrl_file) + random noise, N(0, sigma_pert^2) (in the same folder as script is executed) # inputs: ctrl_file = sys.argv[1] # file that contains true data sigma_pert = sys.argv[2] # sigma of perturbation noise # convert to float sigma_pert = float(sigma_pert) # load true data ctrl_data = np.loadtxt(ctrl_file) # define K = no. of states K = np.size(ctrl_data) # define an_data vector Kx1 pert_data = np.zeros(K) # pert_data = ctrl_data + noise (random number) for i in range(K): pert_data[i] = ctrl_data[i] + rndm(0, sigma_pert) # save output to file np.savetxt('s0file.dat', pert_data, fmt='%.10f') # END OF FILE
########## BeamPolarization = -1 # not useful with open( ofilename ,"w") as fout: # loop on events for i in range(1,NEVENTS+1): header = [99]*10 header[0] = len(PDGs) header[4] = BeamPolarization for h in header: fout.write(str(h)) fout.write(" ") fout.write("\n") r = -VR + 2*VR*rndm() #r = abs( gauss( 0., VR ) ) f = rndm()*2*math.pi vx= Vx + r vy= Vy vz= VzMin + rndm()*(VzMax - VzMin) for j,p in enumerate(PDGs): particle = [99]*14 particle[0] = j + 1; particle[2] = 1 particle[3] = p P = PMin + rndm()*(PMax - PMin) Phi = PhiMin + rndm()*(PhiMax - PhiMin) Theta = ThetaMin + rndm()*(ThetaMax - ThetaMin)
# generate with open(fname, "w") as fout: # generate event Event = TGenPhaseSpace() Event.SetDecay(CME, len(FSMasses), array('d', FSMasses)) # loop on events for i in range(1, NEVENTS + 1): # generate event counter = 1 w = Event.Generate() # generate vertex vertex = (VxMin + rndm() * (VxMax - VxMin), VyMin + rndm() * (VyMax - VyMin), VzMin + rndm() * (VzMax - VzMin)) # write header header = [99] * 10 header[0] = len(FSPDGs) + len(PDGs) + len( gPDGs) # daughters + mother + electron + proton header[4] = BeamPolarization header[6] = w # array to store all the particles in the event parts = [] # the reaction for l, j in enumerate(FSPDGs):
# read in true data at time index t_index, add noise to get initial value for model # inputs: path to true data, time index, sigma_an # output: s0file.dat = "analysed data" = truth + noise, noise ~ N(0,sigma_an^2) (output in the same folder as script is executed) # inputs: truth_file = sys.argv[1] # file that contains true data t_index = sys.argv[2] # index for time t sigma_an = sys.argv[3] # sigma for analysis # convert t_index to integer t_index = int(t_index) # convert sigma_an to float sigma_an = float(sigma_an) # load true data truth_data = np.loadtxt(truth_file) # define K = no. of states K = np.size(truth_data[t_index, :]) # define an_data vector an_data = np.zeros(K) # an_data = truth_data[t_index, :] + noise (random number) for i in range(K): an_data[i] = truth_data[t_index, i] + rndm(0,sigma_an) # save output to file np.savetxt('s0file.dat', an_data, fmt='%.10f') # END OF FILE