def scenario(request): scenario = Scenario.objects.all()[0] current_neighborhood_name = scenario.current_neighborhood current_neighborhood = Neighborhood.objects.get(neighborhood_name=current_neighborhood_name) energy_price_data = [] for energy_price in current_neighborhood.energyprice_set.all(): energy_price_data.append([(float(energy_price.time) - 1.0) / 4.0, float(energy_price.price)*1000.0]) solar_data = [] wind_data = [] for available_energy in current_neighborhood.availableenergy_set.all(): solar_data.append([(float(available_energy.time) - 1.0) / 4.0, float(available_energy.amount)/1000.0]) wind_data.append([(float(available_energy.time) - 1.0) / 4.0, float(available_energy.wind)/1000.0]) available_energy_list = [{"name": "Verwachte zonne-energie", "data": solar_data}, {"name": "Verwachte windenergie", "data": wind_data}] consumption_list = [] for house in current_neighborhood.house_set.all(): name = house.house_name data = map(lambda x: [x[0], x[1]/1000.0], utilities.get_consumption(house)) consumption_list.append({"name": name, "data": data}) # consumption_list.append({"name": "Volledige buurt", "data": utilities.get_consumption(), "linewidth": 5}) if not current_neighborhood_name.endswith("zonder vraagzijdesturing"): neighborhood_geen_sturing = Neighborhood.objects.get( neighborhood_name=current_neighborhood_name + " zonder vraagzijdesturing") consumption_list.append({"name": "Zonder vraagzijdesturing", "data": map(lambda x: [x[0], x[1]/1000.0], utilities.get_consumption(neighborhood=neighborhood_geen_sturing))}) else: neighborhood_met_sturing = Neighborhood.objects.get(neighborhood_name=current_neighborhood_name[0:7]) consumption_list.append({"name": "Met vraagzijdesturing", "data": map(lambda x: [x[0], x[1]/1000.0], utilities.get_consumption(neighborhood=neighborhood_met_sturing))}) wrong_neighborhood_list = Neighborhood.objects.all() store = wrong_neighborhood_list.filter(neighborhood_name='Store')[0] een_zonder = wrong_neighborhood_list.filter(neighborhood_name='Buurt 1 zonder vraagzijdesturing')[0] twee_zonder = wrong_neighborhood_list.filter(neighborhood_name='Buurt 2 zonder vraagzijdesturing')[0] neighborhood_list = [] for x in wrong_neighborhood_list: if x.neighborhood_name != store.neighborhood_name \ and x.neighborhood_name != een_zonder.neighborhood_name \ and x.neighborhood_name != twee_zonder.neighborhood_name: neighborhood_list += [x] print neighborhood_list return render(request, 'smartgrid/post_login/scenario.html', {'current_neighborhood_name': current_neighborhood_name, 'energy_price_data': energy_price_data, 'available_energy_list': available_energy_list, 'consumption_list': consumption_list, 'neighborhood_list': neighborhood_list})
def resultaat(request): eff_buurt = Neighborhood.objects.get(neighborhood_name="Buurt 1") eff_buurt_zonder = Neighborhood.objects.get(neighborhood_name="Buurt 1 zonder vraagzijdesturing") ineff_buurt = Neighborhood.objects.get(neighborhood_name="Buurt 2") ineff_buurt_zonder = Neighborhood.objects.get(neighborhood_name="Buurt 2 zonder vraagzijdesturing") energy_price_data_1 = [] for energy_price in eff_buurt.energyprice_set.all(): energy_price_data_1.append([(float(energy_price.time) - 1.0) / 4.0, float(energy_price.price) * 1000]) solar_data_1 = [] wind_data_1 = [] for available_energy in eff_buurt.availableenergy_set.all(): solar_data_1.append([(float(available_energy.time) - 1.0) / 4.0, float(available_energy.amount)/1000.0]) wind_data_1.append([(float(available_energy.time) - 1.0) / 4.0, float(available_energy.wind)/1000.0]) available_energy_list_1 = [{"name": "Beschikbare zonne-energie", "data": solar_data_1, "color": "#8A3528"}, {"name": "Beschikbare windenergie", "data": wind_data_1, "color": "#C54C3A"}] energy_price_data_2 = [] for energy_price in eff_buurt.energyprice_set.all(): energy_price_data_2.append([(float(energy_price.time) - 1.0) / 4.0, float(energy_price.price)]) solar_data_2 = [] wind_data_2 = [] for available_energy in ineff_buurt.availableenergy_set.all(): solar_data_2.append([(float(available_energy.time) - 1.0) / 4.0, float(available_energy.amount)]) wind_data_2.append([(float(available_energy.time) - 1.0) / 4.0, float(available_energy.wind)]) available_energy_list_2 = [{"name": "Beschikbare zonne-energie", "data": solar_data_2, "color": "#8A3528"}, {"name": "Beschikbare windenergie", "data": wind_data_2, "color": "#C54C3A"}] consumption_list_1 = [] consumption_list_1.append({"name": "Met vraagzijdesturing", "data": map(lambda x: [x[0], x[1] / 1000.0], utilities.get_consumption(neighborhood=eff_buurt))}) consumption_list_1.append({"name": "Zonder vraagzijdesturing", "data": map(lambda x: [x[0], x[1] / 1000.0], utilities.get_consumption(neighborhood=eff_buurt_zonder))}) consumption_list_2 = [] consumption_list_2.append({"name": "Met vraagzijdesturing", "data": map(lambda x: [x[0], x[1] / 1000.0], utilities.get_consumption(neighborhood=ineff_buurt))}) consumption_list_2.append({"name": "Zonder vraagzijdesturing", "data": map(lambda x: [x[0], x[1] / 1000.0], utilities.get_consumption(neighborhood=ineff_buurt_zonder))}) return render(request, 'smartgrid/info/resultaat.html', {'consumption_list_1': consumption_list_1, 'consumption_list_2': consumption_list_2, 'available_energy_list_1': available_energy_list_1, 'available_energy_list_2': available_energy_list_2, 'energy_price_data_1': energy_price_data_1, 'energy_price_data_2': energy_price_data_2})