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); }