def predict_vm(ecs_infor_array, input_file_array): #Get the CPU information CPU_kernel, CPU_memory, N_Pvm, condition, Pvm, Predict_time, Predict_Start = utils.splitEscData( ecs_infor_array) #Get the History Data information length, Hvm, History_Start = utils.splitInputData(input_file_array) #History Data lenD, S_Data = utils.Denoise_Split(length, Hvm, N_Pvm, Pvm) #print S_Data result = [] if ecs_infor_array is None: print 'ecs information is none' return result if input_file_array is None: print 'input file information is none' return result #--------------------method one estimate-------------- NEPvm = TDEstimation.EstTD(History_Start, Predict_Start, lenD, N_Pvm, S_Data, Predict_time) print NEPvm # allocation CPU, N_PCPU = Box.Boxing(NEPvm, Pvm, N_Pvm, CPU_kernel, CPU_memory, condition) print N_PCPU result = utils.results_expression(CPU, N_PCPU, N_Pvm, Pvm) return result
def test_make(self): # Make a 10 x 10 x 10 box box = Box.make() self.assertEqual(len(box.Faces), 6) self.assertAlmostEqual(box.Volume, 1000) self.assertAlmostEqual(box.Area, 600) self.assertEqual(box.TypeId, 'Part::TopoShape')
def move_objects(self, land_sound_flag=True): ## link all boxes to platforms they are standing on for bod in self.box_list: bod.move( ) # boxes not floating and not resting on will accelerate down if bod.vel[1] > 0: # if falling for bod2 in self.platform_list + self.box_list: # find a landing spot if Box.resolve_fall(bod, bod2): # if not just touching another falling box, you've landed bud. if not isinstance(bod2, Box.Box) or bod2.vel[1] == 0: bod.vel[1] = 0 #stop falling. if land_sound_flag: # if this is flagged (i.e. if this is in game not resetting) thud_sound() # play hitting ground sound # tnt boxes start timers if hitting the ground or getting hit (not on reset though) for b in bod.recursive_dependent_list() + [ bod2 ]: # the base box or anything on the falling one if isinstance(b, Box.Tnt): if b.countdown == -1: b.start_countdown() break # no need to check for any more landing spots for bod in self.platform_list + self.baddie_list: # platforms and baddies* do not fall, they float. bod.move() # *for now?
def predict_vm(ecs_infor_array, input_file_array): #Get the CPU information CPU_kernel, CPU_memory, N_Pvm, condition, Pvm, Predict_time, Predict_Start = utils.splitEscData( ecs_infor_array) #Get the History Data information length, Hvm, History_Start = utils.splitInputData(input_file_array) #History Data #Statistic and Split #lenD,S_Data=utils.Statistic_Split(length,Hvm,N_Pvm,Pvm) lenD, S_Data = utils.Denoise_Split(length, Hvm, N_Pvm, Pvm) #print S_Data result = [] if ecs_infor_array is None: print 'ecs information is none' return result if input_file_array is None: print 'input file information is none' return result #-----------------------Mirror------------------------- #NEPvm=mirror.Mirror(lenD,N_Pvm,S_Data,Predict_time) #-----------------------Smirror------------------------- #NEPvm=mirror.Smirror(lenD,N_Pvm,S_Data,Predict_time) #-----------------------Smirror------------------------- NEPvm = mirror.Commirror(lenD, N_Pvm, S_Data, Predict_time) # allocation CPU, N_PCPU = Box.Boxing(NEPvm, Pvm, N_Pvm, CPU_kernel, CPU_memory, condition) print N_PCPU result = utils.results_expression(CPU, N_PCPU, N_Pvm, Pvm) return result
def genBoxes(self, ppfunction): # Preprocessing processed = ppfunction() # Edge Highlightning edged = processed.copy() edged = cv2.Canny( processed, 10, 200 ) # canny: first parameter -> greater, # canny: second parameter -> greater, less contours # Contours Detection cnts, hierarchy = cv2.findContours(edged, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # Boxing making factory = DPFactory.DPFactory('configuration.ini') dp = factory.generate() boxes = list(cnts) boxes = map(lambda x: Box.Box(x, dp, self.img, self.pcm), boxes) # Filtering # [Area] Is the area in the valid range? boxes = filter(lambda x: x.checkArea(), boxes) # [Black] Is the area "totally" black? boxes = filter(lambda x: x.isNotBlack(), boxes) # [Canvas] Is the area in the legal area (the canvas)? boxes = filter(lambda x: x.inCanvas(), boxes) # [Inside] Is the area inside another one? boxes = filter(lambda x: not x.insider(boxes), boxes) return boxes
def add_box(self, box_type, position, floating=False): position[1] *= -1.0 pos = np.array(position, dtype='float') * (box_size * 2.0) + [ 0, floor - box_size ] self.master_box_list.append(Box.create_box(box_type, pos, floating))
def initBoxes(self): self.boxesImage = pygame.image.load(os.getcwd() + "\\data\\sprites\\boxes.png") boxes = [[pygame.Rect(0, 0, 260, 80), "SinglePlayer"], [pygame.Rect(0, 80, 260, 80), "HighScores"], [pygame.Rect(0, 160, 260, 80), "Exit"]] for box in boxes: self.boxes.append(b.Button(box[0], box[1], self.boxesImage))
def redrawAll(self, screen): for i in range(20): for j in range(20): X = j * self.sizex Y = i * self.sizey if self.board[i][j] == 1: obs = Box.Box(X, Y, self.sizex, self.sizey) Box.Box.draw(obs, screen)
def builMatrixBoxes(self): boxesMatrix = [] for i in range(self.Row): aux=[] for j in range(self.Column): aux.append(Box(i,j,0)) boxesMatrix.append(aux) return boxesMatrix
def create_boxes(): boxes = [] for i in range(grid_size[0]): boxes.append([]) for i in range(grid_size[0]): for j in range(grid_size[1]): boxes[i].append(Box((i, j), grid_param)) return boxes
def Visit_Array(self, curArray): length = curArray.length.val elemBox = curArray.typePtr.buildENV(self) inputList = [] for i in range(0, length): inputList.append(elemBox.makeCopy()) curBox = Box.ArrayBox(inputList, curArray.startPos, curArray.endPos, self.myErrHandler) return curBox
def credential_setting(): # Box用設定 if "box" == upload_type: global box_file global box_folder logging.getLogger('boxsdk').setLevel(logging.CRITICAL) key_name = "/SlackUploadFileTransfer/Box" box_setting = lambda_tools.ssm_get_parameter(name=key_name) box_setting = json.loads(box_setting) settings = box_setting["boxAppSettings"] box_user = kms_decrypted("BOX_USER") box_folder = Box.Folder( client_id=settings["clientID"], client_secret=settings["clientSecret"], enterprise_id=box_setting["enterpriseID"], jwt_key_id=settings["appAuth"]["publicKeyID"], rsa_private_key_data=settings["appAuth"]["privateKey"] ) box_folder.login(box_user) box_file = Box.File( client_id=settings["clientID"], client_secret=settings["clientSecret"], enterprise_id=box_setting["enterpriseID"], jwt_key_id=settings["appAuth"]["publicKeyID"], rsa_private_key_data=settings["appAuth"]["privateKey"] ) box_file.login(box_user) # Google用設定 if "google" == upload_type: global gdrive global gdrive_permission key_name = "/SlackUploadFileTransfer/GSuite" credential = lambda_tools.ssm_get_parameter(name=key_name) credential = json.loads(credential) gdrive = GSuite.Drive.Files( credential=credential, scopes=GSuite.Drive.SCOPES_MANAGE, delegate_user=credential["client_email"] ) gdrive_permission = GSuite.Drive.Permissions( credential=credential, scopes=GSuite.Drive.SCOPES_MANAGE, delegate_user=credential["client_email"] )
def openNodeContend(self): print "me abriste" horizontalEdge = [ [1,1,0], [0,0,0], [0,0,0], [1,1,1] ] verticalEdge = [ [1,0,0,0], [1,0,0,0], [0,0,0,0] ] boxes = [[Box(0,0, 2), Box(0,1, 1), Box(0,2, 0)], [Box(1,0, 1), Box(1,1, 0), Box(1,2, 0)], [Box(2,0, 0), Box(2,1, 0), Box(2,2, 0)]] self.w = GraphicNodeContend(self.rows,self.columns,self.node.verticalEdge,self.node.horizontalEdge,self.node.boxes) self.w.show() print "se abrio"
def readbox(filename): #read a 21cmfast output file and return a Box object with data #parse filename to (1) check its a 21cmFast box (2) get box parameters # (3) identify what sort of box it is param_dict=parse_filename(filename) print param_dict #open box and read in data dim=param_dict['HIIdim'] box_data=open_box(filename,dim) #tidy data to ensure its in optimal form i.e. trim padding box_data=trim_box(box_data) #push data into Box class box=Box() box.setBox(box_data,param_dict) return box
def readbox(filename): #read a 21cmfast output file and return a Box object with data #parse filename to (1) check its a 21cmFast box (2) get box parameters # (3) identify what sort of box it is param_dict = parse_filename(filename) print param_dict #open box and read in data dim = param_dict['HIIdim'] box_data = open_box(filename, dim) #tidy data to ensure its in optimal form i.e. trim padding box_data = trim_box(box_data) #push data into Box class box = Box() box.setBox(box_data, param_dict) return box
def top(): one = Box.Box(37.5, 150, 100, 100, 64, 224, 208) Box.Box.draw(one, main_screen) one.drawimg("Toppings/t1.jpg", main_screen) two = Box.Box(170, 150, 100, 100, 64, 224, 208) Box.Box.draw(two, main_screen) two.drawimg("Toppings/t2.jpg", main_screen) three = Box.Box(302.5, 150, 100, 100, 64, 224, 208) Box.Box.draw(three, main_screen) three.drawimg("Toppings/t3.jpg", main_screen) four = Box.Box(37.5, 337.5, 100, 100, 64, 224, 208) Box.Box.draw(four, main_screen) four.drawimg("Toppings/t4.jpg", main_screen) five = Box.Box(170, 337.5, 100, 100, 64, 224, 208) Box.Box.draw(five, main_screen) five.drawimg("Toppings/cs.jpg", main_screen) six = Box.Box(302.5, 337.5, 100, 100, 64, 224, 208) Box.Box.draw(six, main_screen) six.drawimg("Toppings/cs.jpg", main_screen) global pg pg = 2
def fro(): one = Box.Box(37.5, 150, 100, 100, 64, 224, 208) Box.Box.draw(one, main_screen) one.drawimg("Frostings/frosting1.jpg", main_screen) two = Box.Box(170, 150, 100, 100, 64, 224, 208) Box.Box.draw(two, main_screen) two.drawimg("Frostings/frosting2.jpg", main_screen) three = Box.Box(302.5, 150, 100, 100, 64, 224, 208) Box.Box.draw(three, main_screen) three.drawimg("Frostings/frosting3.jpg", main_screen) four = Box.Box(37.5, 337.5, 100, 100, 64, 224, 208) Box.Box.draw(four, main_screen) four.drawimg("Frostings/frosting4.jpg", main_screen) five = Box.Box(170, 337.5, 100, 100, 64, 224, 208) Box.Box.draw(five, main_screen) five.drawimg("Frostings/cs.jpg", main_screen) six = Box.Box(302.5, 337.5, 100, 100, 64, 224, 208) Box.Box.draw(six, main_screen) six.drawimg("Frostings/cs.jpg", main_screen) global pg pg = 1
def redrawAll(self, screen): for i in range(20): for j in range(20): X = j * self.sizex + self.xOffset Y = i * self.sizey + self.yOffset if self.board[i][j] == 1: obs = Box.Box(X, Y, self.sizex, self.sizey) Box.Box.draw(obs, screen) self.display = screen self.enemy.updateRect(screen) for sprite in self.entities: sprite.draw(screen)
def __init__(self): pygame.init() self.screen = pygame.display.set_mode( [SCREENWIDTH, SCREENHEIGHT + TILESIZE]) self.allSprites = pygame.sprite.Group() self.population = 4000 self.seaLevel = 0 self.seaIncrement = 1 self.resource = 2700 self.carryingCapacity = 4100 self.emotion = Emotion.NORMAL self.currentTurn = 0 # counter of Sprites self.startTreeCount = 0 self.treeCount = 0 self.houseCount = 0 self.factoryCount = 0 self.allSea = pygame.sprite.Group() self.allFactories = pygame.sprite.Group() self.allTrees = pygame.sprite.Group() self.allHouses = pygame.sprite.Group() self.allWaves = pygame.sprite.Group() self.spriteDict = {} self.constructionList = [] self.running = True pygame.key.set_repeat(300, 100) # self.initializeTerrain() self.box = Box(self, self.screen) self.seaX = 0 self.seaY = 0 self.clock = pygame.time.Clock()
def detectBaseDrawables(base): """Given a base WorldObject, return a list of the drawables that should be used to represent it. This starts with a box, then adds some decorations to make it a base. """ # This is a hack bzflag uses since the Z component of base size isn't sent over the wire. # if a base is not on the ground and it's height is zero, set the height to 1. if base.center[2] > 0 and base.size[2] == 0: base.size[2] = 1 drawables = Box.detectBoxDrawables(base) drawables.append(BaseDecal(base)) drawables.append(BaseRotorDecal(base)) return drawables
def _createSweptBoxList(self, world, speed): sweptList = [] self.specialSwept = None for entity in world.dynamicEntities: rb = entity.getComponent('RigidBody') colliders = entity.getComponent('ColliderList') if rb and colliders: c = colliders[0] collider = Box(entity.position - c.position, Vector2f(abs(c.size.x), abs(c.size.y))) swept = PhysicsSweptBox(collider, speed * rb.velocity, entity) sweptList.append(swept) world.addPhysicsEntity(swept) world.removeEntity(entity) if entity == self.specialEntity: self.specialSwept = swept return sweptList
def Show(self): File = open("Data/Save/Ships/" + self.FileName + "/Ships.txt", "r") n = int(File.readline()) names = [] for i in range(n): names.append(File.readline()[:-5]) File.close() self.Title = Box.TxtBox("Select Design", [350, 50], [300, 75], 25, self.Screen.background, 0) self.buts = [] for i in range(len(names)): self.buts.append( Buttons.ButtonWtxt(self.Screen, [350, 130 + 42 * i], [300, 40], names[i], 20, 1)) self.buts[-1].AddClick(self.Clear, ()) self.buts[-1].AddClick(self.NextInterface.Active, (self.Screen, self.stack, names[i])) self.Screen.draw()
def main(stdscr): curses.noecho() curses.curs_set(0) stdscr.keypad(True) mapReader = MapReader.MapReader('map') if mapReader.verifyMap() == False: curses.endwin() exit() player = Player.Player() box = Box.Box() mapReader.displayMap(stdscr) while True: entry = stdscr.getch() stdscr.clear() if entry == 27 or entry == 113: curses.endwin() exit() if entry == curses.KEY_UP: player.moveUp() mapReader.displayMap(stdscr) stdscr.refresh() if entry == curses.KEY_DOWN: player.moveDown() mapReader.displayMap(stdscr) stdscr.refresh() if entry == curses.KEY_LEFT: player.moveLeft() mapReader.displayMap(stdscr) stdscr.refresh() if entry == curses.KEY_RIGHT: player.moveRight() mapReader.displayMap(stdscr) stdscr.refresh()
def read_sudoku_in_line(self, txtPath, sudokuNumber):#Method that read a file where each line is a sudoku and save them in a list #open sudoku txt file file = open(txtPath, "r") #Read all lines of this file self.sudokuList = file.readlines() #Get the desired sudoku sudokuInLine = self.sudokuList[sudokuNumber] i = 0 while(i < len(sudokuInLine)-1): sudokuTmp = [] for j in range(0, 9): if(sudokuInLine[i+j] != ""): box = Box(((int)(sudokuInLine[i+j]))) #box.val sudokuTmp.append(box) self.sudokuToSolve.append(sudokuTmp) i = i + 9 file.close() return self.sudokuToSolve
def redrawAll(self, screen): self.display = screen pygame.draw.rect( screen, (0, 0, 0), (self.xOffset, self.yOffset, self.width * 2, self.height * 2), 4) for i in range(20): for j in range(20): X = j * self.sizex + self.xOffset Y = i * self.sizey + self.yOffset if self.board[i][j] == 1: obs = Box.Box(X, Y, self.sizex, self.sizey) Box.Box.draw(obs, screen) self.obstacles.add(obs) self.display = screen self.enemy.updateRect(screen) for sprite in self.entities: if sprite.alive: sprite.draw(screen)
""" horizontalEdge = [ [1,1,0], [0,0,0], [0,0,0], [1,1,1] ] verticalEdge = [ [1,0,0,0], [1,0,0,0], [0,0,0,0] ] boxes = [[Box(0,0, 2), Box(0,1, 1), Box(0,2, 0)], [Box(1,0, 1), Box(1,1, 0), Box(1,2, 0)], [Box(2,0, 0), Box(2,1, 0), Box(2,2, 0)]] sequenceEdge = [] if __name__ == "__main__": node = Node(horizontalEdge, verticalEdge, boxes, sequenceEdge ) obj=pc.pcPlayer(None, 2,None,None)
#!/usr/bin/python from __future__ import print_function import argparse from pprint import pprint as pp import Box parser = argparse.ArgumentParser() parser.add_argument("folder_name") args = parser.parse_args() folder_name = args.folder_name folder_info = Box._folder_info(folder_name) pp(folder_info)
def draw_level(self, gameDisplay, screen, character): # remove unnecessary destroyed objects for bod in self.foreground_list[::-1]: if bod.destruct_counter == 0: #completely destroyed! self.foreground_list.remove(bod) # move all non-corporeal objects to the foreground, deal with new checkpoints! for body_list in [self.box_list, self.gettable_list, self.baddie_list]: for bod in body_list[:: -1]: # need to go in reverse else removal of two objects doesn't work if not bod.corporeal: body_list.remove(bod) self.foreground_list.append(bod) # if this is a checkpoint box, player now is spawned here. if isinstance(bod, Box.Checkpoint): self.player_start = np.array( bod.pos, dtype=float) + [0, -box_size] self.level_set( ) # destroyed stuff is destroyed... forever! self.boxes_killed = character.current_status.counters[ 'boxes'] # lives can only be got once if isinstance(bod, Gettables.Life) or isinstance( bod, Box.Life): # search for copy in appropriate master list if isinstance(bod, Gettables.Life): master_list = self.master_gettable_list swap_box = False else: master_list = self.master_box_list swap_box = True # find closest equivalent object in that master list min_dist = np.inf for bod2 in master_list: if type(bod) == type(bod2): dist = np.linalg.norm(bod2.pos - bod.pos) if dist < min_dist: same_obj = bod2 min_dist = dist # remove it! master_list.remove(same_obj) # if it's a box replace it with a regular wooden box if swap_box: self.master_box_list.append( Box.create_box('wood', 1.0 * same_obj.pos, same_obj.floating)) # draw scenery (special rules for when they overlap with screen) for bod in self.scenery: if abs((screen.pos[0] - bod.pos[0]) * (1.0 - background_speed)) < (screen.size[0] + bod.size[0]): bod.draw(gameDisplay, [ screen.pos[0] - (character.pos[0] - bod.pos[0]) * background_speed - display_size[0] / 2, 0 ]) # If flop just hit the ground, reset the ticker, if currently shaking, advance the ticker. if self.ticker == -1 and character.flopping == (character.flop_stun - 1): self.ticker = len(self.shifts) - 1 thud_sound() elif self.ticker >= 0: self.ticker -= 1 # draw all non-scenery objects for small_list in self.big_list[:1] + [[character] ] + self.big_list[1:]: for bod in small_list: if self.ticker >= 0: # shakes from flop hit bod.visual_shift(self.shifts[self.ticker]) if screen.overlap(bod): bod.draw(gameDisplay, [character.pos[0] - display_size[0] / 2, 0]) else: # if object is blowing up/disappearing, continue this count even off screen bod.death_throws() if self.ticker >= 0: # undo shift from flop hit bod.visual_shift(-self.shifts[self.ticker]) # draw counters and icons at top of display character.current_status.draw(gameDisplay)
from Box import * test = Box(1, 2, 3, 1, 1, 1, "hello") print test.getModel()
#!/usr/bin/env python import os import argparse import Box parser = argparse.ArgumentParser() parser.add_argument("folder_name") args = parser.parse_args() folder_name = args.folder_name folder_id = Box._get_folder_id() box_folder_name = folder_name.split("/")[-1] folder_list = Box._folder_list(folder_id) print(folder_id) if folder_id not in folder_list: Box._folder_create(box_folder_name) Box._folder_change(box_folder_name) for file in os.listdir(folder_name): filename = folder_name + '/' + file print('Uploading {0}...'.format(filename)) Box._file_update(filename) else: for file in os.listdir(folder_name): filename = folder_name + '/' + file print('Uploading {0}...'.format(filename)) Box._file_update(filename) # os.remove(filename)
#!/usr/bin/python from __future__ import print_function import argparse from ConfigParser import SafeConfigParser import Box parser = argparse.ArgumentParser() parser.add_argument("filename") args = parser.parse_args() filename = args.filename Box._file_update(filename)
global pg pg = 2 def end(): erase((64, 224, 208)) if __name__ == "__main__": #start pygame pygame.init() main_screen = pygame.display.set_mode((450, 600)) main_screen.fill((255, 255, 224)) start = Box.Box(135, 500, 180, 50, 64, 224, 208) Box.Box.draw(start, main_screen) pg = 0 while True: ev = pygame.event.poll() if ev.type == pygame.MOUSEBUTTONDOWN: x, y = ev.pos if start.rec.collidepoint(x, y): erase((255, 255, 224)) one = Box.Box(37.5, 150, 100, 100, 64, 224, 208) Box.Box.draw(one, main_screen) one.drawimg("Actual/a1.jpg", main_screen)
#!/usr/bin/python from __future__ import print_function import argparse import Box parser = argparse.ArgumentParser() parser.add_argument("filename") args = parser.parse_args() filename = args.filename file_info = Box._file_info(filename) if '404' in file_info: print('File not found') else: path = '/' ctime = file_info['content_created_at'] mtime = file_info['content_modified_at'] size = file_info['size'] owner = file_info['owned_by']['name'] name = file_info['name'] id = file_info['id'] for folder in file_info['path_collection']['entries']: path += folder['name'] + '/' print('ID:\t\t{0}\nFILENAME:\t{1}\nOWNER:\t\t{2}\nMODIFIED:\t{3}\nCREATED:\t' '{4}\nPATH:\t\t{5}\nSIZE:\t\t{6}'.format(id, name, owner, mtime, ctime, path, size))
#!/usr/bin/python import argparse import Box parser = argparse.ArgumentParser() parser.add_argument("folder_name") args = parser.parse_args() folder_name = args.folder_name Box._folder_change(folder_name)
#!/usr/bin/python import argparse import Box parser = argparse.ArgumentParser() parser.add_argument("folder_name") args = parser.parse_args() folder_name = args.folder_name Box._folder_delete(folder_name)
import Box import Pyramid import Sphere shape = input( "Choose which shape you want to calculate: Box, Sphere, or Pyramid ") if shape == 'Box': l = int(input("Type the Length of your Box ")) w = int(input("Type the Width of your Box ")) h = int(input("Type the Height of your Box ")) b = Box.Box(l, w, h) print('This is the Surface Area of your Box | ', b.getSurfaceArea()) print('This is the Volume of your Box | ', b.getVolume()) elif shape == 'Pyramid': l = int(input("Type the Length of your Pyramid ")) w = int(input("Type the Width of your Pyramid ")) h = int(input("Type the Height of your Pyramid ")) p = Pyramid.Pyramid(l, w, h) print('This is the Surface Area of your Pyramid | ', p.getSurfaceArea()) print('This is the Volume of your Pyramid | ', p.getVolume()) elif shape == 'Sphere': r = int(input("Type the Radius of your Sphere ")) s = Sphere.Sphere(r) print('This is the Surface Area of your Sphere | ', s.getSurfaceArea()) print('This is the Volume of your Sphere | ', s.getVolume())
def generate_map(self, surface, color_liste, list_box): """Generate Map, create Pawns objects and Box objects""" #iterate our board for line in range(self.rows): for item in range(self.columns): x = BOARD_TOPLEFT[0] + item * (CELL_SIZE[0] + CELL_SPACING[0]) y = BOARD_TOPLEFT[1] + line * (CELL_SIZE[1] + CELL_SPACING[1]) if self.list_name[line][ item] != 'nothing': # if name is not 'nothing' if self.list_box_owner[line][ item] == "player_one" or self.list_box_owner[line][ item] == "player_one_fix": owner_pawn = "player_one" #whatever box is fix or not, the owner would be same else: owner_pawn = "player_two" #use specific class to create pawns if self.list_name[line][item] == "pharaoh": pawn = Pharaoh(self.list_name[line][item], owner_pawn, self.list_direction[line][item]) elif self.list_name[line][item] == "anubis": pawn = Anubis(self.list_name[line][item], owner_pawn, self.list_direction[line][item]) elif self.list_name[line][item] == "scarab": pawn = Scarab(self.list_name[line][item], owner_pawn, self.list_direction[line][item]) elif self.list_name[line][item] == "pyramid": pawn = Pyramid(self.list_name[line][item], owner_pawn, self.list_direction[line][item]) elif self.list_name[line][item] == "sphinx": pawn = Sphinx(self.list_name[line][item], owner_pawn, self.list_direction[line][item]) else: print("ERROR Pawn does not exit !") #set position of pawns pawn._set_pos_X(x) pawn._set_pos_Y(y) self.list_pawn.append( pawn ) #append pawns into a list to stock them and be able to use them later # set settings of box as pawns box = Box(self.list_box_owner[line][item], False) box._set_pos_X(x) box._set_pos_Y(y) box._set_box_color(int(9)) self.list_box.append(box) else: #if there are no pawns on box : box = Box(self.list_box_owner[line][item], True) #True means the box is empty box._set_pos_X(x) box._set_pos_Y(y) box._set_box_color(int(9)) self.list_box.append(box)
def main(): # Read parameter and output file names from sys.argv parameters, outfile, cpp = get_arguments() # Create simulation Box. See design document for details. Simba = Box(parameters[0], parameters[2], parameters[1], parameters[3], cpp) # Performs simulation and saves positions and timelist. position_list, timelist = Simba.simulate(outfile, parameters[5], parameters[4]) # If you only want to load data to test the observable use the following # command and comment the one directly above. In that case specify the outfile: #outfile = "vmdoutput.xyz" #position_list = np.array(get_output(outfile, parameters[0])) #timelist = parameters[4]*np.arange(parameters[5]) # Define MSD and RDF parameters msd_start = 7000 # Need something >= 1 msd_end = 9999 # Need something > msd_start and < n_steps rdf_bins = np.arange(0, int(Simba.boxdim), 0.1) # Creates RDF bins rdf_start = 9500 # Need > 0 rdf_end = 9999 # Need < n_steps # The code below will create and save a MSD plot from time msd_start to msd_end. print("Calculating the Mean Square Displacement function\n") MSD_arr = MSD(position_list, msd_start, msd_end, Simba.boxdim) #fig = plt.figure(figsize=(3, 6)) write_output("MSD_output.txt", timelist[msd_start - 1:msd_end] - timelist[msd_start - 1], MSD_arr) plt.figure(1) plt.plot(timelist[msd_start - 1:msd_end], MSD_arr) #plt.title("Mean Square Displacement") plt.xlabel("Time $\\rightarrow$", fontsize=12, fontstyle="italic") plt.ylabel("MSD(t)/$\\sigma^{2}$ $\\rightarrow$", fontsize=12, fontstyle="italic") #plt.show() plt.savefig('Plots/MSD_gas.png') # The code below will create and save an RDF plot from time msd_start to msd_end. print("Calculating the Radial Distribution function\n") rdf_arr, rdf_bins = RDF(position_list, rdf_start, rdf_end, rdf_bins, Simba.boxdim) rdf_arr /= parameters[1] write_output("RDF_output.txt", rdf_bins, rdf_arr) plt.figure(2) plt.plot(rdf_bins, rdf_arr) #plt.title("Radial Distribution Function") plt.xlabel("Distance/$\\sigma$ $\\rightarrow$", fontsize=12, fontstyle="italic") plt.ylabel("g(r) $\\rightarrow$", fontsize=12, fontstyle="italic") #plt.show() plt.savefig('Plots/RDF_gas.png') # The code below will create and save an energy plot, displaying the potential # kinetic and total energies throughout the simulation. print("Plotting energy functions\n") timelist, PE, KE, TE = np.loadtxt('energyfile.txt', usecols=[0, 1, 2, 3], unpack=True) #,dtype=float) plt.figure(3) plt.plot(timelist, KE) plt.plot(timelist, PE) plt.plot(timelist, TE) #plt.title("Energy as a function of time") plt.xlabel("Time $\\rightarrow$", fontsize=12, fontstyle="italic") plt.ylabel("Energy $\\rightarrow$", fontsize=12, fontstyle="italic") plt.legend(['KE', 'PE', 'TE']) plt.savefig('Plots/E.png') plt.show() print("Post Simulation Fitted Temperature: ", np.mean(KE) / (1.5 * len(Simba.particles))) print("All plots saved in directory. Simulation has been successful.")
#!/usr/bin/python import argparse import Box parser = argparse.ArgumentParser() parser.add_argument("filename") args = parser.parse_args() filename = args.filename Box._file_delete(filename)
clip1 = Clip("Sifap", "Mediano") eraser1 = Eraser("Milan", "Grande") eraser2 = Eraser("Pelikan", "Pequeño") pen1 = Pen("Bic", "2HB") pen2 = Pen("Bic", "4HB") pen3 = Pen("Stabilo", "4HB") pen4 = Pen("Studio", "4HB") marker1 = Marker("Sharpie", "Permanente") marker2 = Marker("Bic", "Permanente") reamOfPaper1 = ReamOfPaper("Chamex", "Hoja carta", "200") folder1 = Folder("Econofile", "grande", "200") tape1 = Tape("Tesa", "Transparente") stapler1 = Stapler("King", "200", "Grande") #creando caja1 box1 = Box() #Agregando objetos a la caja1 box1.add(clip1) box1.add(pen1) box1.add(pen2) box1.add(pen3) box1.add(folder1) box1.showContent() #imprimir el contenido de la caja #creando caja2 box2 = Box() #Agregando objetos a la caja2 box2.add(eraser1)
#!/usr/bin/python import argparse import Box parser = argparse.ArgumentParser() parser.add_argument("filename") args = parser.parse_args() filename = args.filename Box._file_download(filename)