protected override void RunActualProcess([NotNull][ItemNotNull] List <ScenarioSliceParameters> allSlices)
        {
            Info("starting to make house results");
            LineSeriesEntry housesCount     = new LineSeriesEntry("Häuser");
            LineSeriesEntry householdsCount = new LineSeriesEntry("Haushalte");
            LineSeriesEntry occupantsCount  = new LineSeriesEntry("Bewohner");

            foreach (var slice in allSlices)
            {
                var dbh    = SqlConnection.GetDatabaseConnection(Stage.Houses, slice);
                var houses = dbh.Database.Fetch <House>();
                housesCount.Values.Add(new Point(slice.DstYear, houses.Count));

                var households = dbh.Database.Fetch <Household>();
                householdsCount.Values.Add(new Point(slice.DstYear, households.Count));

                var occupants = dbh.Database.Fetch <Occupant>();
                occupantsCount.Values.Add(new Point(slice.DstYear, occupants.Count));
            }

            var s         = allSlices.Last();
            var filename1 = MakeAndRegisterFullFilename("HousesForScenario." + s + ".png", Name, "", s);

            Services.PlotMaker.MakeLineChart(filename1, "Anzahl Häuser", housesCount, new List <PlotMaker.AnnotationEntry>());

            var filename2 = MakeAndRegisterFullFilename("HouseholdsForScenario." + s + ".png", Name, "", s);

            Services.PlotMaker.MakeLineChart(filename2, "Anzahl Haushalte", householdsCount, new List <PlotMaker.AnnotationEntry>());

            var filename3 = MakeAndRegisterFullFilename("OccupantForScenario." + s + ".png", Name, "", s);

            Services.PlotMaker.MakeLineChart(filename3, "Anzahl Einwohner", occupantsCount, new List <PlotMaker.AnnotationEntry>());
        }
Esempio n. 2
0
        private void MakeOneAnalysis([NotNull] List <double> areas, int bucketSize, [NotNull] string baseName,
                                     [NotNull] string sectionDescription, [NotNull] ScenarioSliceParameters slice)
        {
            {
                var maxArea   = areas.Max();
                var histogram = new Histogram();
                for (var i = 0; i < bucketSize * 10; i += bucketSize)
                {
                    histogram.AddBucket(new Bucket(i, i + bucketSize));
                }

                if (maxArea > bucketSize * 10)
                {
                    histogram.AddBucket(new Bucket(bucketSize * 10, maxArea));
                }

                histogram.AddData(areas);
                string histogramfilename = MakeAndRegisterFullFilename(baseName + "_Histogram.png", Name, sectionDescription, slice);
                var    bs  = BarSeriesEntry.MakeBarSeriesEntry(histogram, out var colNames);
                var    bss = new List <BarSeriesEntry> {
                    bs
                };
                Services.PlotMaker.MakeBarChart(histogramfilename, "Anzahl von Haushalten mit Fläche in diesem Bereich", bss, colNames);
            }
            {
                string dstFileName2 = MakeAndRegisterFullFilename(baseName + "_SortedAreas.png", Name, sectionDescription, slice);
                var    lse          = new LineSeriesEntry("Sorted");
                var    sorted       = areas.ToList();
                sorted.Sort();
                for (var i = 0; i < sorted.Count; i++)
                {
                    lse.Values.Add(new Point(i, sorted[i]));
                }

                var lss = new List <LineSeriesEntry> {
                    lse
                };
                Services.PlotMaker.MakeLineChart(dstFileName2, "", lss, new List <PlotMaker.AnnotationEntry>());
            }
            {
                string dstFileName2 = MakeAndRegisterFullFilename(baseName + "_Kumulativ.png", Name, sectionDescription, slice);
                var    lse          = new LineSeriesEntry("Kumulativ");
                var    sorted       = areas.ToList();
                sorted.Sort();
                double tempSum = 0;
                for (var i = 0; i < sorted.Count; i++)
                {
                    tempSum += sorted[i];
                    lse.Values.Add(new Point(i, tempSum));
                }

                var lss = new List <LineSeriesEntry> {
                    lse
                };
                Services.PlotMaker.MakeLineChart(dstFileName2, "", lss, new List <PlotMaker.AnnotationEntry>());
            }
        }
Esempio n. 3
0
        protected override void RunActualProcess([NotNull][ItemNotNull] List <ScenarioSliceParameters> allSlices, [NotNull] AnalysisRepository analysisRepo)
        {
            if (!Services.RunningConfig.MakeCharts)
            {
                return;
            }
            Info("starting to make house results");
            LineSeriesEntry housesCount     = new LineSeriesEntry("Häuser");
            LineSeriesEntry householdsCount = new LineSeriesEntry("Haushalte");
            LineSeriesEntry occupantsCount  = new LineSeriesEntry("Bewohner");
            List <ScenarioSliceParameters> missingSlices = new List <ScenarioSliceParameters>();

            foreach (var slice in allSlices)
            {
                Info("Checking for slice " + slice);
                var db = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Houses, slice);
                var fi = new FileInfo(db.DBFilename);
                if (!fi.Exists)
                {
                    missingSlices.Add(slice);
                }
            }

            if (missingSlices.Count > 0)
            {
                var    missingSliceNames = missingSlices.Select(x => x.ToString()).ToList();
                string missingSlicesStr  = string.Join("\n", missingSliceNames);
                throw new FlaException("Missing Slice Names: " + missingSlicesStr);
            }
            foreach (var slice in allSlices)
            {
                Info("Reading slice " + slice);
                var houses = analysisRepo.GetSlice(slice).Fetch <House>();
                housesCount.Values.Add(new Point(slice.DstYear, houses.Count));

                var households = analysisRepo.GetSlice(slice).Fetch <Household>();
                householdsCount.Values.Add(new Point(slice.DstYear, households.Count));

                var occupants = households.SelectMany(x => x.Occupants).ToList();
                occupantsCount.Values.Add(new Point(slice.DstYear, occupants.Count));
            }

            var s         = Constants.PresentSlice;
            var filename1 = MakeAndRegisterFullFilename("HousesForScenario." + s + ".png", s);

            Services.PlotMaker.MakeLineChart(filename1, "Anzahl Häuser", housesCount, new List <AnnotationEntry>());

            var filename2 = MakeAndRegisterFullFilename("HouseholdsForScenario." + s + ".png", s);

            Services.PlotMaker.MakeLineChart(filename2, "Anzahl Haushalte", householdsCount, new List <AnnotationEntry>());

            var filename3 = MakeAndRegisterFullFilename("OccupantForScenario." + s + ".png", s);

            Services.PlotMaker.MakeLineChart(filename3, "Anzahl Einwohner", occupantsCount, new List <AnnotationEntry>());
        }
        public void MakeLineChart([NotNull] string filename,
                                  [NotNull] string yaxislabel,
                                  [NotNull] LineSeriesEntry lineSeries,
                                  [NotNull][ItemNotNull] List <AnnotationEntry> annotations,
                                  double absoluteMinimum = 0,
                                  ExportType exportType  = ExportType.Png)
        {
            List <LineSeriesEntry> lineseriesList = new List <LineSeriesEntry> {
                lineSeries
            };

            AddThread(yaxislabel,
                      () => InternalMakeLineChart(filename, yaxislabel, lineseriesList, annotations, absoluteMinimum, exportType),
                      filename);
        }
Esempio n. 5
0
        private void MakeSortedChart([NotNull][ItemNotNull] List <MonthlyElectricityUsePerStandort> energyusePerStandort)
        {
            var electricityEntriesWithValues = energyusePerStandort.Where(x => x.YearlyElectricityUseLocalnet > 0).ToList();

            electricityEntriesWithValues.Sort((x, y) => y.YearlyElectricityUseLocalnet.CompareTo(x.YearlyElectricityUseLocalnet));
            var gasEntriesWithValues = energyusePerStandort.Where(x => x.YearlyGasUse > 0).ToList();

            gasEntriesWithValues.Sort((x, y) => y.YearlyGasUse.CompareTo(x.YearlyGasUse));

            {
                var pas      = new List <PlannedAnnotations>();
                var zeroAnno = new PlannedAnnotations(0, 500, 1, 100);
                pas.Add(new PlannedAnnotations(500, 1000, 1, 100));
                pas.Add(new PlannedAnnotations(1000, 2500, 1, 100));
                pas.Add(new PlannedAnnotations(2500, 5000, -1, 150));
                pas.Add(new PlannedAnnotations(5000, 10000, -1, 200));
                pas.Add(new PlannedAnnotations(10000, 50000, -1, 50));
                pas.Add(new PlannedAnnotations(50000, 1000000000, -1, 200));
                var    bses            = new List <LineSeriesEntry>();
                var    lse             = new LineSeriesEntry("Electricity");
                var    idx             = 0;
                double sum             = 0;
                var    electricityPaes = new List <AnnotationEntry>();
                foreach (var standort in electricityEntriesWithValues)
                {
                    sum += standort.YearlyElectricityUseLocalnet;
                    foreach (var plannedAnnotationse in pas)
                    {
                        if (standort.YearlyElectricityUseLocalnet < plannedAnnotationse.Limit && !plannedAnnotationse.Processed)
                        {
                            electricityPaes.Add(new AnnotationEntry(plannedAnnotationse.MakeDescription(electricityEntriesWithValues),
                                                                    idx,
                                                                    sum,
                                                                    plannedAnnotationse.Direction,
                                                                    plannedAnnotationse.YOffset));
                            plannedAnnotationse.Processed = true;
                        }
                    }

                    lse.Values.Add(new Point(idx, sum));
                    idx++;
                }

                electricityPaes.Add(new AnnotationEntry(zeroAnno.MakeDescription(electricityEntriesWithValues), idx, sum, 1, 50));
                bses.Add(lse);
                var fn = MakeAndRegisterFullFilename("SortedCustomers.Electricity.png", Constants.PresentSlice);
                Services.PlotMaker.MakeLineChart(fn, "Strom [kWh]", bses, electricityPaes);
            }
            {
                var pas      = new List <PlannedAnnotations>();
                var zeroAnno = new PlannedAnnotations(0, 500, 1, 100);
                pas.Add(new PlannedAnnotations(500, 1000, 1, 100));
                pas.Add(new PlannedAnnotations(1000, 10000, -1, 200));
                pas.Add(new PlannedAnnotations(10000, 50000, -1, 50));
                pas.Add(new PlannedAnnotations(50000, 1000000000, -1, 200));
                var    bses    = new List <LineSeriesEntry>();
                var    lse     = new LineSeriesEntry("Electricity");
                var    gasPaes = new List <AnnotationEntry>();
                var    idx     = 0;
                double sum     = 0;
                foreach (var standort in gasEntriesWithValues)
                {
                    sum += standort.YearlyGasUse;
                    foreach (var plannedAnnotationse in pas)
                    {
                        if (standort.YearlyGasUse < plannedAnnotationse.Limit && !plannedAnnotationse.Processed)
                        {
                            gasPaes.Add(new AnnotationEntry(plannedAnnotationse.MakeDescription(gasEntriesWithValues),
                                                            idx,
                                                            sum,
                                                            plannedAnnotationse.Direction,
                                                            plannedAnnotationse.YOffset));
                            plannedAnnotationse.Processed = true;
                        }
                    }

                    lse.Values.Add(new Point(idx, sum));
                    idx++;
                }

                gasPaes.Add(new AnnotationEntry(zeroAnno.MakeDescription(gasEntriesWithValues), idx, sum, 1, 50));
                bses.Add(lse);
                var fn2 = MakeAndRegisterFullFilename("SortedCustomers.Gas.png", Constants.PresentSlice);
                Services.PlotMaker.MakeLineChart(fn2, "Strom [kWh]", bses, gasPaes);
            }
        }