def __init__ (self): self.player = Units.unit('Fred') self.A = Locations.location('A', 'Just empty room') self.B = Locations.location('B', 'Room with two door') self.C = Locations.location('C', 'Another empty room') self.rooms_map = {'A' : self.A, 'B' : self.B, 'C' : self.C}
def test_export(self): NUM_INCLUSIONS = 4 INCLUSION_SIZE = 0.2 #Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) inclusion_material2 = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion2', youngs_modulus=2500, poissons_ratio=0.2) inclusion_materials = [ inclusion_material, inclusion_material, inclusion_material2, inclusion_material ] matrix_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Matrix', youngs_modulus=3000, poissons_ratio=0.25) #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Circle.Constant(INCLUSION_SIZE, NUM_INCLUSIONS) loc = Locations.FixedLocation(generate_lattice=True, num_locations=4) circles = Locations.Location.GenerateInclusions( NUM_INCLUSIONS, dist, loc, inclusion_materials) output = Shapes.Circle.ExportInclusions(circles) print output
def find_nearest_package(package_manifest, current_location,truck): lowest_distance = 50 lowest_soonest_distance = 50 return_package = [] soonest_deadline = 999 for package in package_manifest: distance = Locations.get_distance_address(current_location, package.address) deadline = package.delivery_deadline if (package.delivery_deadline != 'EOD'): if (deadline <= soonest_deadline) and (distance < lowest_soonest_distance): soonest_deadline = deadline lowest_soonest_distance = distance lowest_distance = distance package_addy = package.address return_package = package elif distance < lowest_distance and lowest_soonest_distance == 50: lowest_distance = distance package_addy = package.address return_package = package truck.distance_traveled += lowest_distance return return_package
def test_generate_circles_50_visual(self): NUM_INCLUSIONS = 50 #Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) #This is going to use the same material for all inclusions inclusion_materials = [inclusion_material] * NUM_INCLUSIONS #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Circle.Random(NUM_INCLUSIONS) loc = Locations.RandomLocation(NUM_INCLUSIONS, buffersize=0, scale_factor=1) circles = Locations.Location.GenerateInclusions(NUM_INCLUSIONS, dist, loc, inclusion_materials, recurse_attempts=5, max_attempts=50) print 'Generated {0} circles'.format(len(circles))
def test_guassian_circles_visual(self): NUM_INCLUSIONS = 10 #Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) #This is going to use the same material for all inclusions inclusion_materials = [inclusion_material] * NUM_INCLUSIONS max_radius = Shapes.Circle.determine_max_radius(0, 3, 1) #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Circle.Gaussian(max_radius / 2, max_radius / 2, NUM_INCLUSIONS) loc = Locations.FixedLocation(generate_lattice=True, num_locations=NUM_INCLUSIONS, buffersize=0, scalefactor=1) circles = Locations.Location.GenerateInclusions(NUM_INCLUSIONS, dist, loc, inclusion_materials, recurse_attempts=5, max_attempts=50) LocationsTests.setupboundingbox() print 'Generated {0} circles'.format(len(circles)) for circle in circles: LocationsTests.drawCircle(circle.centre, circle.radius)
def test_generate_circles2(self): NUM_INCLUSIONS = 60 #Create the material for the matrix matrix_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Matrix', youngs_modulus=1000, poissons_ratio=0.2) #matrix_mesh = Mesh.Mesh(elem_shape=TRI) #Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) #inclusion_mesh = [Mesh.Mesh(elem_shape=QUAD_DOMINATED)] * NUM_INCLUSIONS #This is going to use the same material for all inclusions inclusion_materials = [inclusion_material] * NUM_INCLUSIONS #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Circle.Gaussian(0.1, 0.1, NUM_INCLUSIONS) loc = Locations.RandomLocation(NUM_INCLUSIONS) circles = Locations.Location.GenerateInclusions(NUM_INCLUSIONS, dist, loc, inclusion_materials, recurse_attempts=10)
def test_lattice_constructor(self): loc = Locations.FixedLocation(generate_lattice=True, num_locations=4) self.assertEqual(4, len(loc.locations)) self.assertTrue((0.25, 0.25) in loc.locations) self.assertTrue((0.25, 0.75) in loc.locations) self.assertTrue((0.75, 0.25) in loc.locations) self.assertTrue((0.75, 0.75) in loc.locations)
def recalcBtnSelect(event): global swePaths, precipPaths, tempPaths selectedLocations = list_locations.getSelectedValuesList() swePaths, precipPaths, tempPaths = Locations.getSelectedLocations( selectedLocations) pathsNoDPart, sList, pList, tList = CalcAtiMelt.processPathsLists( swePaths, precipPaths, tempPaths) dList = CalcAtiMelt.processPathsDatesList(pathsNoDPart) aList, mList = CalcAtiMelt.calcATIMelt(selectedLocations, sList, pList, tList, dList) # Write Melt-Cum and ATI Locations to DSS. CalcAtiMelt.writeAtiMelt(selectedLocations, dList, aList, mList) # Plot Locations if checkbox.selected = True. if chckbxShowLocationPlot.selected is True: # print '\nPLOT TEAM ACTIVATE' PlotAtiMelt.plotAtiMelt(selectedLocations) # Use optional specified dates if fields are not blank. # if startDateField.getText() and endDateField.getText() is not None: # pdStart, pdEnd = ProcessPD.getSpecifiedDates(startDateField, endDateField) # else: pdStart = None pdEnd = None # Create Paired Data for Selected Locations. ProcessPD.processPairedData(selectedLocations, dList, mList, aList, pdStart, pdEnd) # Populate the UI Paired Data Table. CalcPD.updatePDTable(dssFile, eventsTable, dm_events) # Close the DSS File. dssFile.close()
def remove_places(candidates): import Locations unwanted = Locations.has_building_words(candidates) if unwanted != []: for item in unwanted: candidates.remove(item) return candidates
def callback(self,data): # parse message measuredLocations = Locations.Locations() measuredLocations.setLocationsFromMeasurement(data) self.pendSamplingSemaphore() self.lastLocations = measuredLocations self.home1.updateLocation(self.lastLocations.home1) self.postSamplingSemaphore()
def test_create_random_location_one_circle(self): buffersize = 0.1 loc = Locations.RandomLocation(1, buffersize=buffersize, scale_factor=0.9) result = loc.retrieve_location(Shapes.shapes.CIRCLE) self.assertEqual(len(result), 2) self.assertTrue(0 <= result[0] <= 1) self.assertTrue(0 <= result[1] <= 1)
def updatePDTable(dssFile, eventsTable, dm_events): locationsList, eventsList = Locations.getPairedData(dssFile) columns = ("Location", "Event") data = [] dm_events.setRowCount(0) for l, e in zip(locationsList, eventsList): data.append([l, e]) dm_events.setDataVector(data, columns) eventsTable.repaint()
def run(self): name = raw_input('Please enter your name? ') #name ="Simon" self.user = User(name) Locations.buildMap() # Create the Map Data start = Locations.getStartLocation() self.user.Move(start) print "Running Game" #print "Location; " #print self.user.getLocation().name #print "User: "******"Items: " #print self.user.getItems() while self.user.isAlive(): displayStatus(self.user) actions = self.user.getLocation().getActions() action = self.getAction(actions) self.processAction(self.user,action,actions)
def __init__(self): self.ball = Locations.Locations().ball self.robotHome1 = Locations.Locations().home1 self.distanceToBall = 0 self.state = State.wait self.stopRushingGoalTime = 0 self.newCommand = False self.vel_x = 0.0 self.vel_y = 0.0 self.omega = 0.0 self.desiredPoint = 0.0 self.stopped = True #self.signal = Point() self.pause = 0 self.reset = 0 self.spin = 0 self.front = 0 self.back = 0 self.gogo = 0
def test_create_random_location_multiple_circles(self): buffersize = 0.1 loc = Locations.RandomLocation(3, buffersize=buffersize, scale_factor=0.9) for i in range(3): result = loc.retrieve_location(Shapes.shapes.CIRCLE) self.assertTrue(0 <= result[0] <= 1) self.assertTrue(0 <= result[1] <= 1)
def play_game(): game_screen = pygame.Surface((SCREEN_WIDTH, GAME_SCREEN_HEIGHT)) bg_color = BLACK all_objects = pygame.sprite.Group() #TODO -- load player and location(s) from file player = GameObjects.Player(all_objects, coords=(128, 80)) debug_screen = debug.DebugPane(player) '''# TEST LOCATIONS CONSTRUCTED BELOW v_wall_image = pygame.Surface((TILE_SIZE, GAME_SCREEN_HEIGHT)) h_wall_image_full = pygame.Surface((SCREEN_WIDTH - 2 * TILE_SIZE, TILE_SIZE)) h_wall_image_half = pygame.Surface((SCREEN_WIDTH / 2 - TILE_SIZE, TILE_SIZE)) left_wall = GameObjects.Wall(image=v_wall_image, coords=(0,0)) right_wall = GameObjects.Wall(image=v_wall_image, coords=(SCREEN_WIDTH - TILE_SIZE, 0)) bottom_wall = GameObjects.Wall(image=h_wall_image_full, coords=(TILE_SIZE, GAME_SCREEN_HEIGHT - TILE_SIZE)) top_left_wall = GameObjects.Wall(image=h_wall_image_half, coords=(0, 0)) top_right_wall = GameObjects.Wall(image=h_wall_image_half, coords=(SCREEN_WIDTH / 2 + TILE_SIZE, 0)) test_loc_1 = [left_wall, right_wall, bottom_wall, top_left_wall, top_right_wall] for wall in test_loc_1: wall.image.fill((128, 128, 128)) #test_loc_2 = all_objects.add(test_loc_1) # TEST LOCATIONS CONSTRUCTED ABOVE''' current_screen = Locations.Location() current_screen.load_screen('level01.json', 'home') for obj in current_screen: all_objects.add(obj) while True: if len(pygame.event.get(QUIT)): terminate() # TESTING if player.rect.centery <= 0 and current_screen.name == 'home': new_objects = change_location(game_screen, all_objects, 'UP', 'level01.json', 'other') all_objects.empty() all_objects.add(new_objects) player.set_coords((120, GAME_SCREEN_HEIGHT - TILE_SIZE)) all_objects.add(player) current_screen.name = 'other' elif player.rect.centery > GAME_SCREEN_HEIGHT and current_screen.name == 'other': new_objects = change_location(game_screen, all_objects, 'DOWN', 'level01.json', 'home') all_objects.empty() all_objects.add(new_objects) player.set_coords((120, 0)) all_objects.add(player) current_screen.name = 'home' # END TESTING #TODO -- check for game over (return if so) game_screen.fill(bg_color) player.update(all_objects) #TODO -- update objects by group (enemies, ....?) all_objects.draw(game_screen) SCREEN.blit(game_screen, (0, SCREEN_HEIGHT - GAME_SCREEN_HEIGHT)) debug_screen.update(player) debug_screen.draw(SCREEN) pygame.display.update() GAME_CLOCK.tick(FPS)
def test_fixed_random_order(self): """ Note that this test can technically fail. If the random function randomly puts the 10 objects back in the same order, then it will fail. That should only happen 1 in 3.6 million times the test is run though, so it should be fine. """ locs = [(0.1, 0.1), (0.2, 0.2), (0.3, 0.3), (0.4, 0.4), (0.5, 0.5), (0.6, 0.6), (0.7, 0.7), (0.8, 0.8), (0.9, 0.9)] fixed_loc = Locations.FixedLocation(locs, True) self.assertNotEqual(locs, fixed_loc.locations)
def __init__(self): self.id = Commuter.old_id Commuter.old_id = Commuter.old_id + 1 self.sex = self.generate_sex() self.mark = Commuter.MARKS[self.sex] self.name = self.generate_name() self.hometown = Locations.get_random_source() self.position = self.hometown self.has_ticket = self.generate_ticket() self.travel_time = 0
def try_to_advance(self): """ Try to advance with this bus, the Italian way. If the bus is travelling, it won't be at a bus stop. If it has arrived somewhere, it will be at the next bus stop from the last position recorded. Advancement is random :return: """ if self.should_advance(): self.last_position = Locations.get_next(self.last_position) self.is_at_bus_stop = True else: self.is_at_bus_stop = False
def render_template(self, template_name, template_values): user = users.get_current_user() url = users.create_logout_url(self.request.uri) user_name = user.nickname() default_template_values = { 'user_name': user_name, 'url': url, 'location_provider': locations.get_location_provider(), } all_values = dict(default_template_values.items() + template_values.items()) template = jinja_environment.get_template(template_name) self.response.out.write(template.render(all_values))
def test_generate_circles(self): NUM_INCLUSIONS = 4 INCLUSION_SIZE = 0.2 #Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) #This is going to use the same material for all inclusions inclusion_materials = [inclusion_material] * NUM_INCLUSIONS #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Circle.Constant(INCLUSION_SIZE, NUM_INCLUSIONS) loc = Locations.FixedLocation(generate_lattice=True, num_locations=4) circles = Locations.Location.GenerateInclusions( NUM_INCLUSIONS, dist, loc, inclusion_materials)
def change_location(game_screen, current_objects, direction, location_file, location_name): new_screen = Locations.Location() new_screen.load_screen(location_file, location_name) movement_dict = {'UP': (1, -SCREEN_HEIGHT), 'DOWN': (1, SCREEN_HEIGHT), 'LEFT': (0, -SCREEN_WIDTH), 'RIGHT': (0, SCREEN_WIDTH)} move_index, move_amount = movement_dict[direction] draw_objects = current_objects for obj in draw_objects: if isinstance(obj, GameObjects.Player): draw_objects.remove(obj) for obj in new_screen: new_coords = list(obj.rect.topleft) new_coords[move_index] += move_amount obj.set_coords(tuple(new_coords)) draw_objects.add(obj) #TODO -- player movement if move_index == 1: for i in xrange(SCREEN_HEIGHT): for obj in draw_objects: if direction == 'UP': obj.rect.top += 1 elif direction == 'DOWN': obj.rect.top -= 1 game_screen.fill(BLACK) draw_objects.draw(game_screen) SCREEN.blit(game_screen, (0, SCREEN_HEIGHT - GAME_SCREEN_HEIGHT)) pygame.display.update(Rect(0, SCREEN_HEIGHT - GAME_SCREEN_HEIGHT, SCREEN_WIDTH, GAME_SCREEN_HEIGHT)) GAME_CLOCK.tick(FPS) elif move_index == 0: for i in xrange(SCREEN_WIDTH): for obj in draw_objects: if direction == 'LEFT': obj.rect.left += 1 elif direction == 'RIGHT': obj.rect.left -= 1 game_screen.fill(BLACK) draw_objects.draw(game_screen) SCREEN.blit(game_screen, (0, SCREEN_HEIGHT - GAME_SCREEN_HEIGHT)) pygame.display.update(Rect(0, SCREEN_HEIGHT - GAME_SCREEN_HEIGHT, SCREEN_WIDTH, GAME_SCREEN_HEIGHT)) GAME_CLOCK.tick(FPS) return new_screen.objects
def NewGame(self): #Select Level self.Level = cm.GetInt("Select Level", 1, 1) #Select Heroes: self.Heroes = Hero.SelectHeroes() #Build Locations self.LocationDeck = Locations.BuildLocations(self.Level, False) self.CurrentLocation = self.LocationDeck[0] #Build Dark Arts self.DarkArtsDeck = DarkArts.BuildDarkArts(self.Level, False) #Build Villains self.VillainDeck, self.NVillains = Villains.BuildVillainDeck( self.Level, False) self.CurrentVillains = self.VillainDeck[0:self.NVillains] self.CurrentVillainsNames = [ i.Name for i in self.VillainDeck[0:self.NVillains] ] #Build Buy Deck self.BuyDeck = Card.BuildBuyDeck(self.Level, False)
#Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) inclusion_mesh = [Mesh.Mesh(elem_shape=QUAD_DOMINATED)] * NUM_INCLUSIONS #This is going to use the same material for all inclusions inclusion_materials = [inclusion_material] * NUM_INCLUSIONS #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Circle.Gaussian(0.15, 0.03, NUM_INCLUSIONS) loc = Locations.RandomLocation(NUM_INCLUSIONS) circles = Locations.Location.GenerateInclusions(NUM_INCLUSIONS, dist, loc, inclusion_materials, recurse_attempts=10) output = '[' for circle in circles: output += '{0}, '.format(circle.radius) output = output[:-3] output += ']' print output inclusions = zip(circles, inclusion_mesh)
import pickle import logging import ssl import pgeocode import os from geopy.geocoders import Nominatim #see https://stackoverflow.com/questions/50236117/scraping-ssl-certificate-verify-failed-error-for-http-en-wikipedia-org ssl._create_default_https_context = ssl._create_unverified_context nomi = pgeocode.Nominatim('ca') geolocator = Nominatim(user_agent="my_application") logging.basicConfig(level=logging.DEBUG) #CANADA_RTA = Locations.GetCanadaRTA() QUEBEC_RTA = Locations.GetQuebecRTA() CANADA_PROV = Locations.GetCanadaProvinces() COUNTRIES = Locations.GetCountries() QUEBEC_LAT_LONG = {} CANADA_PROV_LAT_LONG = {} COUNTRIES_LAT_LONG = {} quebec_lat_long_obj = os.path.join(os.path.dirname(os.getcwd()), "LatLongObj/quebec_lat_long.pkl") canada_prov_lat_long_obj = os.path.join(os.path.dirname(os.getcwd()), "LatLongObj/canada_prov_lat_long.pkl") countries_lat_long_obj = os.path.join(os.path.dirname(os.getcwd()), "LatLongObj/countries_lat_long.pkl") lat_long_out = os.path.join(os.path.dirname(os.getcwd()),
class UI: global dssFile mainWindow = ListSelection.getMainWindow() dssFileName = mainWindow.getDSSFilename() dssFile = HecDss.open(dssFileName) global frame, lbl_close, list_locations, chckbxShowLocationPlot, eventsTable, dm_events, dm_meltRate global swePaths, precipPaths, tempPaths, bList, meltRateTable, startDateField, endDateField frame = JFrame("Snow PAC - Parameter Aggregator & Calculator") # frame.setUndecorated(True) frame.setBackground(Color.WHITE) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) frame.setBounds(100, 100, 1110, 775) contentPane = JPanel() contentPane.setBackground(Color.WHITE) contentPane.setBorder(EmptyBorder(5, 5, 5, 5)) frame.setContentPane(contentPane) contentPane.setLayout(None) class MouseListener(MouseAdapter): # @Override def mousePressed(self, e): global xx global xy xx = e.getX() xy = e.getY() class MouseMotionListener(MouseMotionAdapter): # @Override def mouseDragged(self, arg0): x = arg0.getXOnScreen() y = arg0.getYOnScreen() frame.setLocation(x - xx, y - xy) mL = MouseListener() mML = MouseMotionListener() contentPane.addMouseListener(mL) contentPane.addMouseMotionListener(mML) if os.path.exists(img_dir + "/button.jpg"): btnIcon = ImageIcon(img_dir + "/button.jpg") else: btnIcon = ImageIcon(img_dir2 + "/button.jpg") scrollPane_events = JScrollPane() scrollPane_events.setBounds(270, 372, 403, 263) contentPane.add(scrollPane_events) scrollPane_locations = JScrollPane() scrollPane_locations.setBounds(270, 49, 403, 203) contentPane.add(scrollPane_locations) class deleteAction(AbstractAction): def actionPerformed(self, deleteEvent): # Get selected Rows and reverse list. Removes each row in list one at a time. # List is Reversed using [::-1], so it doesn't mess up the ordering as it deletes through the loop. for row in meltRateTable.getSelectedRows()[::-1]: dm_meltRate.removeRow(row) dm_meltRate.insertRow(row, [None, None]) scrollPane_table = JScrollPane() scrollPane_table.setBounds(708, 49, 338, 586) contentPane.add(scrollPane_table) meltRateTable = JTable() scrollPane_table.setViewportView(meltRateTable) scrollPane_table.setBorder(LineBorder(Color(1, 1, 1), 2, True)) meltRateTable.setFont(Font("Tahoma", Font.PLAIN, 11)) columns = ("ATI (Deg F-Day)", "Meltrate (Inches/Deg F-Day)") data = [] datarows = 100 data.append([0, None]) for i in range(datarows): data.append([None, None]) dm_meltRate = DefaultTableModel(data, columns) meltRateTable.setModel(dm_meltRate) meltRateTable.getColumnModel().getColumn(0).setPreferredWidth(154) meltRateTable.getColumnModel().getColumn(1).setResizable(False) meltRateTable.getColumnModel().getColumn(1).setPreferredWidth(154) meltRateTable.setCellSelectionEnabled(True) # Delete data from the table using the Delete Key. # meltRateTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); inputMap = meltRateTable.getInputMap(JComponent.WHEN_FOCUSED) actionMap = meltRateTable.getActionMap() deleteActionStr = "delete" inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), deleteActionStr) actionMap.put(deleteActionStr, deleteAction()) # jLabelStartDate = JLabel() # jLabelStartDate.setText("Optional Start Date:") # jLabelStartDate.setToolTipText("Optional User Specified Date Range for Paired Data. If Specified, Will be Calculated for each Water Year.") # jLabelStartDate.setBounds(420, 263, 120, 20); # jLabelStartDate.setFont( Font("Tahoma", Font.PLAIN, 12)) # contentPane.add(jLabelStartDate) # # startDateField = CalendarField(); # jLabelStartDate.setLabelFor(startDateField); # startDateField.setMargin(Insets(0, 4, 0, 0)); # startDateField.setBounds(540, 263, 118, 22); # startDateField.setFont(Font("Tahoma", Font.PLAIN, 12)); # startDateField.setToolTipText("Optional User Specified Date Range for Paired Data. If Specified, Will be Calculated for each Water Year.") # contentPane.add(startDateField); # # jLabelEndDate = JLabel() # jLabelEndDate.setText("Optional End Date:") # jLabelEndDate.setToolTipText("Optional User Specified Date Range for Paired Data. If Specified, Will be Calculated for each Water Year.") # jLabelEndDate.setBounds(420, 293, 120, 20); # jLabelEndDate.setFont( Font("Tahoma", Font.PLAIN, 12)) # contentPane.add(jLabelEndDate) # # endDateField = CalendarField(); # jLabelEndDate.setLabelFor(endDateField); # endDateField.setMargin(Insets(0, 4, 0, 0)); # endDateField.setBounds(540, 293, 118, 22); # endDateField.setFont(Font("Tahoma", Font.PLAIN, 12)); # endDateField.setToolTipText("Optional User Specified Date Range for Paired Data. If Specified, Will be Calculated for each Water Year.") # contentPane.add(endDateField); def recalcBtnSelect(event): global swePaths, precipPaths, tempPaths selectedLocations = list_locations.getSelectedValuesList() swePaths, precipPaths, tempPaths = Locations.getSelectedLocations( selectedLocations) pathsNoDPart, sList, pList, tList = CalcAtiMelt.processPathsLists( swePaths, precipPaths, tempPaths) dList = CalcAtiMelt.processPathsDatesList(pathsNoDPart) aList, mList = CalcAtiMelt.calcATIMelt(selectedLocations, sList, pList, tList, dList) # Write Melt-Cum and ATI Locations to DSS. CalcAtiMelt.writeAtiMelt(selectedLocations, dList, aList, mList) # Plot Locations if checkbox.selected = True. if chckbxShowLocationPlot.selected is True: # print '\nPLOT TEAM ACTIVATE' PlotAtiMelt.plotAtiMelt(selectedLocations) # Use optional specified dates if fields are not blank. # if startDateField.getText() and endDateField.getText() is not None: # pdStart, pdEnd = ProcessPD.getSpecifiedDates(startDateField, endDateField) # else: pdStart = None pdEnd = None # Create Paired Data for Selected Locations. ProcessPD.processPairedData(selectedLocations, dList, mList, aList, pdStart, pdEnd) # Populate the UI Paired Data Table. CalcPD.updatePDTable(dssFile, eventsTable, dm_events) # Close the DSS File. dssFile.close() def plotPDBtnSelect(event): selected_Events = eventsTable.getSelectedRows() # Print 'selected_Events: ', selected_Events # Sorting of the table by selecting the headers is doen by using: eventsTable.setAutoCreateRowSorter(True) # This sorts the table but does not update the table model. # To ensure sorting and selecting of resulting paths works properly, # we must convert our selection using: eventsTable.convertRowIndexToModel(event) selectedEvents = [] for event in selected_Events: selectedEvents.append(eventsTable.convertRowIndexToModel(event)) # print 'selectedEvents: ', selectedEvents PlotPD.plotPD(eventsTable, selectedEvents, dssFile) dssFile.close() def calcMeltRateBtnSelect(event): selected_Events = eventsTable.getSelectedRows() selectedEvents = [] for event in selected_Events: selectedEvents.append(eventsTable.convertRowIndexToModel(event)) meltRateList = CalcMeltRate.calcMeltRate(selectedEvents, eventsTable, meltRateTable, dssFile) CalcMeltRate.updateTable(meltRateTable, meltRateList, dm_meltRate) dssFile.close() locDict, bList = Locations.getPaths(dssFile) locList = Locations.getList(locDict) list_locations = JList(locList) scrollPane_locations.setViewportView(list_locations) list_locations.setBorder(LineBorder(Color(0, 0, 0), 2, True)) eventsTable = JTable() scrollPane_events.setViewportView(eventsTable) scrollPane_events.setBorder(LineBorder(Color(1, 1, 1), 2, True)) eventsTable.setFont(Font("Tahoma", Font.PLAIN, 11)) locationsList, eventsList = Locations.getPairedData(dssFile) columns = ("Location", "Event") data = [] for l, e in zip(locationsList, eventsList): data.append([l, e]) dm_events = DefaultTableModel(data, columns) eventsTable.setModel(dm_events) eventsTable.setAutoCreateRowSorter(True) eventsTable.getColumnModel().getColumn(0).setPreferredWidth(154) eventsTable.getColumnModel().getColumn(1).setResizable(False) eventsTable.getColumnModel().getColumn(1).setPreferredWidth(154) eventsTable.setRowSelectionAllowed(True) inputPanel = JPanel() inputPanel.setBorder(EmptyBorder(0, 0, 0, 0)) inputPanel.setBackground(Color(255, 255, 255)) inputPanel.setBounds(270, 11, 410, 27) contentPane.add(inputPanel) inputPanel.setLayout(None) inputPanel.setVisible(True) lbl_locations = JLabel( "DSS Locations that have PRECIP-INC, TEMPERATURE-AIR-AVG, and SWE. ") lbl_locations.setFont(Font("Tahoma", Font.PLAIN, 12)) lbl_locations.setBounds(0, 11, 410, 15) inputPanel.add(lbl_locations) btnRecalc = JButton(btnIcon, actionPerformed=recalcBtnSelect) btnRecalc.setText("Calculate Paired Data") btnRecalc.setFont(Font("Tahoma", Font.BOLD, 12)) btnRecalc.setForeground(Color.WHITE) btnRecalc.setBackground(Color.WHITE) btnRecalc.setBorderPainted(False) btnRecalc.setContentAreaFilled(False) btnRecalc.setFocusPainted(False) btnRecalc.setOpaque(True) btnRecalc.setVerticalTextPosition(SwingConstants.CENTER) btnRecalc.setHorizontalTextPosition(SwingConstants.CENTER) btnRecalc.setBounds(382, 293, 165, 54) contentPane.add(btnRecalc) leftPanel = JPanel() leftPanel.setBackground(Color.DARK_GRAY) leftPanel.setBounds(0, 0, 250, 780) contentPane.add(leftPanel) leftPanel.setLayout(None) lbl_castle = JLabel("") lbl_castle.setBounds(110, 678, 40, 25) leftPanel.add(lbl_castle) try: i_corps = ImageIO.read(File(img_dir + "/CorpsCastle.png")) except: i_corps = ImageIO.read(File(img_dir2 + "/CorpsCastle.png")) corpsCastle = i_corps.getScaledInstance(lbl_castle.getWidth(), lbl_castle.getHeight(), Image.SCALE_SMOOTH) lbl_castle.setVerticalAlignment(SwingConstants.TOP) lbl_castle.setIcon(ImageIcon(corpsCastle)) lbl_logo = JLabel("") lbl_logo.setBounds(18, 294, 218, 148) leftPanel.add(lbl_logo) try: snowLogo = ImageIO.read(File(img_dir + "/melted-snowman.png")) except: snowLogo = ImageIO.read(File(img_dir2 + "/melted-snowman.png")) dssLogo = snowLogo.getScaledInstance(lbl_logo.getWidth(), lbl_logo.getHeight(), Image.SCALE_SMOOTH) lbl_logo.setVerticalAlignment(SwingConstants.TOP) lbl_logo.setIcon(ImageIcon(dssLogo)) lbl_logo2 = JLabel("") lbl_logo2.setBounds(18, 11, 218, 148) leftPanel.add(lbl_logo2) try: snowPacLogo = ImageIO.read(File(img_dir + "/SnowPac.png")) except: snowPacLogo = ImageIO.read(File(img_dir2 + "/SnowPac.png")) snowPac = snowPacLogo.getScaledInstance(lbl_logo2.getWidth(), lbl_logo2.getHeight(), Image.SCALE_SMOOTH) lbl_logo2.setVerticalAlignment(SwingConstants.TOP) lbl_logo2.setIcon(ImageIcon(snowPac)) # lbl_close = JLabel("X") # # class CloseClickListener(MouseAdapter): # # @Override # def mouseEntered(self): # lbl_close.setBorder(LineBorder.createGrayLineBorder()) # # @Override # def mouseExited(self): # lbl_close.setBorder(None) # # @Override # def mouseClicked(self): # lbl_close.setBorder(BorderFactory.createLineBorder(Color.red)); # sys.exit(); # cL = CloseClickListener() # lbl_close.addMouseListener(cL) # # lbl_close.setHorizontalAlignment(SwingConstants.CENTER); # lbl_close.setForeground(Color(241, 57, 83)); # lbl_close.setFont(Font("Tahoma", Font.PLAIN, 18)); # lbl_close.setBounds(1071, 0, 37, 27); # contentPane.add(lbl_close); lblPxf = JLabel("Base Temperature (F):") lblPxf.setToolTipText("The temperature at which melt will occur.") lblPxf.setFont(Font("Tahoma", Font.PLAIN, 12)) lblPxf.setBounds(400, 263, 132, 15) contentPane.add(lblPxf) textField_8 = JTextField() textField_8.setFont(Font("Tahoma", Font.PLAIN, 12)) textField_8.setToolTipText("The temperature at which melt will occur.") textField_8.setText("32.0") textField_8.setBounds(548, 263, 40, 20) contentPane.add(textField_8) textField_8.setColumns(10) chckbxShowLocationPlot = JCheckBox("Plot Locations") chckbxShowLocationPlot.setToolTipText( "Will plot the Temp, Precip, SWE, ATI, and Melt for each selected location." ) chckbxShowLocationPlot.setSelected(True) chckbxShowLocationPlot.setBackground(Color.WHITE) chckbxShowLocationPlot.setFont(Font("Tahoma", Font.PLAIN, 12)) chckbxShowLocationPlot.setBounds(547, 310, 120, 23) contentPane.add(chckbxShowLocationPlot) lblEvents = JLabel("Paired Data") lblEvents.setBounds(270, 346, 72, 15) contentPane.add(lblEvents) lblEvents.setFont(Font("Tahoma", Font.PLAIN, 12)) # lblAtiThreshold = JLabel("ATI Threshold:"); # lblAtiThreshold.setToolTipText("Some Melt Events are small & can be ignored. The ATI Threshold is a value that must be reached for the event to be listed."); # lblAtiThreshold.setFont(Font("Tahoma", Font.PLAIN, 12)); # lblAtiThreshold.setBounds(500, 610, 82, 15); # contentPane.add(lblAtiThreshold); # textField_9 = JTextField(); # textField_9.setFont(Font("Tahoma", Font.PLAIN, 12)); # textField_9.setText("0.0"); # textField_9.setToolTipText("Some Melt Events are small & can be ignored. The ATI Threshold is a value that must be reached for the event to be listed."); # textField_9.setColumns(10); # textField_9.setBounds(600, 608, 60, 20); # contentPane.add(textField_9); btnPlot = JButton(btnIcon, actionPerformed=plotPDBtnSelect) btnPlot.setText("Plot Paired Data") btnPlot.setFont(Font("Tahoma", Font.BOLD, 12)) btnPlot.setForeground(Color.WHITE) btnPlot.setBackground(Color.WHITE) btnPlot.setBorderPainted(False) btnPlot.setContentAreaFilled(False) btnPlot.setFocusPainted(False) btnPlot.setOpaque(False) btnPlot.setVerticalTextPosition(SwingConstants.CENTER) btnPlot.setHorizontalTextPosition(SwingConstants.CENTER) btnPlot.setBounds(385, 657, 163, 54) contentPane.add(btnPlot) lblAtimeltrateTable = JLabel("ATI-Meltrate Table") lblAtimeltrateTable.setFont(Font("Tahoma", Font.PLAIN, 12)) lblAtimeltrateTable.setBounds(708, 10, 410, 15) contentPane.add(lblAtimeltrateTable) lblAtimeltrateTable2 = JLabel( "The first ATI value should be 0. ATI values must be ascending.") lblAtimeltrateTable2.setFont(Font("Tahoma", Font.PLAIN, 11)) lblAtimeltrateTable2.setBounds(708, 30, 410, 15) contentPane.add(lblAtimeltrateTable2) btnCalculateMeltrate = JButton(btnIcon, actionPerformed=calcMeltRateBtnSelect) btnCalculateMeltrate.setText("Calculate Meltrate") btnCalculateMeltrate.setFont(Font("Tahoma", Font.BOLD, 12)) btnCalculateMeltrate.setToolTipText( "Calculate Meltrate for ATI values in the ATI-Meltrate Table. Calculation will performed on the Paired Data Records Selected in the Paired Data Table." ) btnCalculateMeltrate.setForeground(Color.WHITE) btnCalculateMeltrate.setBackground(Color.WHITE) btnCalculateMeltrate.setBorderPainted(False) btnCalculateMeltrate.setContentAreaFilled(False) btnCalculateMeltrate.setFocusPainted(False) btnCalculateMeltrate.setOpaque(False) btnCalculateMeltrate.setVerticalTextPosition(SwingConstants.CENTER) btnCalculateMeltrate.setHorizontalTextPosition(SwingConstants.CENTER) btnCalculateMeltrate.setBounds(792, 657, 163, 54) contentPane.add(btnCalculateMeltrate) frame.setVisible(True) dssFile.close()
#Define a material for the inclusions inclusion_material = Materials.MaterialFactory.createMaterial( Materials.materials.ELASTIC, name='Inclusion', youngs_modulus=2000, poissons_ratio=0.3) inclusion_mesh = [Mesh.Mesh(elem_shape=abaqusConstants.QUAD)] * NUM_INCLUSIONS #This is going to use the same material for all inclusions inclusion_materials = [inclusion_material] * NUM_INCLUSIONS #Create the distribution and location to use, and generate the inclusions dist = SizeDistributions.Ellipse.Constant(0.3, 0.15, NUM_INCLUSIONS) loc = Locations.FixedLocation(generate_lattice=True, num_locations=NUM_INCLUSIONS) ellipses = Locations.Location.GenerateInclusions( NUM_INCLUSIONS, dist, loc, inclusion_materials, inclusion_shape=Shapes.shapes.ELLIPSE, recurse_attempts=10) inclusions = zip(ellipses, inclusion_mesh) #Output the details of the generated shapes. It will be located in the directory the script is run from(should eb the abaqus temp directory export_str = Shapes.Ellipse.ExportInclusions(ellipses) with open("geometry.txt", "w") as text_file: text_file.write(export_str)
try: import Tkinter as tk except ImportError: import tkinter as tk try: import ttk py3 = False except ImportError: import tkinter.ttk as ttk py3 = True def init(top, gui, *args, **kwargs): global w, top_level, root w = gui top_level = top root = top def destroy_window(): # Function which closes the window. global top_level top_level.destroy() top_level = None if __name__ == '__main__': import Locations Locations.vp_start_gui()
def __init__(self): self.lastLocations = Locations.Locations() self.home1 = HomeRobot() self.sampling = False
collapsednames = NER.filter_sender(collapsednames, text) speakers = [] if collapsednames != {}: speakerdict = NER.pick_speakers(collapsednames, text) for num in speakerdict: speakers.extend(collapsednames[num]) print "SPEAKERS:" print speakers # for speaker in speakers: text = Tagger.find_and_tag(speakers, "speaker", text) #Location Tagging print "Locations found:" locations = Locations.get_all_locations(text) for loc in locations: print " " + loc print "Selected locations:" selectedlocs = Locations.pick_locations(locations, text) for loc in selectedlocs: print " " + loc text = Tagger.find_and_tag(selectedlocs, "location", text) print "Topic:" text = Tagger.add_ontology_tag(text) print "final text:" print text
def location_tracking(): import Locations C7 = Locations.vp_start_gui()