/* * private void MakeHeatingDensityMap([NotNull] ScenarioSliceParameters up,[ItemNotNull] [NotNull] List<House> houses, * [NotNull] MyDb dbHouses ) * { * const string section = "Heizungseffizienz [kWh/m2/a]"; * const string sectionDescription = "Heizungseffizenz über alle Gebäude"; * //heating energy density * //var heatingMethods = dbHouses.Fetch<HouseHeating>(); * var heatingEnergyPoints = new List<MapPoint>(); * double adjustmentFactor = houses.Max(x => x.MergedTotalHeatingEnergyDemand)/100; * foreach (var house in houses) { * if (house.GeoCoords.Count == 0) { * continue; * } * * //var hm = heatingMethods.FirstOrDefault(x => x.HouseGuid == house.HouseGuid); * * var co = house.GeoCoords[0]; * var adjustedRadius = (int)(house.MergedTotalHeatingEnergyDemand / adjustmentFactor); * heatingEnergyPoints.Add(new MapPoint(co.X, co.Y, house.MergedHeatingEnergyIntensity, adjustedRadius)); * } * * string dstFileName2 = dbHouses.GetFullFilename(up.GetFileName() + "_HeatDensity_Map.svg",SequenceNumber,Name); * ResultFileEntry rfe2 = new ResultFileEntry(section, sectionDescription, dstFileName2.Replace(".svg", ".png"), * "", "", up.DstScenario, up.DstYear, Stage.PresentVisualisation); * rfe2.Save(); * Services.MapDrawer.DrawMapSvg(heatingEnergyPoints, dstFileName2, new List<MapLegendEntry>()); * Log(MessageType.Info, "Heat Density Maps written"); * }*/ /* * private void MakeCarMaps([NotNull] ScenarioSliceParameters up, [NotNull] MyDb dbHouses, [ItemNotNull] [NotNull] List<House> houses) * { * var cars = dbHouses.Database.Fetch<Car>(); * if (cars.Count == 0) * { * return; * } * * var carPoints = new List<MapPoint>(); * foreach (House house in houses) * { * if (house.GeoCoords.Count == 0) * { * continue; * } * * var carsAtHouse = cars.Where(x => x.HouseGuid == house.HouseGuid).ToList(); * * bool hasElectric = carsAtHouse.Any(x => x.CarType == CarType.Electric); * var co = house.GeoCoords[0]; * if (carsAtHouse.Count == 0) { * carPoints.Add(new MapPoint(co.X, co.Y, 10, 0, 0, 0)); * } * else { * int radius = 10+ carsAtHouse.Count; * if (!hasElectric) { * carPoints.Add(new MapPoint(co.X, co.Y, radius, 255, 0, 0)); * } * else { * carPoints.Add(new MapPoint(co.X, co.Y, radius, 0, 255, 0)); * } * } * } * if (carPoints.Count == 0) { * throw new Exception("No points"); * } * * const string section = "Fahrzeuge"; * const string sectionDescription = "Typ und Anzahl von Fahrzeugen"; * * string dstFileName2 = dbHouses.GetFullFilename(up.GetFileName() + "_Cars_Map.svg",SequenceNumber,Name); * ResultFileEntry rfe2 = new ResultFileEntry(section, sectionDescription, dstFileName2.Replace(".svg", ".png"), * "", "", up.DstScenario, up.DstYear, Stage.PresentVisualisation); * rfe2.Save(); * Services.MapDrawer.DrawMapSvg(carPoints, dstFileName2, new List<MapLegendEntry>()); * Log(MessageType.Info, "Car Maps written"); * }*/ /* * private void MakeHeatingSystemMap([NotNull] ScenarioSliceParameters up, [NotNull] MyDb dbHouses, [ItemNotNull] [NotNull] List<House> houses) * { * var heatingSystemEntries = dbHouses.Database.Fetch<HeatingSystemEntry>(); * if (heatingSystemEntries.Count == 0) * { * return; * } * * var pvPoints = new List<MapPoint>(); * foreach (House house in houses) { * if (house.GeoCoords.Count == 0) * { * continue; * } * List<HeatingSystemEntry> hses = new List<HeatingSystemEntry>(); * var entry = heatingSystemEntries.FirstOrDefault(x => x.HouseGuid == house.HouseGuid); * if (entry != null) { * hses.Add(entry); * } * * if(hses.Count == 0) { * continue; * } * * bool hasHP = hses.Any(x => x.HeatingSystemType == HeatingSystemType.Heatpump); * bool hasGas = hses.Any(x => x.HeatingSystemType == HeatingSystemType.Gasheating); * bool hasOil = hses.Any(x => x.HeatingSystemType == HeatingSystemType.OilHeating); * * var co = house.GeoCoords[0]; * if(hasHP) { * pvPoints.Add(new MapPoint(co.X, co.Y, 10,255,0,0)); * } * else if(hasGas) { * pvPoints.Add(new MapPoint(co.X, co.Y, 10, 0, 255, 0)); * } * else if (hasOil) { * pvPoints.Add(new MapPoint(co.X, co.Y, 10, 0, 0, 255)); * } * else { * pvPoints.Add(new MapPoint(co.X, co.Y, 10, 0, 0, 0)); * } * * } * if(pvPoints.Count == 0) { * throw new Exception("No points"); * } * * const string section = "Heizungssysteme"; * const string sectionDescription = "Art des Heizungssystems"; * string dstFileName2 = dbHouses.GetFullFilename( up.GetFileName() + "_HeatingSystem_Map.svg",SequenceNumber,Name); * ResultFileEntry rfe2 = new ResultFileEntry(section, sectionDescription, dstFileName2.Replace(".svg", ".png"), * "", "", up.DstScenario, up.DstYear, Stage.PresentVisualisation); * rfe2.Save(); * Services.MapDrawer.DrawMapSvg(pvPoints, dstFileName2, new List<MapLegendEntry>()); * Log(MessageType.Info, "PV Maps written"); * }*/ private void MakePVMap([NotNull] ScenarioSliceParameters parameters, [NotNull] MyDb dbHouses, [ItemNotNull][NotNull] List <House> houses) { var pvSystems = dbHouses.Database.Fetch <PvSystemEntry>(); if (pvSystems.Count == 0) { return; } var adjustmentfactor = pvSystems.Max(x => x.YearlyPotential) / 100; var pvPoints = new List <MapPoint>(); foreach (var house in houses) { if (house.WgsGwrCoords.Count == 0) { continue; } var co = house.WgsGwrCoords[0]; var pvSystem = pvSystems.FirstOrDefault(x => x.HouseGuid == house.HouseGuid); if (pvSystem != null) { var radius = (int)(pvSystem.YearlyPotential / adjustmentfactor); if (radius < 10) { radius = 10; } pvPoints.Add(new MapPoint(co.Lat, co.Lon, radius, 255, 0, 0)); } else { pvPoints.Add(new MapPoint(co.Lat, co.Lon, 10, 0, 0, 0)); } } const string section = "Photovoltaik"; const string sectionDescription = "Leistung der PV-Systeme"; var dstFileName2 = dbHouses.GetFullFilename(parameters.GetFileName() + "_PV_power_Map.svg", SequenceNumber, Name); var rfe2 = new ResultFileEntry(section, sectionDescription, dstFileName2.Replace(".svg", ".png"), "", "", parameters, MyStage); rfe2.Save(); var lge = new List <MapLegendEntry> { new MapLegendEntry(parameters.DstScenario.ToString() + " Jahr " + parameters.DstYear.ToString(), Constants.Black) }; Services.MapDrawer.DrawMapSvg(pvPoints, dstFileName2, lge, MyStage); Log(MessageType.Info, "PV Maps written"); }
private List <SingleSankeyArrow> MakeFernwärmeArrow([ItemNotNull][NotNull] List <BuildingComplex> complexes, [ItemNotNull][NotNull] List <Localnet> rawEntries, [ItemNotNull][NotNull] List <MonthlyElectricityUsePerStandort> monthlyElectricityUsePerStandorts) { var slice = Constants.PresentSlice; const string section = "Erdgas"; const string sectionDescription = "Analyse der Erdgasverbräuche"; //write python var arrows = new List <SingleSankeyArrow>(); { var arr1 = new SingleSankeyArrow("Fernwärme_NachStandorten", 2000, MyStage, SequenceNumber, Name, Services.Logger, slice); var rfe = new ResultFileEntry(section, sectionDescription, arr1.FullPngFileName(), arr1.ArrowName, "", Constants.PresentSlice, MyStage); rfe.Save(); var verbrauchsList = rawEntries.Where(x => x.Verrechnungstyp == "Arbeitspreis").ToList(); var totalSum = verbrauchsList.Select(x => { if (x.BasisVerbrauch == null) { throw new Exception("Basisverbrauch was null"); } return(x.BasisVerbrauch.Value); }).Sum(); const double factor = 1_000_000; arr1.AddEntry(new SankeyEntry("Total aus Rohdaten", totalSum / factor, 1000, Orientation.Up)); var monthlyElectricityUseNetz = monthlyElectricityUsePerStandorts.Sum(x => x.YearlyFernwaermeUse); arr1.AddEntry(new SankeyEntry("Arbeitspreis in Monthly", monthlyElectricityUseNetz / factor * -1, 1000, Orientation.Down)); arrows.Add(arr1); } { var arr1 = new SingleSankeyArrow("Fernwärme_Verbrauch_Nach_Identified_Complexed_Standort", 2000, MyStage, SequenceNumber, Name, Services.Logger, slice); var rfe = new ResultFileEntry(section, sectionDescription, arr1.FullPngFileName(), arr1.ArrowName, "", Constants.PresentSlice, MyStage); rfe.Save(); var totalSum = monthlyElectricityUsePerStandorts.Select(x => x.YearlyFernwaermeUse).Sum(); const double factor = 1_000_000; arr1.AddEntry(new SankeyEntry("Total", totalSum / factor, 1000, Orientation.Up)); var cleandStandortIDs = complexes.SelectMany(x => x.CleanedStandorte).ToList(); var identifiedComplexStandorts = monthlyElectricityUsePerStandorts.Where(x => cleandStandortIDs.Contains(x.CleanedStandort)); var identifiedmonthlygas = identifiedComplexStandorts.Sum(x => x.YearlyFernwaermeUse); arr1.AddEntry(new SankeyEntry("MonthlyElectricityUseNetz", identifiedmonthlygas / factor * -1, 1000, Orientation.Down)); arrows.Add(arr1); } { var arr1 = new SingleSankeyArrow("Fernwärme_Verbrauch_Nach_BuildingWithGeoCoords", 500, MyStage, SequenceNumber, Name, Services.Logger, slice); var rfe = new ResultFileEntry(section, sectionDescription, arr1.FullPngFileName(), arr1.ArrowName, "", Constants.PresentSlice, MyStage); rfe.Save(); var totalSum = monthlyElectricityUsePerStandorts.Select(x => x.YearlyFernwaermeUse).Sum(); const double factor = 1_000_000; arr1.AddEntry(new SankeyEntry("Fernwärmeverbrauch gesamt", totalSum / factor, 500, Orientation.Straight)); var cleandStandortIDs = complexes.Where(x => x.Coords.Count > 0).SelectMany(x => x.CleanedStandorte).ToList(); var identifiedComplexStandorts = monthlyElectricityUsePerStandorts.Where(x => cleandStandortIDs.Contains(x.CleanedStandort)); var identifiedmonthlyElectricityUseNetz = identifiedComplexStandorts.Sum(x => x.YearlyFernwaermeUse); arr1.AddEntry(new SankeyEntry("Fernwärmeverbrauch in\\n Gebäuden mit Geokoordinaten", identifiedmonthlyElectricityUseNetz / factor * -1, 200, Orientation.Straight)); var notidentified = monthlyElectricityUsePerStandorts.Where(x => !cleandStandortIDs.Contains(x.CleanedStandort)); var notidentifiedmonthlyElectricityUseNetz = notidentified.Sum(x => x.YearlyFernwaermeUse); arr1.AddEntry(new SankeyEntry("Fernwärmeverbrauch in nicht\\n zuordenbaren Gebäuden", notidentifiedmonthlyElectricityUseNetz / factor * -1, 200, Orientation.Up)); arrows.Add(arr1); } return(arrows); }
// ReSharper disable once FunctionComplexityOverflow private List <SingleSankeyArrow> MakeElectricityArrow([ItemNotNull][NotNull] List <BuildingComplex> complexes, [ItemNotNull][NotNull] List <Localnet> rawEntries, [ItemNotNull][NotNull] List <MonthlyElectricityUsePerStandort> monthlyElectricityUsePerStandorts, Stage mystage) { const string section = "Stromverbräuche"; const string sectionDescription = "Analyse der Stromverbräuche"; var slice = Constants.PresentSlice; //write python var arrows = new List <SingleSankeyArrow>(); { var arr1 = new SingleSankeyArrow("Stromkunden_Anzahl_nach_Verrechnungstyp", 20000, MyStage, SequenceNumber, Name, Services.Logger, slice); var rfe = new ResultFileEntry(section, sectionDescription, arr1.FullPngFileName(), arr1.ArrowName, "", Constants.PresentSlice, mystage); rfe.Save(); var verbrauchsList = rawEntries.Where(x => x.Verrechnungstyp == "Netz Nachtstrom (NT)" || x.Verrechnungstyp == "Netz Tagesstrom (HT)").ToList(); arr1.AddEntry(new SankeyEntry("Total", verbrauchsList.Count, 100, Orientation.Up)); var count2 = rawEntries.Count(x => x.Verrechnungstyp == "Netz Nachtstrom (NT)"); arr1.AddEntry(new SankeyEntry("Nachtstrom", count2 * -1, 100, Orientation.Up)); var countTag = rawEntries.Count(x => x.Verrechnungstyp == "Netz Tagesstrom (HT)"); arr1.AddEntry(new SankeyEntry("Tagstrom", countTag * -1, 100, Orientation.Up)); arrows.Add(arr1); } { var arr1 = new SingleSankeyArrow("Stromkunden_Verbrauch_nach_Verrechnungstyp", 2000, MyStage, SequenceNumber, Name, Services.Logger, slice); var rfe = new ResultFileEntry(section, sectionDescription, arr1.FullPngFileName(), arr1.ArrowName, "", Constants.PresentSlice, mystage); rfe.Save(); var verbrauchsList = rawEntries.Where(x => x.Verrechnungstyp == "Netz Nachtstrom (NT)" || x.Verrechnungstyp == "Netz Tagesstrom (HT)").ToList(); var totalSum = verbrauchsList.Select(x => { if (x.BasisVerbrauch == null) { throw new Exception("Basisverbrauch was null"); } return(x.BasisVerbrauch.Value); }).Sum(); const double factor = 1_000_000; arr1.AddEntry(new SankeyEntry("Total", totalSum / factor, 1000, Orientation.Up)); var sumNight = rawEntries.Where(x => x.Verrechnungstyp == "Netz Nachtstrom (NT)").Select(x => { if (x.BasisVerbrauch == null) { throw new Exception("Basisverbrauch was null"); } return(x.BasisVerbrauch.Value); }).Sum(); arr1.AddEntry(new SankeyEntry("Nachtstrom", sumNight / factor * -1, 1000, Orientation.Down)); var sumDay = rawEntries.Where(x => x.Verrechnungstyp == "Netz Tagesstrom (HT)").Select(x => { if (x.BasisVerbrauch == null) { throw new Exception("Basisverbrauch was null"); } return(x.BasisVerbrauch.Value); }).Sum(); arr1.AddEntry(new SankeyEntry("Tagstrom", sumDay / factor * -1, 1000, Orientation.Up)); arrows.Add(arr1); } { var arr1 = new SingleSankeyArrow("Stromkunden_Verbrauch_Nach_Standort", 2000, MyStage, SequenceNumber, Name, Services.Logger, slice); var rfe = new ResultFileEntry(section, sectionDescription, arr1.FullPngFileName(), arr1.ArrowName, "", Constants.PresentSlice, MyStage); rfe.Save(); var verbrauchsList = rawEntries.Where(x => x.Verrechnungstyp == "Netz Nachtstrom (NT)" || x.Verrechnungstyp == "Netz Tagesstrom (HT)").ToList(); var totalSum = verbrauchsList.Select(x => { if (x.BasisVerbrauch == null) { throw new Exception("Basisverbrauch was null"); } return(x.BasisVerbrauch.Value); }).Sum(); const double factor = 1_000_000; arr1.AddEntry(new SankeyEntry("Total", totalSum / factor, 1000, Orientation.Up)); var monthlyElectricityUseNetz = monthlyElectricityUsePerStandorts.Sum(x => x.YearlyElectricityUseNetz); arr1.AddEntry(new SankeyEntry("MonthlyElectricityUseNetz", monthlyElectricityUseNetz / factor * -1, 1000, Orientation.Down)); arrows.Add(arr1); } { var arr1 = new SingleSankeyArrow("Stromkunden_Verbrauch_Nach_Rechnungsart", 2000, MyStage, SequenceNumber, Name, Services.Logger, slice); var rfe = new ResultFileEntry(section, sectionDescription, arr1.FullPngFileName(), arr1.ArrowName, "", Constants.PresentSlice, MyStage); rfe.Save(); var verbrauchsList = rawEntries.Where(x => x.Verrechnungstyp == "Netz Nachtstrom (NT)" || x.Verrechnungstyp == "Netz Tagesstrom (HT)").ToList(); var totalSum = verbrauchsList.Select(x => { if (x.BasisVerbrauch == null) { throw new Exception("Basisverbrauch was null"); } return(x.BasisVerbrauch.Value); }).Sum(); const double factor = 1_000_000; arr1.AddEntry(new SankeyEntry("Total", totalSum / factor, 1000, Orientation.Up)); var rechungsarten = verbrauchsList.Select(x => x.Rechnungsart).Distinct().ToList(); var pathlength = 500; foreach (var rechnungsart in rechungsarten) { var rechnungsartSum = verbrauchsList.Where(x => x.Rechnungsart == rechnungsart).Select(x => { if (x.BasisVerbrauch == null) { throw new Exception("Basisverbrauch was null"); } return(x.BasisVerbrauch.Value); }).Sum(); arr1.AddEntry(new SankeyEntry(rechnungsart, rechnungsartSum / factor * -1, pathlength, Orientation.Down)); pathlength += 500; } arrows.Add(arr1); } { var arr1 = new SingleSankeyArrow("Stromkunden_Verbrauch_Nach_Identified_Complexed_Standort", 2000, MyStage, SequenceNumber, Name, Services.Logger, slice); var rfe = new ResultFileEntry(section, sectionDescription, arr1.FullPngFileName(), arr1.ArrowName, "", Constants.PresentSlice, MyStage); rfe.Save(); var totalSum = monthlyElectricityUsePerStandorts.Select(x => x.YearlyElectricityUseNetz).Sum(); const double factor = 1_000_000; arr1.AddEntry(new SankeyEntry("Total", totalSum / factor, 1000, Orientation.Up)); var cleandStandortIDs = complexes.SelectMany(x => x.CleanedStandorte).ToList(); var identifiedComplexStandorts = monthlyElectricityUsePerStandorts.Where(x => cleandStandortIDs.Contains(x.CleanedStandort)); var identifiedmonthlyElectricityUseNetz = identifiedComplexStandorts.Sum(x => x.YearlyElectricityUseNetz); arr1.AddEntry(new SankeyEntry("MonthlyElectricityUseNetz", identifiedmonthlyElectricityUseNetz / factor * -1, 1000, Orientation.Down)); arrows.Add(arr1); } { var arr1 = new SingleSankeyArrow("Stromkunden_Verbrauch_Nach_BuildingWithGeoCoords", 500, MyStage, SequenceNumber, Name, Services.Logger, slice); var rfe = new ResultFileEntry(section, sectionDescription, arr1.FullPngFileName(), arr1.ArrowName, "", Constants.PresentSlice, MyStage); rfe.Save(); var totalSum = monthlyElectricityUsePerStandorts.Select(x => x.YearlyElectricityUseNetz).Sum(); const double factor = 1_000_000; arr1.AddEntry(new SankeyEntry("Stromverbrauch gesamt", totalSum / factor, 500, Orientation.Straight)); var cleandStandortIDs = complexes.Where(x => x.Coords.Count > 0).SelectMany(x => x.CleanedStandorte).ToList(); var identifiedComplexStandorts = monthlyElectricityUsePerStandorts.Where(x => cleandStandortIDs.Contains(x.CleanedStandort)); var identifiedmonthlyElectricityUseNetz = identifiedComplexStandorts.Sum(x => x.YearlyElectricityUseNetz); arr1.AddEntry(new SankeyEntry("Stromverbrauch in\\n Gebäuden mit Geokoordinaten", identifiedmonthlyElectricityUseNetz / factor * -1, 200, Orientation.Straight)); var notidentified = monthlyElectricityUsePerStandorts.Where(x => !cleandStandortIDs.Contains(x.CleanedStandort)); var notidentifiedmonthlyElectricityUseNetz = notidentified.Sum(x => x.YearlyElectricityUseNetz); arr1.AddEntry(new SankeyEntry("Stromverbrauch in nicht\\n zuordenbaren Gebäuden", notidentifiedmonthlyElectricityUseNetz / factor * -1, 200, Orientation.Up)); arrows.Add(arr1); } return(arrows); }