def main(): #Get the relative directory of the repo or modify repo_parent_dir current_directory = os.path.dirname(os.path.abspath(__file__)) parent_directory = os.path.abspath(os.path.split(current_directory)[0]) c_d = parent_directory for i in range(2): repo_parent_dir = os.path.split(c_d)[0] c_d = repo_parent_dir print("Loading from: " + repo_parent_dir) #repo_paent_dir = r"F:\residential_wearable_data_repo_with_location_labels" #Examples of loading the data living_exp = os.path.join(repo_parent_dir, "house_A", "experiments", "living_1") #load all measurement data rssi = load_exp_data(living_exp) #load unwrapped acc data acc = load_acc(living_exp) #Load annotations ann = load_annotations(living_exp) #observe_rssi_data at a tag location plot_tag_distribution(rssi, acc, ann, 14, ap_=1) #Create a house object. house_dir = os.path.join(repo_parent_dir, "house_A", "metadata") hO = house.house(house_dir) plot_room_annotations(rssi, acc, ann, hO, "living_area") #observe_rssi_data at all tags in bedroom plot_room_distribution(rssi, acc, ann, hO, "living_area", ap_=1) #Plot the floor plan of this house hO.plot_tags_aps( os.path.join(parent_directory, "temp_plot", "home_A_plots")) plt.close("all") house_dir = os.path.join(repo_parent_dir, "house_B", "metadata") hO = house.house(house_dir) hO.plot_tags_aps( os.path.join(parent_directory, "temp_plot", "home_B_plots")) plt.close("all") house_dir = os.path.join(repo_parent_dir, "house_C", "metadata") hO = house.house(house_dir) hO.plot_tags_aps( os.path.join(parent_directory, "temp_plot", "home_C_plots")) plt.close("all") house_dir = os.path.join(repo_parent_dir, "house_C", "metadata") hO = house.house(house_dir) hO.plot_tags_aps( os.path.join(parent_directory, "temp_plot", "home_D_plots")) plt.close("all")
def test_max_wifis(self): test_house = house() test_house.add_access_point(1,1) test_house.add_access_point(2,2) test_house.add_access_point(3,3) with self.assertRaises(Exception): test_house.add_access_point(4,4)
def lsqr(A, b): m = A.shape[0] n = A.shape[1] Q, R = house(A) Ap = R[0:n, 0:n] bpp = np.dot(np.transpose(Q), b) bp = bpp[0:n] x = np.copy(bp) for i in range(n - 1, -1, -1): for j in range(i + 1, n): x[i] = x[i] - Ap[i][j] * x[j] x[i] = x[i] / Ap[i][i] e = LA.norm(bpp[n:m]) return x, e
def __init__(self, game, rows, columns): self.hauntedHouses = rows * columns; #houses = [[house() for x in range(columns)] for y in range(rows)]; #This nested for loop will fill the board with new houses in a grid. Observable.__init__(self); r = rows c = columns self.add_observer(game); for x in range(0, c): self.houses.append([]); for y in range(0, r): newHome = house(self, x, y); newHome.add_observer(self); self.houses[x].append(newHome); self.hauntedHouses = self.hauntedHouses + 1;
def test_coordinate_calc(self): test_house = house() test_house.add_access_point(0,0) test_house.add_access_point(16,0) test_house.add_access_point(8,16) result = test_house.get_coordinate(10,10,10) plt.plot(result[0], result[1], 'bo') plt.plot(test_house.access_points[0].x, test_house.access_points[0].y, 'ro') plt.plot(test_house.access_points[1].x, test_house.access_points[1].y, 'ro') plt.plot(test_house.access_points[2].x, test_house.access_points[2].y, 'ro') plt.xlabel('x') plt.ylabel('y') plt.savefig("location_test") plt.clf() test_house.save_house('load_test.txt') house_2 = house.load_house('load_test.txt') self.assertEqual(result[0], 8) self.assertEqual(result[1], 6)
def run(): LineFollow() house()
def addHouse(self, hID): self.houses[hID] = house(hID)
def main(): house_param = load_config("config2R2C.yml") days_sim = house_param['timing']['days_sim'] CF = house_param['ventilation']['CF'] Rair_wall, Cwall, Rair_outdoor, Cair = calculateRC(house_param) print('Simulation days:', days_sim) df_nen = nen5060_to_dataframe() df_irr = run_qsun(df_nen) #df_weeks = read_week('NEN_data') print(df_irr.head()) time_sim = df_irr.iloc[0:days_sim * 24, 0].values Qsolar = (df_irr.total_E * house_param['glass']['E'] + df_irr.total_SE * house_param['glass']['SE'] + df_irr.total_S * house_param['glass']['S'] + df_irr.total_SW * house_param['glass']['SW'] + df_irr.total_W * house_param['glass']['W'] + df_irr.total_NW * house_param['glass']['NW'] + df_irr.total_N * house_param['glass']['N'] + df_irr.total_NE * house_param['glass']['NE']).values Qsolar *= house_param['glass']['g_value'] Qsolar_sim = Qsolar[0:days_sim * 24] #print(len(Qsolar_sim)) Qint = internal_heat_gain(house_param['internal']['Q_day'], house_param['internal']['delta_Q'], house_param['internal']['t1'], house_param['internal']['t2']) Qinternal_sim = Qint[0:days_sim * 24] Toutdoor = df_nen.loc[:, 'temperatuur'].values / 10.0 # temperature T_outdoor_sim = Toutdoor[0:days_sim * 24] #plt.plot(T_outdoor_sim) week_day_setpoint = thermostat_sp( house_param['setpoint']['t1'], house_param['setpoint']['t2'], house_param['setpoint']['Night_T_SP'], house_param['setpoint']['Day_T_SP'], house_param['setpoint']['Flex_T_SP_workday'], house_param['setpoint']['Wu_time'], house_param['setpoint']['Work_time'], house_param['setpoint']['back_home_from_work']) day_off_setpoint = thermostat_sp( house_param['setpoint']['t1'], house_param['setpoint']['t2'], house_param['setpoint']['Night_T_SP'], house_param['setpoint']['Day_T_SP'], house_param['setpoint']['Flex_T_SP_dayoff'], house_param['setpoint']['Wu_time'], house_param['setpoint']['shopping_time'], house_param['setpoint']['back_home']) SP = SP_profile(week_day_setpoint, day_off_setpoint) #SP = temp_sp(house_param['setpoint']['t1'], # house_param['setpoint']['t2'], # house_param['setpoint']['Night_T_SP'], # house_param['setpoint']['Day_T_SP'], # house_param['setpoint']['Wu_time'], # house_param['setpoint']['Work_time'], # house_param['setpoint']['back_home']) SP_sim = SP[0:days_sim * 24] # addition NTA8800 house model # Controller value kp = house_param['controller']['kp'] # solve ODE data = house(T_outdoor_sim, Qinternal_sim, Qsolar_sim, SP_sim, time_sim, CF, Rair_outdoor, Rair_wall, Cair, Cwall, kp) # plot the results plt.figure(figsize=(15, 5)) # key-value pair: no spaces plt.plot(data[0], label='Tair') plt.plot(data[1], label='Twall') plt.plot(SP_sim, label='SP_Temperature') # plt.plot(T_outdoor_sim,label='Toutdoor') plt.legend(loc='best') plt.show() '''
def getResultsAndSave(url_base): data_list = [] house_list = [] # This will remove weird characters that people put in titles like ****!***!!! use_chars = string.ascii_letters + ''.join([str(i) for i in range(10)]) + ' ' link_list = [] # We'll store the data here resp = requests.get(url_base) #(url) txt = bs4(resp.text, 'html.parser') apts = txt.findAll(attrs={'class': "result-info"}) # We're just going to pull the title and link for apt in apts: #[:2]: house_ins = None try: price_apt = apt.find_all('span', attrs={'class': 'result-price'}) price_soup = BeautifulSoup(str(price_apt), 'html.parser') print(price_soup.text) title = apt.find_all('a', attrs={'class': 'result-title hdrlnk'})[0] #title_soup = BeautifulSoup(title.text, 'html.parser') name = ''.join([i for i in title.text if i in use_chars]) link = title.attrs['href'] #link_all.append([link]) #name_all.append([name]) # Check if there is not result price yet, get it from different way #if(len(price_apt) > 0 ): # price_all.append([price_soup.text]) print(name) print(price_apt) if link not in link_list: url_each = "" #url_each = base_url+link url_each = url_base + link if (link.startswith("http")): url_each = link print(url_each) house_ins = house.house(link) house_ins.setTitle(name) # Open each link, get its response and parse it resp_each = requests.get(url_each) txt = bs4(resp_each.text, 'html.parser') # Get it from different method price_found = getPriceFromText(price_apt, txt) house_ins.setPrice(price_found) #price_all.append(price_found) txt_attr = txt.find_all('p', attrs={'class': 'attrgroup'}) txt_attr_utils = [] bedbathsoup = "" sqftsoup = "" availabledatesoup = "" location = [] descr = "" for att_utils in txt_attr: util_each = att_utils.find_all('span') utilitiessoup = BeautifulSoup(str(util_each), 'html.parser') #print "55555" txt_attr_utils.append(utilitiessoup.text) #print (1111) house_ins.setUtilities(''.join(txt_attr_utils)) for utils in txt_attr_utils: utilList = utils.split(",") for util in utilList: print(util) if ("BR / " in util): bedbathsoup = util elif ("ft2" in util): sqftsoup = util elif ("available" in util): availabledatesoup = util if (len(availabledatesoup) == 0): availabledatesoup = "No available date" house_ins.setAvailability( availabledatesoup) # availabledatesoup if (len(sqftsoup) == 0): sqftsoup = "No sqft found" house_ins.setSqft(sqftsoup) if (len(bedbathsoup) == 0): bedbathsoup = "No bed bath found" house_ins.setBedBath(bedbathsoup) locations = txt.find_all('div', attrs={'id': 'map'}) #print(locations) #house_ins.setBedBath("BedBath") if (len(locations) > 0): house_ins.setLatitutde(locations[0].get('data-latitude')) house_ins.setLongitude(locations[0].get('data-longitude')) else: house_ins.setLatitutde("No latitude") house_ins.setLongitude("No longitude") desc_all = txt.find_all('meta', attrs={'property': 'og:description'}) #,limit=1) desc = [] for desc_each in desc_all: desc.append(desc_each.get('content')) print("******") if (len(desc) > 0): house_ins.setDesc(desc) else: house_ins.setDesc("No Desc found") descr = desc[0] except Exception as e: print("Error occured", e) pass if house_ins is None: pass else: house_list.append(house_ins) return house_list
# - справа от дома - дерево (можно несколько) # - справа в небе - радуга, слева - солнце (весна же!) # пример см. lesson_005/results/04_painting.jpg # Приправить своей фантазией по вкусу (коты? коровы? люди? трактор? что придумается) import simple_draw as sd from house import house from picture_items.tree import forest from picture_items import sky_item as sky_item from picture_items import smile as smile from picture_items.snow import snowbank sd.resolution = (1200, 600) sd.background_color = (255, 255, 255) sky_item.sky(start_y=100) sky_item.sun(75, 525, 50) sky_item.rainbow(start_x=200, radius=800) house(250, 300, 180) smile.smile(400, 100, 40, 7) forest(650, 100, 3) snowbank(150, 210) sd.pause() # Усложненное задание (делать по желанию) # Анимировать картину. # Пусть слева идет снегопад, радуга переливается цветами, смайлик моргает, солнце крутит лучами, етс. # Задержку в анимировании все равно надо ставить, пусть даже 0.01 сек - так библиотека устойчивей работает. #зачет!
from house import house from house import room import sys if __name__ == "__main__": test_house = house() while True: print("1. Add room") print("2. Get room from coordinate") print("3. Get closest room center from coordinate") print("4. List all rooms") print("5. exit") choice = int(input()) if choice == 1: x = int(input("enter top left x ")) y = int(input("enter top left y ")) tl = (x, y) x = int(input("enter top right x ")) y = int(input("enter top right y ")) tr = (x, y) x = int(input("enter bottom left x ")) y = int(input("enter bottom left y ")) bl = (x, y) x = int(input("enter bottom right x ")) y = int(input("enter bottom right y ")) br = (x, y)
import matplotlib.pyplot as plt import house as house import parameters as par import internal_heat_gain as ihg import Temperature_SP as sp #from house_model.house import house #Define Simulation time days_Sim = 25 #number of simulation days time_sim = par.time[0:days_Sim*24] Qsolar_Sim = par.Qsolar[0:days_Sim*24] Qinternal_Sim = ihg.Qinternal[0:days_Sim*24] #Qinst_Sim = Qinst_Sim[0:days_Sim*24][:,0] T_outdoor_Sim = par.Toutdoor_p[0:days_Sim*24] CF =par.CF Rair_outdoor=par.Rair_outdoor Rair_wall=par.Rair_wall Cair=par.Cair Cwall=par.Cwall #Set point SP_Sim=sp.SP[0:days_Sim*24] data = house.house(T_outdoor_Sim,Qinternal_Sim,Qsolar_Sim,SP_Sim,time_sim,CF,Rair_outdoor,Rair_wall,Cair,Cwall)
def test_add_wifis(self): test_house = house() test_house.add_access_point(1,1) test_house.add_access_point(2,2) test_house.add_access_point(3,3) self.assertEqual(len(test_house.access_points), 3)
def test_closest_center(self): test_house = house() test_house.add_room(room((1,1),2,2,1)) test_house.add_room(room((3.5,3.5),1,1,2)) test_house.save_house() self.assertEqual(test_house.get_closest_room_center(3,3)[0].ID, 2)
def test_in_room(self): test_house = house() test_house.add_room(room((1,1),2,2,1)) test_house.add_room(room((3.5,3.5),1,1,2)) self.assertEqual(test_house.get_room(1,1).ID, 1)
def test_add_rooms(self): test_house = house() test_house.add_room(room((1,1),2,2,1)) test_house.add_room(room((3.5,3.5),1,1,2)) self.assertEqual(len(test_house.rooms), 2)