From fd99dc21f0deae3c65d6ef24e35967d148a97ac7 Mon Sep 17 00:00:00 2001 From: Kai Nagel Date: Mon, 15 Jul 2024 11:25:34 +0200 Subject: [PATCH] major changes to allow section titles between plots --- pom.xml | 5 + .../vsp/bvwp/computation/ComputationKN.java | 19 +- .../vsp/bvwp/computation/Modifications.java | 6 +- .../bvwp/computation/NkvCalculatorRail.java | 1 - .../java/org/tub/vsp/bvwp/data/Headers.java | 26 +- .../analysis/RailAnalysisDataContainer.java | 8 +- .../analysis/StreetAnalysisDataContainer.java | 48 ++-- .../org/tub/vsp/bvwp/plot/MultiPlotUtils.java | 36 +++ .../org/tub/vsp/bvwp/users/kn/Figures1KN.java | 261 ++++++++---------- .../tub/vsp/bvwp/users/kn/Figures1RailKN.java | 153 +++------- .../org/tub/vsp/bvwp/users/kn/Figures2KN.java | 95 +++---- .../bvwp/users/kn/RunLocalCsvScrapingKN.java | 229 ++++++++++----- .../bvwp/computation/ComputationKNTest.java | 6 +- 13 files changed, 460 insertions(+), 433 deletions(-) diff --git a/pom.xml b/pom.xml index 6d3127e..a09e95d 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,11 @@ tablesaw-jsplot 0.43.1 + + tech.tablesaw + tablesaw-html + 0.43.1 + org.jsoup jsoup diff --git a/src/main/java/org/tub/vsp/bvwp/computation/ComputationKN.java b/src/main/java/org/tub/vsp/bvwp/computation/ComputationKN.java index 8028bcd..f911515 100644 --- a/src/main/java/org/tub/vsp/bvwp/computation/ComputationKN.java +++ b/src/main/java/org/tub/vsp/bvwp/computation/ComputationKN.java @@ -192,7 +192,7 @@ static double nkvOhneKR_induz(Modifications modifications, Amounts amounts, Bene double b_co2_reroute = amounts.pkwkm_reroute * amounts.co2_per_pkwkm * b_per_co2; - // ### first deduct the CO2 components so that we can later re-scale the other material according to changed discount rate: + // ### first deduct the CO2 components so that we can afterwards re-scale the other material according to changed discount rate: // --- for infra: b_all -= benefits.co2_infra; @@ -202,13 +202,7 @@ static double nkvOhneKR_induz(Modifications modifications, Amounts amounts, Bene b_all -= b_co2_verl; b_all -= b_co2_induz; - // ### then rescale the remaining benefit with the corresponding modification: - { - double b_tmp = b_all; - b_all *= modifications.nonCo2BenefitsFactor(); - prn( "b w nonCo2 factor:", b_all, b_tmp ); - } - // ### then add the CO2 components with the new values: + // ### then re-add the CO2 components with the new values: // co2 Bau { @@ -218,21 +212,22 @@ static double nkvOhneKR_induz(Modifications modifications, Amounts amounts, Bene } // co2 Betrieb + final double operationsCorrFactor = modifications.co2Price() / 145. * modifications.discountCorrFact() * modifications.emobCorrFact(); { double b_tmp = b_all; - b_all += b_co2_reroute / 145. * modifications.co2Price(); + b_all += b_co2_reroute / 145. * modifications.co2Price() * modifications.discountCorrFact() * modifications.emobCorrFact(); prn("b after co2 reroute:", b_all, b_tmp); } { double b_tmp = b_all; - b_all += b_co2_verl / 145. * modifications.co2Price(); + b_all += b_co2_verl / 145. * modifications.co2Price() * modifications.discountCorrFact() * modifications.emobCorrFact(); prn("b after co2 verl:", b_all, b_tmp); } { double b_tmp = b_all; - b_all += b_co2_induz / 145. * modifications.co2Price(); - b_all += modifications.mehrFzkm() * amounts.co2_per_pkwkm * b_per_co2 * modifications.co2Price() / 145; + b_all += b_co2_induz / 145. * modifications.co2Price() * modifications.discountCorrFact() * modifications.emobCorrFact() ; + b_all += modifications.mehrFzkm() * amounts.co2_per_pkwkm * b_per_co2 * modifications.co2Price() / 145 * modifications.discountCorrFact() * modifications.emobCorrFact() ; prn("b after co2 induz", b_all, b_tmp); } // prn("b_co2_betrieb", b_all, bb_tmp); diff --git a/src/main/java/org/tub/vsp/bvwp/computation/Modifications.java b/src/main/java/org/tub/vsp/bvwp/computation/Modifications.java index f8938fc..d6dd8ce 100644 --- a/src/main/java/org/tub/vsp/bvwp/computation/Modifications.java +++ b/src/main/java/org/tub/vsp/bvwp/computation/Modifications.java @@ -3,13 +3,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public record Modifications(double co2Price, double mehrFzkm, double constructionCostFactor, double nonCo2BenefitsFactor) { - //TODO nonCo2BenefitsFactor is not used in the codebase +public record Modifications(double co2Price, double mehrFzkm, double constructionCostFactor, double discountCorrFact, double emobCorrFact) { private static final Logger log = LogManager.getLogger(Modifications.class); public static final double co2PriceBVWP = 145.; public static final double co2Price700 = 642.; // (700 sind die Klimakosten von in 2030 erzeugten CO2-Emissionen, zum Preisstand 2020. Rückgerechnet nach 2012 führt das zu 642.) + public static final double co2Price2000 = 2000.*642/700; /** * Wie {@link #co2Price700}, aber mit 1% Zeitpräferenzrate. */ @@ -28,7 +28,7 @@ public record Modifications(double co2Price, double mehrFzkm, double constructio } } - public static final Modifications NO_CHANGE = new Modifications(co2PriceBVWP, 0., 1, 1. ); + public static final Modifications NO_CHANGE = new Modifications(co2PriceBVWP, 0., 1, 1, 1. ); @Override public String toString() { return "[co2Price=" + co2Price + "; mehrFzkm=" + mehrFzkm + "]"; diff --git a/src/main/java/org/tub/vsp/bvwp/computation/NkvCalculatorRail.java b/src/main/java/org/tub/vsp/bvwp/computation/NkvCalculatorRail.java index b3d6632..ad4f5d0 100644 --- a/src/main/java/org/tub/vsp/bvwp/computation/NkvCalculatorRail.java +++ b/src/main/java/org/tub/vsp/bvwp/computation/NkvCalculatorRail.java @@ -26,7 +26,6 @@ public Double calculateNkv( Modifications modifications ) { @Deprecated // use instance approach public static Double calculateNkv(Modifications modifications, RailBaseDataContainer railBaseDataContainer) { assert modifications.mehrFzkm() == 0; - assert modifications.nonCo2BenefitsFactor() == 1.; double baukosten_MioEur = railBaseDataContainer.getCostBenefitAnalysis().getCost().overallCosts() * modifications.constructionCostFactor(); double benefit_MioEur = railBaseDataContainer.getCostBenefitAnalysis().getOverallBenefit().overall(); diff --git a/src/main/java/org/tub/vsp/bvwp/data/Headers.java b/src/main/java/org/tub/vsp/bvwp/data/Headers.java index 3f154a6..127c2f3 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/Headers.java +++ b/src/main/java/org/tub/vsp/bvwp/data/Headers.java @@ -26,7 +26,7 @@ public final class Headers{ /** * Mehrverkehr auf Pkw, den das Projekt erzeugt, laut PRINS. */ - public static final String ADDTL_PKWKM_ORIG = ADDTL_PKWKM + " aus PRINS"; + public static final String ADDTL_PKWKM_ORIG = ADDTL_PKWKM + " in PRINS"; public static final String ADDTL_PKWKM_FROM_TTIME = ADDTL_PKWKM + " aus Reisezeitgewinnen"; public static final String ADDTL_PKWKM_FROM_TTIME_DIFF = "addtl_pkwkm_from_ttime_diff"; @@ -35,7 +35,7 @@ public final class Headers{ * * @see org.tub.vsp.bvwp.data.type.Bautyp */ - public static final String BAUTYP = "bautyp"; + public static final String BAUTYP = "Bautyp"; /** * Die (vermutlich negativen) Nutzenbeiträge ("benefits") durch CO2 sowie durch Emissionen, die auf CO2 umgerechnet werden können. (??) */ @@ -63,11 +63,11 @@ public final class Headers{ /** * Originale Investitionskosten. */ - public static final String INVCOST_ORIG = "investmentCost_orig"; + public static final String INVCOST_ORIG = "Inv.kosten BVWP 2030"; /** * Investitionskosten nach Berechnung der TUD */ - public static final String INVCOST_TUD = "Investitionskosten neu"; + public static final String INVCOST_TUD = "Inv.kosten neu"; /** * Umrechnung von Emissionen (welchen??) in CO2-Äquivalente. */ @@ -89,7 +89,7 @@ public final class Headers{ /** * min( 5 , {@link #NKV_ORIG} ) */ - public static final String NKV_ORIG = "NKV aus PRINS"; + public static final String NKV_ORIG = "NKV BVWP 2030"; /** * NKV bei erhöhtem CO2-Preis (welchem?). */ @@ -105,7 +105,7 @@ public final class Headers{ */ public static final String NKV_EL03 = "NKV_el03"; public static final String NKV_EL03_CAPPED5 = NKV_EL03 + "_capped5"; - public static final String NKV_CARBON700ptpr0 = "NKV mit erhöhten CO2-Kosten"; + public static final String NKV_CARBON700ptpr0 = "NKV CO2-Kosten+"; public static final String NKV_CARBON700_CAPPED5 = NKV_CARBON700ptpr0 + "_capped5"; /** * Neues NKV mit höherem Mehrverkehr, CO2-Preis 215, sowie höheren Investitionskosten. @@ -130,14 +130,18 @@ public final class Headers{ * Dies ist da, damit "bubble size" als Funktion der Einstufung geplottet werden kann. */ public static final String EINSTUFUNG_AS_NUMBER = "einstufungAsNumber"; - public static final String PROJECT_NAME = "project _name"; + public static final String PROJECT_NAME = "Projektname"; public static final String VERKEHRSBELASTUNG_PLANFALL = "DTV_Planfall"; - public static final String NKV_INVCOSTTUD = "NKV mit erhöhten Baukosten"; - public static final String NKV_ELTTIME = "NKV mit erhöhtem Straßenmehrverkehr"; + public static final String NKV_INVCOSTTUD = "NKV mit Inv.kosten+"; + public static final String NKV_ELTTIME = "NKV mit Straßenmehrverkehr+"; public static final String NKV_ELTTIME_CARBON215_INVCOSTTUD = "NKV_elTtime_carbon215_invcostTud"; - public static final String NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD = "NKV mit erhöhtem Straßenmehrverkehr/Baukosten/CO2-Preis"; + public static final String NKV_ELTTIME_CARBON700ptpr0 = "NKV mit Straßenmehrverkehr+/CO2-Preis+"; + public static final String NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD = "NKV mit Inv.Kosten+/Straßenmehrverkehr+/CO2-Preis+"; + public static final String NKV_ELTTIME_CARBON700ptpr0_EMOB_INVCOSTTUD = "NKV mit Inv.Kosten+/Straßenmehrverkehr+/CO2-Preis+ & EMob"; + public static final String NKV_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD = "NKV mit Inv.Kosten+/Straßenmehrverkehr+/CO2-Preis++ & EMob"; + public static final String NProCo2_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD = "Nutzen_pro_CO2 mit Inv.Kosten+/Straßenmehrverkehr+/CO2-Preis++ & EMob"; public static final String NKV_ELTTIME_CARBON2000_INVCOSTTUD = "NKV_elTtime_carbon2000_invcostTud"; - public static final String CO2_ELTTIME = "CO2[mt] bei erhöhem Straßenmehrverkehr"; + public static final String CO2_ELTTIME = "CO2[Mt] bei Straßenmehrverkehr+"; public static String capped5Of( String str ) { int cap=5; diff --git a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/RailAnalysisDataContainer.java b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/RailAnalysisDataContainer.java index 10c49db..cdb824b 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/RailAnalysisDataContainer.java +++ b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/RailAnalysisDataContainer.java @@ -58,10 +58,10 @@ private void addComputations() { entries.put(Headers.B_PER_KM, baseDataContainer.getCostBenefitAnalysis().getOverallBenefit().overall() / baseDataContainer.getProjectInformation().getLength() ); entries.put(Headers.NKV_ORIG, NkvCalculatorRail.calculateNkv( NO_CHANGE, baseDataContainer ) ); - entries.put(Headers.NKV_CO2, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1.), baseDataContainer)); - entries.put(Headers.NKV_CO2_700_EN, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1.), baseDataContainer)); - entries.put(Headers.NKV_CARBON700ptpr0, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1.), baseDataContainer ) ); - entries.put(Headers.NKV_CO2_2000_EN, NkvCalculatorRail.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, 0, 1, 1 ), baseDataContainer ) ); + entries.put(Headers.NKV_CO2, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1, 1. ), baseDataContainer ) ); + entries.put(Headers.NKV_CO2_700_EN, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1, 1. ), baseDataContainer ) ); + entries.put(Headers.NKV_CARBON700ptpr0, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1, 1. ), baseDataContainer ) ); + entries.put(Headers.NKV_CO2_2000_EN, NkvCalculatorRail.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, 0, 1, 1, 1. ), baseDataContainer ) ); // entries.put(Headers.NKV_EL03, NkvCalculatorRail.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1, 1. ), baseDataContainer ) ); // entries.put(Headers.NKV_EL03_CARBON215_INVCOSTTUD, NkvCalculatorRail.calculateNkv( new Modifications( co2Price215, addtlFzkmBeyondPrinsEl03, constructionCostFactor, 1. ), baseDataContainer ) ); // entries.put(Headers.NKV_EL03_CARBON700tpr0_INVCOSTTUD, NkvCalculatorRail.calculateNkv( new Modifications( co2Price700, addtlFzkmBeyondPrinsEl03, constructionCostFactor, 1.75 ), baseDataContainer ) ); diff --git a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java index e1157d1..523f677 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java +++ b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java @@ -81,26 +81,28 @@ private void addComputations() { // return; // } - final double fact = 1.; + final double discountCorrFact = 1.14; // ptpr0 = stpr 1%. Diskontierung 1% statt 1.7% über Jahre 0 bis 42 bedeutet 1.14 x so viel Nutzen. Vgl. prins.mw. Könnte man ordentlicher machen. - // dennoch 1 gewählt, weil wir nach neuester Überlegung co2 um diesen Faktor nach oben schieben müssen. Machen wir jetzt aber auch nicht, wg. Elektromobilität. + + // Nach neuerer Überlegung lassen wir alles andere bei 1.7% , und schieben nur co2 um diesen Faktor nach oben. + + final double emobCorrFact = 0.1; NkvCalculator nkvCalculator = new NkvCalculator( streetBaseData ); entries.put(Headers.NKV_ORIG, nkvCalculator.calculateNkv( NO_CHANGE ) ); - entries.put(Headers.NKV_CO2, nkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, fact ) ) ); - entries.put(Headers.NKV_CO2_700_EN, nkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, fact ) ) ); - entries.put(Headers.NKV_CARBON700ptpr0, nkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, fact ) ) ); - entries.put(Headers.NKV_CO2_2000_EN, nkvCalculator.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, 0, 1, 1. ) ) ); - entries.put(Headers.NKV_EL03, nkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1, 1. ) ) ); - entries.put(Headers.NKV_EL03_CARBON215_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price215, addtlFzkmBeyondPrinsEl03, constructionCostFactor, 1. ) ) ); - entries.put(Headers.NKV_EL03_CARBON700ptpr0_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmBeyondPrinsEl03, constructionCostFactor, fact ) ) ); - entries.put(Headers.NKV_EL03_CARBON700ptpr0, nkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmBeyondPrinsEl03, 1., fact ) ) ); + entries.put(Headers.NKV_CO2, nkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1, 1. ) ) ); + entries.put(Headers.NKV_CO2_700_EN, nkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1, 1. ) ) ); + entries.put(Headers.NKV_CO2_2000_EN, nkvCalculator.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, 0, 1, 1, 1. ) ) ); + entries.put(Headers.NKV_EL03, nkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1, 1, 1. ) ) ); +// entries.put(Headers.NKV_EL03_CARBON215_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price215, addtlFzkmBeyondPrinsEl03, constructionCostFactor ) ) ); +// entries.put(Headers.NKV_EL03_CARBON700ptpr0_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( discountCorr*co2Price700, addtlFzkmBeyondPrinsEl03, constructionCostFactor ) ) ); +// entries.put(Headers.NKV_EL03_CARBON700ptpr0, nkvCalculator.calculateNkv( new Modifications( discountCorr*co2Price700, addtlFzkmBeyondPrinsEl03, 1. ) ) ); // entries.put(Headers.NKV_EL03_CO2_INVCOST50, NkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmBeyondPrinsEl03, constructionCostFactor ), streetBaseData ) ); // entries.put(Headers.ADDTL_PKWKM_EL03, addtlFzkmFromElasticity03 ); // entries.put(Headers.CO2_COST_ORIG, Math.max( 1., nkvCalculator.calculateCost_CO2( NO_CHANGE, streetBaseData ) ) ); - entries.put(Headers.CO2_COST_EL03, Math.max( 1., nkvCalculator.calculateCo2_t( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1, 1. ) ) ) ); +// entries.put(Headers.CO2_COST_EL03, Math.max( 1., nkvCalculator.calculateCo2_t( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1 ) ) ) ); // ("max(1,...)" so that they become visible on logplot. find other solution! entries.put(Headers.INVCOST_TUD, this.constructionCostTud ); @@ -108,15 +110,27 @@ private void addComputations() { double addtlFzkmFromTtime = - streetBaseData.getPhysicalEffect().getVehicleHours().overall() * AVERAGE_SPEED_OF_ADDITIONAL_TRAVEL; entries.put( Headers.ADDTL_PKWKM_FROM_TTIME, addtlFzkmFromTtime ); - entries.put( Headers.NKV_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, 0., constructionCostFactor, 1. ) ) ); - entries.put( Headers.NKV_ELTTIME, nkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmFromTtime, 1, 1. ) ) ); - entries.put( Headers.NKV_ELTTIME_CARBON215_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price215, addtlFzkmFromTtime, constructionCostFactor, 1. ) ) ); - entries.put( Headers.NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmFromTtime, constructionCostFactor, 1. ) ) ); + // Beiträge einzeln: + entries.put( Headers.NKV_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, 0., constructionCostFactor, 1, 1. ) ) ); + entries.put( Headers.NKV_ELTTIME, nkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmFromTtime, 1, 1, 1. ) ) ); + entries.put(Headers.NKV_CARBON700ptpr0, nkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, discountCorrFact, 1. ) ) ); + + // Induz. Strassenmehrverkehr und CO2-Preis kombiniert: + entries.put( Headers.NKV_ELTTIME_CARBON700ptpr0, nkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmFromTtime, 1., discountCorrFact, 1. )) ); + + // ... + Investitionskosten: + entries.put( Headers.NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmFromTtime, constructionCostFactor, discountCorrFact, 1. ) ) ); + + // ... + eMob: + entries.put( Headers.NKV_ELTTIME_CARBON700ptpr0_EMOB_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmFromTtime, constructionCostFactor, discountCorrFact, emobCorrFact ) ) ); + entries.put( Headers.NKV_ELTTIME_CARBON215_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price215, addtlFzkmFromTtime, constructionCostFactor, 1, 1. ) ) ); + entries.put( Headers.NKV_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price2000, addtlFzkmFromTtime, constructionCostFactor, discountCorrFact, emobCorrFact ) ) ); // for the 1.15 see "barwert.mw". kai, jun'24 - entries.put(Headers.CO2_ELTTIME, nkvCalculator.calculateCo2_t( new Modifications( co2PriceBVWP, addtlFzkmFromTtime, 1, 1. ) ) ); + entries.put(Headers.CO2_ELTTIME, nkvCalculator.calculateCo2_t( new Modifications( co2PriceBVWP, addtlFzkmFromTtime, 1, 1, 1. ) ) ); - entries.put( Headers.NKV_ELTTIME_CARBON2000_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, addtlFzkmFromTtime, constructionCostFactor, fact ) ) ); + entries.put( Headers.NKV_ELTTIME_CARBON2000_INVCOSTTUD, nkvCalculator.calculateNkv( + new Modifications( 2000 * INFLATION_Factor2022to2012, addtlFzkmFromTtime, constructionCostFactor, 1, 1. ) ) ); if ( streetBaseData.getProjectInformation().getProjectNumber().contains("A1-G50-NI" )) { this.remarks.add("Eher geringer Benefit pro km ... erzeugt dann ueber die El pro km relativ viel Verkehr " + diff --git a/src/main/java/org/tub/vsp/bvwp/plot/MultiPlotUtils.java b/src/main/java/org/tub/vsp/bvwp/plot/MultiPlotUtils.java index 9609c80..914f2f9 100644 --- a/src/main/java/org/tub/vsp/bvwp/plot/MultiPlotUtils.java +++ b/src/main/java/org/tub/vsp/bvwp/plot/MultiPlotUtils.java @@ -1,5 +1,9 @@ package org.tub.vsp.bvwp.plot; +import tech.tablesaw.plotly.components.Figure; + +import java.util.Map; + /** * Bausteine, die für die Erstellung der Multiplots benötigt werden. * Für Beispiele zum Erstellen von Plots siehe {@link MultiPlotExample} @@ -38,4 +42,36 @@ public static String pageTop(){ public static final String pageBottom = "" + System.lineSeparator() + ""; + public static String createPageV2( Map figures ) { + StringBuilder result = new StringBuilder( "" + System.lineSeparator() + + "" + System.lineSeparator() + + " Multi-plot test" + System.lineSeparator() + + " " + System.lineSeparator() + + "" + System.lineSeparator() + + "" + System.lineSeparator() + + "

Part A

" + System.lineSeparator() ); + + // append the html that references each individual plot: + { + int ii = 0; + for( Map.Entry entry : figures.entrySet() ){ + result.append( entry.getKey() ).append( "
" ).append( System.lineSeparator() ); + ii++; + } + } + + // append the figures themselves: + { + int ii = 0; + for( Figure figure : figures.values() ){ + result.append( figure.asJavascript( "plot" + ii ) ).append( System.lineSeparator() ); + ii++; + } + } + + // terminating lines: + result.append( "" ).append( System.lineSeparator() ).append( "" ); + + return result.toString(); + } } diff --git a/src/main/java/org/tub/vsp/bvwp/users/kn/Figures1KN.java b/src/main/java/org/tub/vsp/bvwp/users/kn/Figures1KN.java index a0d35b4..48566e8 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kn/Figures1KN.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kn/Figures1KN.java @@ -81,23 +81,23 @@ class Figures1KN{ init = false; // =========================== - table.addColumns( - table.numberColumn( NKV_EL03_CARBON215_INVCOSTTUD ).subtract( table.numberColumn( NKV_ORIG ) ).setName( NKV_EL03_DIFF ) - , table.numberColumn( ADDTL_PKWKM_EL03 ).subtract( table.numberColumn( ADDTL_PKWKM_ORIG ) ).setName( ADDTL_PKWKM_EL03_DIFF ) - ); +// table.addColumns( +// table.numberColumn( NKV_EL03_CARBON215_INVCOSTTUD ).subtract( table.numberColumn( NKV_ORIG ) ).setName( NKV_EL03_DIFF ) +// , table.numberColumn( ADDTL_PKWKM_EL03 ).subtract( table.numberColumn( ADDTL_PKWKM_ORIG ) ).setName( ADDTL_PKWKM_EL03_DIFF ) +// ); // =========================== // =========================== - Headers.addCap5( table, NKV_EL03_CARBON215_INVCOSTTUD ); - Headers.addCap5( table, NKV_EL03_CARBON700ptpr0_INVCOSTTUD ); +// Headers.addCap5( table, NKV_EL03_CARBON215_INVCOSTTUD ); +// Headers.addCap5( table, NKV_EL03_CARBON700ptpr0_INVCOSTTUD ); Headers.addCap5( table, NKV_ELTTIME_CARBON215_INVCOSTTUD ); - Headers.addCap5( table, NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD ); + Headers.addCap5( table, NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD ); Headers.addCap5( table, NKV_ORIG ); - Headers.addCap5( table, NKV_EL03 ); - Headers.addCap5( table, NKV_EL03_CARBON700ptpr0 ); +// Headers.addCap5( table, NKV_EL03 ); +// Headers.addCap5( table, NKV_EL03_CARBON700ptpr0 ); Headers.addCap5( table, NKV_CARBON700ptpr0 ); Headers.addCap5( table, NKV_ELTTIME_CARBON2000_INVCOSTTUD ); - Headers.addCap( 10, table, NKV_EL03_CARBON215_INVCOSTTUD ); +// Headers.addCap( 10, table, NKV_EL03_CARBON215_INVCOSTTUD ); Headers.addCap( 10, table, NKV_ELTTIME_CARBON215_INVCOSTTUD ); // =========================== // =========================== @@ -166,7 +166,7 @@ class Figures1KN{ final String NKV_ORIG_CAPPED5 = Headers.addCap( 5, table, NKV_ORIG ); nkvCappedMax = table.doubleColumn( NKV_ORIG_CAPPED5 ).max() + 0.2 ; - nkvMin = table.doubleColumn( NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD ).min(); + nkvMin = table.doubleColumn( NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD ).min(); this.defaultMargin = Margin.builder() // .autoExpand( true ) @@ -205,10 +205,11 @@ Figure nkv_el03_diff(){ // .name( String.format( legendFormat, String.format( "%30s" , yName ) ) ) // .build(); - final Trace traceCyan = getTraceCyan( table, xName, y2Name ); - final Trace traceMagenta = getTraceMagenta( table, xName, y2Name ); - final Trace traceOrange = getTraceOrange( table, xName, y2Name ); - final Trace traceRed = getTraceRed( table, xName, y2Name ); + List traces = new ArrayList<>(); + traces.addAll( getTraceCyan( table, xName, y2Name ) ); + traces.addAll( getTraceMagenta( table, xName, y2Name ) ); + traces.addAll( getTraceOrange( table, xName, y2Name ) ); + traces.addAll( getTraceRed( table, xName, y2Name ) ); // Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) ) @@ -223,13 +224,7 @@ Figure nkv_el03_diff(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - Figure figure2 = new Figure( layout -// , trace -// , trace3 - , traceCyan, traceMagenta - , traceOrange, traceRed -// , trace4 - ); + Figure figure2 = new Figure( layout, traces.toArray(new Trace[]{}) ); return figure2; } // ======================================================================================== @@ -258,10 +253,11 @@ Figure nkv_el03(){ // .name( String.format( legendFormat, String.format( "%30s" , yName ) ) ) // .build(); - final Trace traceCyan = getTraceCyan( table, xName, y2Name ); - final Trace traceMagenta = getTraceMagenta( table, xName, y2Name ); - final Trace traceOrange = getTraceOrange( table, xName, y2Name ); - final Trace traceRed = getTraceRed( table, xName, y2Name ); + List traces = new ArrayList<>(); + traces.addAll( getTraceCyan( table, xName, y2Name ) ); + traces.addAll( getTraceMagenta( table, xName, y2Name ) ); + traces.addAll( getTraceOrange( table, xName, y2Name ) ); + traces.addAll( getTraceRed( table, xName, y2Name ) ); // Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) ) @@ -276,13 +272,7 @@ Figure nkv_el03(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - Figure figure2 = new Figure( layout -// , trace -// , trace3 - , traceCyan, traceMagenta - , traceOrange, traceRed -// , trace4 - ); + Figure figure2 = new Figure( layout, traces.toArray(new Trace[]{}) ); return figure2; } // ======================================================================================== @@ -311,11 +301,7 @@ Figure nkv_carbon700(){ // .name( String.format( legendFormat, String.format( "%30s" , yName ) ) ) // .build(); - final Trace traceCyan = getTraceCyan( table, xName, y2Name ); - final Trace traceMagenta = getTraceMagenta( table, xName, y2Name ); - final Trace traceOrange = getTraceOrange( table, xName, y2Name ); - final Trace traceRed = getTraceRed( table, xName, y2Name ); - + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); // Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) @@ -329,13 +315,7 @@ Figure nkv_carbon700(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - Figure figure2 = new Figure( layout -// , trace -// , trace3 - , traceCyan, traceMagenta - , traceOrange, traceRed -// , trace4 - ); + Figure figure2 = new Figure( layout, traces.toArray(new Trace[]{} ) ); return figure2; } // ======================================================================================== @@ -364,11 +344,7 @@ Figure nkv_el03_carbon700(){ // .name( String.format( legendFormat, String.format( "%30s" , yName ) ) ) // .build(); - final Trace traceCyan = getTraceCyan( table, xName, y2Name ); - final Trace traceMagenta = getTraceMagenta( table, xName, y2Name ); - final Trace traceOrange = getTraceOrange( table, xName, y2Name ); - final Trace traceRed = getTraceRed( table, xName, y2Name ); - + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); // Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) @@ -382,13 +358,7 @@ Figure nkv_el03_carbon700(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - Figure figure2 = new Figure( layout -// , trace -// , trace3 - , traceCyan, traceMagenta - , traceOrange, traceRed -// , trace4 - ); + Figure figure2 = new Figure( layout, traces.toArray(new Trace[]{} ) ); return figure2; } // ======================================================================================== @@ -405,22 +375,19 @@ Figure createFigurePkwKm( ){ .width( plotWidth ) .build(); - Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); + + traces.add( ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) .text( table.stringColumn( PROJECT_NAME ).asObjectArray() ) - .build(); - - final Trace traceWb = getTraceCyan( table, xName, y2Name ); - final Trace traceWbp = getTraceMagenta( table, xName, y2Name ); - final Trace traceVb = getTraceOrange( table, xName, y2Name ); - final Trace traceVbe = getTraceRed( table, xName, y2Name ); + .build() ); // double[] xx = new double[]{1., 200.}; // Trace trace1 = ScatterTrace.builder( xx, xx ) // .mode( ScatterTrace.Mode.LINE ) // .build(); - Figure figure = new Figure( layout, trace, traceWb, traceWbp, traceVb, traceVbe ); + Figure figure = new Figure( layout, traces.toArray(traces.toArray( new Trace[0] ) ) ); return figure; } // ======================================================================================== @@ -488,16 +455,13 @@ public Figure fzkm(){ Layout layout = Layout.builder( "" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); + Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) .text( table.stringColumn( PROJECT_NAME ).asObjectArray() ) .build(); - final Trace traceWb = getTraceCyan( table, xName, y2Name ); - final Trace traceWbp = getTraceMagenta( table, xName, y2Name ); - final Trace traceVb = getTraceOrange( table, xName, y2Name ); - final Trace traceVbe = getTraceRed( table, xName, y2Name ); - // Trace trace1 = ScatterTrace.builder( new double[]{1,700}, new double[]{ 1 , 700./ComputationKN.LANE_KM_AB * ComputationKN.FZKM_AB*0.3} ) // .mode( ScatterTrace.Mode.LINE ) // .build(); @@ -505,10 +469,7 @@ public Figure fzkm(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - return new Figure( layout, trace - ,traceWb, traceWbp, traceVb, traceVbe -// ,trace1, trace2 - ); + return new Figure( layout, traces.toArray(new Trace[]{} ) ); } // ======================================================================================== @@ -526,11 +487,7 @@ Figure carbon(){ Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - List traces = new ArrayList<>( ); - traces.add( getTraceCyan( table, xName, y2Name ) ); - traces.add( getTraceMagenta( table, xName, y2Name ) ); - traces.add( getTraceOrange( table, xName, y2Name ) ); - traces.add( getTraceRed( table, xName, y2Name ) ); + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name )); return new Figure( layout, traces.toArray(new Trace[]{}) ); } // ======================================================================================== @@ -548,19 +505,9 @@ public Figure dtv(){ // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .build(); - final Trace traceWb = getTraceCyan( table, xName, y2Name ); - final Trace traceWbp = getTraceMagenta( table, xName, y2Name ); - final Trace traceVb = getTraceOrange( table, xName, y2Name ); - final Trace traceVbe = getTraceRed( table, xName, y2Name ); - + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); - return new Figure( layout -// , trace - , traceWb - ,traceWbp - , traceVb - , traceVbe - ); + return new Figure( layout, traces.toArray(new Trace[]{} ) ); } public Figure fzkmNew(){ String yName = ADDTL_PKWKM_ORIG; @@ -575,26 +522,17 @@ public Figure fzkmNew(){ Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); + + traces.add( ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) .text( table.stringColumn( PROJECT_NAME ).asObjectArray() ) - .build(); - - final Trace traceWb = getTraceCyan( table, xName, y2Name ); - final Trace traceWbp = getTraceMagenta( table, xName, y2Name ); - final Trace traceVb = getTraceOrange( table, xName, y2Name ); - final Trace traceVbe = getTraceRed( table, xName, y2Name ); + .build() ); // log.warn( table.where( table.stringColumn( Headers.PROJECT_NAME ).startsWith( "A008" ) ) ); // log.warn("here"); - return new Figure( layout - , trace - , traceWb - ,traceWbp - , traceVb - , traceVbe - ); + return new Figure( layout, traces.toArray(new Trace[]{} ) ); } // ======================================================================================== // ======================================================================================== @@ -610,18 +548,13 @@ public Figure fzkmDiff(){ Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - List traces = new ArrayList<>(); + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); // Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) // .name( String.format( legendFormat, yName ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .build(); - traces.add( getTraceCyan( table, xName, y2Name ) ); - traces.add( getTraceMagenta( table, xName, y2Name ) ); - traces.add( getTraceOrange( table, xName, y2Name ) ); - traces.add( getTraceRed( table, xName, y2Name ) ); - return new Figure( layout, traces.toArray(new Trace[]{} ) ); } @@ -637,12 +570,7 @@ public Figure invCostTud(){ Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - List traces = new ArrayList<>(); - - traces.add( getTraceCyan( table, xName, y2Name ) ); - traces.add( getTraceMagenta( table, xName, y2Name ) ); - traces.add( getTraceOrange( table, xName, y2Name ) ); - traces.add( getTraceRed( table, xName, y2Name ) ); + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); return new Figure( layout, traces.toArray(new Trace[]{} ) ); } @@ -657,45 +585,92 @@ public Figure invCostTud(){ // one can combine the four methods below by setting the marker color etc. to a Column instead of to a single value. See examples in BubblePlot. // (however, in the end this does not work that much differently from what follows here except that it loops over the categorical column instead of repeating the code) - static Trace getTraceRed( Table table, String xName, String y2Name ){ + static List getTraceRed( Table table, String xName, String y2Name ){ Table tableVbe = table.where( table.stringColumn( BAUTYP ).isIn( "EW8" ) ); final String nameInLegend = "EW8"; final String color = "red"; - final Trace traceVbe = getTrace( xName, y2Name, tableVbe, nameInLegend, color ); - return traceVbe; + return getTraces( xName, y2Name, tableVbe, nameInLegend, color ); } - static Trace getTrace( String xName, String y2Name, Table tableVbe, String nameInLegend, String color ){ - Trace traceVbe = ScatterTrace.builder( tableVbe.numberColumn( xName ), tableVbe.numberColumn( y2Name ) ) - .text( tableVbe.stringColumn( PROJECT_NAME ).asObjectArray() ) - .name( String.format( legendFormat, nameInLegend ) ) - .marker( Marker.builder().color( color ) - .size(20) - .size( tableVbe.doubleColumn( Headers.EINSTUFUNG_AS_NUMBER ) ).sizeMode( Marker.SizeMode.DIAMETER ) - .build() ) - .build(); - return traceVbe; + static List getTraces( String xName, String y2Name, Table table, String nameInLegend, String color ){ + + Table tableA20 = table.where( table.stringColumn( PROJECT_NAME ).startsWith( "A20-" ) ); + Table tableA14 = table.where( table.stringColumn( PROJECT_NAME ).startsWith( "A14-" ) ); + Table tableA39 = table.where( table.stringColumn( PROJECT_NAME ).startsWith( "A39-" ) ); + Table tableA008 = table.where( table.stringColumn( PROJECT_NAME ).startsWith( "A008-" ) ); +// + Table tableTmp = table.dropWhere( table.stringColumn( PROJECT_NAME ).startsWith( "A20-" ) + .or( table.stringColumn( PROJECT_NAME ).startsWith( "A008-" ) ) + .or( table.stringColumn( PROJECT_NAME ).startsWith( "A14-" ) ) + .or( table.stringColumn( PROJECT_NAME ).startsWith( "A39-" ) ) + ); + + List traces = new ArrayList<>(); + + traces.add( ScatterTrace.builder( tableTmp.numberColumn( xName ), tableTmp.numberColumn( y2Name ) ) + .text( tableTmp.stringColumn( PROJECT_NAME ).asObjectArray() ) + .name( String.format( legendFormat, nameInLegend ) ) + .marker( Marker.builder().color( color ) +// .size( 20 ) + .size( tableTmp.doubleColumn( EINSTUFUNG_AS_NUMBER ) ) + .sizeMode( Marker.SizeMode.DIAMETER ).build() ) + .build() ); + traces.add( ScatterTrace.builder( tableA20.numberColumn( xName ), tableA20.numberColumn( y2Name ) ) + .text( tableA20.stringColumn( PROJECT_NAME ).asObjectArray() ) + .name( String.format( legendFormat, nameInLegend ) ) + .marker( Marker.builder().color( color ) + .size( 40 ) +// .size( tableA20.doubleColumn( EINSTUFUNG_AS_NUMBER ) ) + .sizeMode( Marker.SizeMode.DIAMETER ) + .symbol( Symbol.TRIANGLE_NW).build() ) + .build() ); + traces.add( ScatterTrace.builder( tableA14.numberColumn( xName ), tableA14.numberColumn( y2Name ) ) + .text( tableA14.stringColumn( PROJECT_NAME ).asObjectArray() ) + .name( String.format( legendFormat, nameInLegend ) ) + .marker( Marker.builder().color( color ) + .size( 40 ) +// .size( tableA14.doubleColumn( EINSTUFUNG_AS_NUMBER ) ) + .sizeMode( Marker.SizeMode.DIAMETER ) + .symbol( Symbol.TRIANGLE_RIGHT).build() ) + .build() ); + traces.add( ScatterTrace.builder( tableA39.numberColumn( xName ), tableA14.numberColumn( y2Name ) ) + .text( tableA39.stringColumn( PROJECT_NAME ).asObjectArray() ) + .name( String.format( legendFormat, nameInLegend ) ) + .marker( Marker.builder().color( color ) + .size( 40 ) +// .size( tableA39.doubleColumn( EINSTUFUNG_AS_NUMBER ) ) + .sizeMode( Marker.SizeMode.DIAMETER ) + .symbol( Symbol.TRIANGLE_LEFT).build() ) + .build() ); + traces.add( ScatterTrace.builder( tableA008.numberColumn( xName ), tableA008.numberColumn( y2Name ) ) + .text( tableA008.stringColumn( PROJECT_NAME ).asObjectArray() ) + .name( String.format( legendFormat, nameInLegend ) ) + .marker( Marker.builder().color( color ) + .size( 40 ) +// .size( tableA008.doubleColumn( EINSTUFUNG_AS_NUMBER ) ) + .sizeMode( Marker.SizeMode.DIAMETER ) + .symbol( Symbol.TRIANGLE_SE).build() ) + .build() ); + + return traces; } - static Trace getTraceOrange( Table table, String xName, String y2Name ){ + static List getTraceOrange( Table table, String xName, String y2Name ){ Table tableVb = table.where( table.stringColumn( BAUTYP ).isIn( "EW6","EW6_EW8" ) ); - final Trace traceVb = getTrace( xName, y2Name, tableVb, "EW6", "orange" ); - return traceVb; + return getTraces( xName, y2Name, tableVb, "EW6", "orange" ); } - static Trace getTraceMagenta( Table table, String xName, String y2Name ){ + static List getTraceMagenta( Table table, String xName, String y2Name ){ Table tableWb = table.where( table.stringColumn( BAUTYP ).containsString( "NB" ) ); - final Trace traceWb = getTrace( xName, y2Name, tableWb, "Neubau", "magenta" ); - return traceWb; + return getTraces( xName, y2Name, tableWb, "Neubau", "magenta" ); } - static Trace getTraceCyan( Table table, String xName, String y2Name ){ + static List getTraceCyan( Table table, String xName, String y2Name ){ Table tableWb = table.where( table.stringColumn( BAUTYP ).containsString( "KNOTENPUNKT" ) ) ; - final Trace traceWb = getTrace( xName, y2Name, tableWb, "Knotenpunkt", "cyan" ); - return traceWb; + return getTraces( xName, y2Name, tableWb, "Knotenpunkt", "cyan" ); } static List getTracesByColor( Table table, String xName, String y2Name ){ List list = new ArrayList<>(); - list.add( getTraceRed( table, xName, y2Name ) ); - list.add( getTraceMagenta( table, xName, y2Name ) ); - list.add( getTraceCyan( table, xName, y2Name ) ); - list.add( getTraceOrange( table, xName, y2Name ) ); + list.addAll( getTraceRed( table, xName, y2Name ) ); + list.addAll( getTraceMagenta( table, xName, y2Name ) ); + list.addAll( getTraceCyan( table, xName, y2Name ) ); + list.addAll( getTraceOrange( table, xName, y2Name ) ); return list; } static ScatterTrace diagonalLine( Table table, String xName, String y2Name ){ diff --git a/src/main/java/org/tub/vsp/bvwp/users/kn/Figures1RailKN.java b/src/main/java/org/tub/vsp/bvwp/users/kn/Figures1RailKN.java index b881d12..21e140d 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kn/Figures1RailKN.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kn/Figures1RailKN.java @@ -183,17 +183,14 @@ Figure nkv_el03_diff(){ .yAxis( yAxis ) .width( plotWidth ) .build(); + + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); + // Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .name( String.format( legendFormat, String.format( "%30s" , yName ) ) ) // .build(); - final Trace traceCyan = getTraceCyan( table, xName, y2Name ); - final Trace traceMagenta = getTraceMagenta( table, xName, y2Name ); - final Trace traceOrange = getTraceOrange( table, xName, y2Name ); - final Trace traceRed = getTraceRed( table, xName, y2Name ); - - // Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .name( String.format( legendFormat, y3Name ) ) @@ -206,13 +203,7 @@ Figure nkv_el03_diff(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - Figure figure2 = new Figure( layout -// , trace -// , trace3 - , traceCyan, traceMagenta - , traceOrange, traceRed -// , trace4 - ); + Figure figure2 = new Figure( layout, traces.toArray(new Trace[]{} ) ); return figure2; } // ======================================================================================== @@ -228,17 +219,14 @@ Figure nkv_el03(){ .build(); Layout layout = Layout.builder( "" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); + // Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .name( String.format( legendFormat, String.format( "%30s" , yName ) ) ) // .build(); - final Trace traceCyan = getTraceCyan( table, xName, y2Name ); - final Trace traceMagenta = getTraceMagenta( table, xName, y2Name ); - final Trace traceOrange = getTraceOrange( table, xName, y2Name ); - final Trace traceRed = getTraceRed( table, xName, y2Name ); - - // Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .name( String.format( legendFormat, y3Name ) ) @@ -251,13 +239,7 @@ Figure nkv_el03(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - Figure figure2 = new Figure( layout -// , trace -// , trace3 - , traceCyan, traceMagenta - , traceOrange, traceRed -// , trace4 - ); + Figure figure2 = new Figure( layout, traces.toArray(new Trace[]{} ) ); return figure2; } // ======================================================================================== @@ -278,8 +260,7 @@ Figure nkv_orig(){ List traces = new ArrayList<>(); - final Trace traceWb = getTrace( xName, y2Name, table, "null", "cyan" ); - traces.add( traceWb ); + traces.addAll( getTraces( xName, y2Name, table, "null", "cyan" ) ); Figure figure2 = new Figure( layout, traces.toArray(new Trace[0]) ); return figure2; @@ -300,8 +281,8 @@ Figure invCost_orig(){ List traces = new ArrayList<>(); - final Trace traceWb = getTrace( xName, y2Name, table, "null", "cyan" ); - traces.add( traceWb ); + final List traceWb = getTraces( xName, y2Name, table, "null", "cyan" ); + traces.addAll( traceWb ); Figure figure2 = new Figure( layout, traces.toArray(new Trace[0]) ); return figure2; @@ -352,8 +333,8 @@ Figure nkv_carbon700(){ List traces = new ArrayList<>(); - final Trace traceWb = getTrace( xName, y2Name, table, "null", "cyan" ); - traces.add( traceWb ); + final List traceWb = getTraces( xName, y2Name, table, "null", "cyan" ); + traces.addAll( traceWb ); Figure figure2 = new Figure( layout, traces.toArray(new Trace[0]) ); return figure2; @@ -379,17 +360,14 @@ Figure nkv_el03_carbon700(){ .yAxis( yAxis ) .width( plotWidth ) .build(); + + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); + // Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .name( String.format( legendFormat, String.format( "%30s" , yName ) ) ) // .build(); - final Trace traceCyan = getTraceCyan( table, xName, y2Name ); - final Trace traceMagenta = getTraceMagenta( table, xName, y2Name ); - final Trace traceOrange = getTraceOrange( table, xName, y2Name ); - final Trace traceRed = getTraceRed( table, xName, y2Name ); - - // Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .name( String.format( legendFormat, y3Name ) ) @@ -402,13 +380,7 @@ Figure nkv_el03_carbon700(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - Figure figure2 = new Figure( layout -// , trace -// , trace3 - , traceCyan, traceMagenta - , traceOrange, traceRed -// , trace4 - ); + Figure figure2 = new Figure( layout, traces.toArray(new Trace[]{} ) ); return figure2; } // ======================================================================================== @@ -425,22 +397,18 @@ Figure createFigurePkwKm( ){ .width( plotWidth ) .build(); - Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); + + traces.add( ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) .text( table.stringColumn( PROJECT_NAME ).asObjectArray() ) - .build(); - - final Trace traceWb = getTraceCyan( table, xName, y2Name ); - final Trace traceWbp = getTraceMagenta( table, xName, y2Name ); - final Trace traceVb = getTraceOrange( table, xName, y2Name ); - final Trace traceVbe = getTraceRed( table, xName, y2Name ); - + .build() ); // double[] xx = new double[]{1., 200.}; // Trace trace1 = ScatterTrace.builder( xx, xx ) // .mode( ScatterTrace.Mode.LINE ) // .build(); - Figure figure = new Figure( layout, trace, traceWb, traceWbp, traceVb, traceVbe ); + Figure figure = new Figure( layout, traces.toArray(new Trace[]{} ) ); return figure; } // ======================================================================================== @@ -508,15 +476,12 @@ public Figure fzkm(){ Layout layout = Layout.builder( "" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) + List traces = getTracesByColor( table, xName, y2Name ); + + traces.add( ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) .text( table.stringColumn( PROJECT_NAME ).asObjectArray() ) - .build(); - - final Trace traceWb = getTraceCyan( table, xName, y2Name ); - final Trace traceWbp = getTraceMagenta( table, xName, y2Name ); - final Trace traceVb = getTraceOrange( table, xName, y2Name ); - final Trace traceVbe = getTraceRed( table, xName, y2Name ); + .build() ); // Trace trace1 = ScatterTrace.builder( new double[]{1,700}, new double[]{ 1 , 700./ComputationKN.LANE_KM_AB * ComputationKN.FZKM_AB*0.3} ) // .mode( ScatterTrace.Mode.LINE ) @@ -525,10 +490,7 @@ public Figure fzkm(){ // .mode( ScatterTrace.Mode.LINE ) // .build(); - return new Figure( layout, trace - ,traceWb, traceWbp, traceVb, traceVbe -// ,trace1, trace2 - ); + return new Figure( layout, traces.toArray(new Trace[]{} ) ); } // ======================================================================================== @@ -546,20 +508,14 @@ Figure carbon(){ Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) + List traces = getTracesByColor( table, xName, y2Name ); + + traces.add( ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) .text( table.stringColumn( PROJECT_NAME ).asObjectArray() ) - .build(); - - final Trace traceWb = getTraceCyan( table, xName, y2Name ); - final Trace traceWbp = getTraceMagenta( table, xName, y2Name ); - final Trace traceVb = getTraceOrange( table, xName, y2Name ); - final Trace traceVbe = getTraceRed( table, xName, y2Name ); - + .build() ); - return new Figure( layout - , trace - , traceWb, traceWbp, traceVb, traceVbe ); + return new Figure( layout, traces.toArray(new Trace[]{} ) ); } // ======================================================================================== // ======================================================================================== @@ -571,24 +527,14 @@ public Figure dtv(){ Layout layout = Layout.builder( "" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + List traces = getTracesByColor( table, xName, y2Name ); + // Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) // .name( String.format( legendFormat, yName ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .build(); - final Trace traceWb = getTraceCyan( table, xName, y2Name ); - final Trace traceWbp = getTraceMagenta( table, xName, y2Name ); - final Trace traceVb = getTraceOrange( table, xName, y2Name ); - final Trace traceVbe = getTraceRed( table, xName, y2Name ); - - - return new Figure( layout -// , trace - , traceWb - ,traceWbp - , traceVb - , traceVbe - ); + return new Figure( layout, traces.toArray(new Trace[]{} ) ); } public Figure fzkmNew(){ String yName = ADDTL_PKWKM_ORIG; @@ -603,26 +549,14 @@ public Figure fzkmNew(){ Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) + List traces = getTracesByColor( table, xName, y2Name ); + + traces.add( ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( String.format( legendFormat, yName ) ) .text( table.stringColumn( PROJECT_NAME ).asObjectArray() ) - .build(); + .build() ); - final Trace traceWb = getTraceCyan( table, xName, y2Name ); - final Trace traceWbp = getTraceMagenta( table, xName, y2Name ); - final Trace traceVb = getTraceOrange( table, xName, y2Name ); - final Trace traceVbe = getTraceRed( table, xName, y2Name ); - -// log.warn( table.where( table.stringColumn( Headers.PROJECT_NAME ).startsWith( "A008" ) ) ); -// log.warn("here"); - - return new Figure( layout - , trace - , traceWb - ,traceWbp - , traceVb - , traceVbe - ); + return new Figure( layout, traces.toArray(new Trace[]{} ) ); } // ======================================================================================== // ======================================================================================== @@ -638,18 +572,13 @@ public Figure fzkmDiff(){ Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - List traces = new ArrayList<>(); + List traces = getTracesByColor( table, xName, y2Name ); // Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) // .name( String.format( legendFormat, yName ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .build(); - traces.add( getTraceCyan( table, xName, y2Name ) ); - traces.add( getTraceMagenta( table, xName, y2Name ) ); - traces.add( getTraceOrange( table, xName, y2Name ) ); - traces.add( getTraceRed( table, xName, y2Name ) ); - return new Figure( layout, traces.toArray(new Trace[]{} ) ); } diff --git a/src/main/java/org/tub/vsp/bvwp/users/kn/Figures2KN.java b/src/main/java/org/tub/vsp/bvwp/users/kn/Figures2KN.java index 0136681..ede43b7 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kn/Figures2KN.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kn/Figures2KN.java @@ -26,7 +26,7 @@ class Figures2KN extends Figures1KN { } // ======================================================================================== // ======================================================================================== - public Figure nkvNeu_vs_dtv( String whichNKV ){ + public Figure nkv_vs_dtv( String whichNKV ){ String xName = VERKEHRSBELASTUNG_PLANFALL; Axis xAxis = Axis.builder().title(xName ).titleFont( defaultFont ).build(); @@ -46,10 +46,10 @@ public Figure nkvNeu_vs_dtv( String whichNKV ){ traces.add( ScatterTrace.builder( xx, yy ).mode( ScatterTrace.Mode.LINE ).build() ); } { - traces.add( getTraceCyan( table2, xName, yName ) ); - traces.add( getTraceMagenta( table2, xName, yName ) ); - traces.add( getTraceOrange( table2, xName, yName ) ); - traces.add( getTraceRed( table2, xName, yName ) ); + traces.addAll( getTraceCyan( table2, xName, yName ) ); + traces.addAll( getTraceMagenta( table2, xName, yName ) ); + traces.addAll( getTraceOrange( table2, xName, yName ) ); + traces.addAll( getTraceRed( table2, xName, yName ) ); } table2.addColumns( table2.doubleColumn( xName ).power( 2 ).setName( "power2" ) ); @@ -59,7 +59,7 @@ public Figure nkvNeu_vs_dtv( String whichNKV ){ traces.add( ScatterTrace.builder( new double[]{60_000., 100_000.}, new double[]{0., 10.} ).mode( ScatterTrace.Mode.LINE ).name( "line to guide the eye" ).build() ); traces.add( ScatterTrace.builder( new double[]{ 100_000., 140_000. }, new double[]{0., 10.} ).mode( ScatterTrace.Mode.LINE ).name( "line to guide they eye" ).build() ); } - case NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD -> { + case NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD -> { traces.add( ScatterTrace.builder( new double[]{70_000., 110_000.}, new double[]{0., 10.} ).mode( ScatterTrace.Mode.LINE ).name( "line to guide the eye" ).build() ); traces.add( ScatterTrace.builder( new double[]{ 110_000., 150_000. }, new double[]{0., 10.} ).mode( ScatterTrace.Mode.LINE ).name( "line to guide they eye" ).build() ); } @@ -110,15 +110,10 @@ public Figure invcost50_vs_NkvEl03Cprice700InvcostTud(){ Layout layout = Layout.builder( "" ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - List traces = new ArrayList<>(); + List traces = new ArrayList<>( getTracesByColor( table2, xName, yName ) ); traces.add( this.vertialNkvOneLine( yName ) ); - traces.add( getTraceCyan( table2, xName, yName ) ); - traces.add( getTraceMagenta( table2, xName, yName ) ); - traces.add( getTraceOrange( table2, xName, yName ) ); - traces.add( getTraceRed( table2, xName, yName ) ); - return new Figure( layout, traces.toArray(new Trace[]{} ) ); } // ======================================================================================== @@ -229,19 +224,14 @@ public Figure cost_VS_nkvOrig(){ String title = ""; Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); + List traces = new ArrayList<>( getTracesByColor( table2, xName, yName ) ); + // the nkv=1 line: double[] xx = new double[]{1., 1.}; double[] yy = new double[]{0., 1.1* table2.numberColumn( yName ).max() }; - Trace trace4 = ScatterTrace.builder( xx, yy ).mode( ScatterTrace.Mode.LINE ).name("NKV=1").build(); - - final Trace traceCyan = getTraceCyan( table2, xName, yName ); - final Trace traceMagenta = getTraceMagenta( table2, xName, yName ); - final Trace traceOrange = getTraceOrange( table2, xName, yName ); - final Trace traceRed = getTraceRed( table2, xName, yName ); + traces.add( ScatterTrace.builder( xx, yy ).mode( ScatterTrace.Mode.LINE ).name("NKV=1").build() ); - return new Figure( layout, traceCyan, traceMagenta, traceOrange, traceRed - , trace4 - ); + return new Figure( layout, traces.toArray( new Trace[]{} ) ); } // ======================================================================================== // ======================================================================================== @@ -268,22 +258,17 @@ Figure carbon_vs_nkvEl03Cprice215Invcost50Capped5(){ Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - List traces = new ArrayList<>(); + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); traces.add( vertialNkvOneLine( y2Name ) ); - traces.add( getTraceCyan( table, xName, y2Name ) ); - traces.add( getTraceMagenta( table, xName, y2Name ) ); - traces.add( getTraceOrange( table, xName, y2Name ) ); - traces.add( getTraceRed( table, xName, y2Name ) ); - return new Figure( layout, traces.toArray( new Trace[]{} ) ); } // ======================================================================================== // ======================================================================================== public List
getFigures( int cap, String xNameOrig ){ List
figures = new ArrayList<>(); - String xName = Headers.cappedOf( cap, xNameOrig ); +// String xName = Headers.cappedOf( cap, xNameOrig ); figures.add( investmentCostTud( cap, xNameOrig ) ); figures.add( carbon( cap, xNameOrig ) ); // figures.add( cumulativeInvestmentCostTud( cap, xName ) ); @@ -315,6 +300,23 @@ public Figure nkvNew_vs_nkvOrig( int cap, String yName ){ return new Figure( layout, traces.toArray( new Trace[]{} ) ); } + // ======================================================================================== + // ======================================================================================== + public Figure nProCo2_vs_nkv( String xName, String yName ){ + Axis.AxisBuilder xAxisBuilder = Axis.builder().autoRange( Axis.AutoRange.REVERSED ); + + Axis.AxisBuilder yAxisBuilder = Axis.builder().titleFont( defaultFont ).title( yName ); + + Table table2 = table.sortDescendingOn( xName ); // cannot remember why this is necessary + + Layout layout = Layout.builder( "" ).margin( defaultMargin ).xAxis( xAxisBuilder.title( xName ).titleFont( defaultFont ).build() ).yAxis( yAxisBuilder.build() ).width( plotWidth ).build(); + + List traces = new ArrayList<>( getTracesByColor( table2, xName, yName ) ); +// traces.add( diagonalLine2( table, x2Name, y2Name ) ); +// traces.add( horizontalNkvOneLine( table, x2Name ) ); + return new Figure( layout, traces.toArray( new Trace[]{} ) ); + } + // ======================================================================================== // ======================================================================================== public Figure carbon_vs_invcostTud(){ @@ -336,11 +338,11 @@ public Figure carbon_vs_invcostTud(){ // ======================================================================================== // ======================================================================================== public Figure nco2v_vs_vs_nkvElttimeCarbon700Invcosttud( int cap ){ - String xName = Headers.cappedOf( cap, NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD ); + String xName = Headers.cappedOf( cap, NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD ); Axis.AxisBuilder xAxisBuilder = Axis.builder().titleFont( defaultFont ); if ( cap ==Integer.MAX_VALUE ) { - xName = NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD; + xName = NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD; xAxisBuilder.autoRange( Axis.AutoRange.REVERSED ); } else { xAxisBuilder.range( nkvCappedMax, nkvMin ); @@ -349,14 +351,14 @@ public Figure nco2v_vs_vs_nkvElttimeCarbon700Invcosttud( int cap ){ Table table2 = Table.create( table.stringColumn( PROJECT_NAME ) , table.stringColumn( BAUTYP ) , table.numberColumn( EINSTUFUNG_AS_NUMBER ) - , table.doubleColumn( NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD ) + , table.doubleColumn( NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD ) , table.doubleColumn( xName ) , table.doubleColumn( INVCOST_TUD ) , table.doubleColumn( CO2_COST_EL03 ) // should be ELTTIME!! ); final String N_CO2_V = "N-CO2-V"; - table2.addColumns( table2.doubleColumn( NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD ) + table2.addColumns( table2.doubleColumn( NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD ) .multiply( table2.doubleColumn( INVCOST_TUD ) ) .divide( table2.doubleColumn( CO2_COST_EL03 ) ).setName( N_CO2_V ) ) ; @@ -367,18 +369,13 @@ public Figure nco2v_vs_vs_nkvElttimeCarbon700Invcosttud( int cap ){ Layout layout = Layout.builder( "" ).xAxis( xAxisBuilder.title( xName ).build() ).yAxis( yAxis ).width( plotWidth ).build(); - List traces = new ArrayList<>(); + List traces = new ArrayList<>( getTracesByColor( table2, xName, yName ) ); // the nkv=1 line: double[] xx = new double[]{1., 1.}; double[] yy = new double[]{0., 1.1* table2.numberColumn( yName ).max() }; traces.add( ScatterTrace.builder( xx, yy ).mode( ScatterTrace.Mode.LINE ).name("NKV=1").build() ); - traces.add( getTraceCyan( table2, xName, yName ) ); - traces.add( getTraceMagenta( table2, xName, yName ) ); - traces.add( getTraceOrange( table2, xName, yName ) ); - traces.add( getTraceRed( table2, xName, yName ) ); - return new Figure( layout, traces.toArray( new Trace[]{} ) ); } @@ -396,15 +393,10 @@ public Figure invcosttud_vs_nkvElttimeCarbon2000Invcosttud(){ Layout layout = Layout.builder("").xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build(); - List traces = new ArrayList<>(); + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); traces.add( vertialNkvOneLine( y2Name ) ); - traces.add( getTraceCyan( table, xName, y2Name ) ); - traces.add( getTraceMagenta( table, xName, y2Name ) ); - traces.add( getTraceOrange( table, xName, y2Name ) ); - traces.add( getTraceRed( table, xName, y2Name ) ); - return new Figure( layout, traces.toArray(new Trace[]{} ) ); } @@ -438,18 +430,13 @@ Figure invcost_tud_vs_orig(){ .width( plotWidth ) .build(); - List traces = new ArrayList<>(); + List traces = new ArrayList<>( getTracesByColor( table, xName, y2Name ) ); // Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) // .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) // .name( String.format( legendFormat, yName ) ) // .build(); - traces.add( getTraceCyan( table, xName, y2Name ) ); - traces.add( getTraceMagenta( table, xName, y2Name ) ); - traces.add( getTraceOrange( table, xName, y2Name ) ); - traces.add( getTraceRed( table, xName, y2Name ) ); - { double[] xx = new double[]{ table.numberColumn( xName ).min(), table.numberColumn( xName ).max() }; double[] yy = new double[]{ table.numberColumn( xName ).min(), table.numberColumn( xName ).max() }; @@ -578,7 +565,9 @@ private Figure investmentCostTud( int cap, String xName ){ Layout layout = Layout.builder( "" ).margin( defaultMargin ).xAxis( xAxisBuilder.title( xName ).titleFont( defaultFont ).build() ).yAxis( yAxis ).width( plotWidth ).build(); List traces = new ArrayList<>( getTracesByColor( table2, xName, yName )); - traces.add( vertialNkvOneLine( table2, yName ) ); + if ( xName.contains( "NKV" ) ){ + traces.add( vertialNkvOneLine( table2, yName ) ); + } return new Figure( layout, traces.toArray( new Trace[]{} ) ); } private Figure carbon( int cap, String xName ){ @@ -598,7 +587,9 @@ private Figure carbon( int cap, String xName ){ Layout layout = Layout.builder( "" ).margin( defaultMargin ).xAxis( xAxisBuilder.title( xName ).titleFont( defaultFont ).build() ).yAxis( yAxis ).width( plotWidth ).build(); List traces = new ArrayList<>( getTracesByColor( table2, xName, yName )); - traces.add( vertialNkvOneLine( table2, yName ) ); + if ( xName.contains( "NKV" ) ){ + traces.add( vertialNkvOneLine( table2, yName ) ); + } return new Figure( layout, traces.toArray( new Trace[]{} ) ); } private Figure cumulativeInvestmentCostTud( int cap, String xName ){ diff --git a/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java b/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java index 9b18126..4468812 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kn/RunLocalCsvScrapingKN.java @@ -3,12 +3,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.tub.vsp.bvwp.BvwpUtils; -import org.tub.vsp.bvwp.data.Headers; import org.tub.vsp.bvwp.data.container.analysis.StreetAnalysisDataContainer; import org.tub.vsp.bvwp.io.StreetCsvWriter; import org.tub.vsp.bvwp.plot.MultiPlotUtils; import org.tub.vsp.bvwp.scraping.StreetScraper; import tech.tablesaw.api.Table; +import tech.tablesaw.io.csv.CsvWriteOptions; +import tech.tablesaw.io.csv.CsvWriter; import tech.tablesaw.plotly.components.Figure; import tech.tablesaw.plotly.display.Browser; @@ -16,7 +17,7 @@ import java.io.FileWriter; import java.io.IOException; import java.nio.file.Paths; -import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -64,137 +65,182 @@ public static void main(String[] args) throws IOException{ Table table = csvWriter.writeCsv( allStreetBaseData ); // === - final String NKV_ORIG_CAPPED5 = Headers.addCap( 5, table, NKV_ORIG); + final String NKV_ORIG_CAPPED5 = addCap( 5, table, NKV_ORIG); Figures1KN figures1 = new Figures1KN( table, NKV_ORIG_CAPPED5 ); Figures2KN figures2 = new Figures2KN( table ); - List
plots1 = new ArrayList<>(); - List
plotsZb = new ArrayList<>(); - List
plots2 = new ArrayList<>(); + Map figures = new LinkedHashMap<>(); -// plots1.add( figures1.invCostTud() ); +// figures.add( figures1.invCostTud() ); // -// plots1.add( figures1.carbon() ); +// figures.add( figures1.carbon() ); // // -// plots1.add( figures2.fzkmFromTtime_vs_fzkmOrig() ); -// plots1.add( figures2.fzkmFromTtimeSum_vs_fzkmOrig() ); +// figures.add( figures2.fzkmFromTtime_vs_fzkmOrig() ); +// figures.add( figures2.fzkmFromTtimeSum_vs_fzkmOrig() ); // -// plots1.add( figures1.nkv_el03() ); -// plots1.add( figures1.nkv_carbon700() ); -// plots1.add( figures1.nkv_el03_carbon700() ); +// figures.add( figures1.nkv_el03() ); +// figures.add( figures1.nkv_carbon700() ); +// figures.add( figures1.nkv_el03_carbon700() ); // -// plots1.add( figures1.elasticities() ); -// plots1.add( figures1.fzkmDiff() ); -// plots1.add( figures1.nkv_el03_diff() ); -// plots1.add( figures1.dtv() ); -// plots1.add( figures1.fzkmNew() ); +// figures.add( figures1.elasticities() ); +// figures.add( figures1.fzkmDiff() ); +// figures.add( figures1.nkv_el03_diff() ); +// figures.add( figures1.dtv() ); +// figures.add( figures1.fzkmNew() ); // Induzierter Strassenmehrverkehr: - plotsZb.add( figures2.fzkmEl03_vs_fzkmOrig() ); -// plotsZb.add( figures2.fzkmFromEl03Delta_vs_fzkmOrig() ); - plotsZb.add( figures2.fzkmFromTtime_vs_fzkmOrig() ); -// plotsZb.add( figures2.fzkmFromTtimeDelta_vs_fzkmOrig() ); + figures.put( createHeader1( "Induzierter Strassenmehrverkehr (aus Elastizität 0,3):" ), figures2.fzkmEl03_vs_fzkmOrig() ); +// figures.add( figures2.fzkmFromEl03Delta_vs_fzkmOrig() ); + figures.put( createHeader1( "Induzierter Strassenmehrverkehr (aus konstantem Reisezeitbudget):" ), figures2.fzkmFromTtime_vs_fzkmOrig() ); +// figures.add( figures2.fzkmFromTtimeDelta_vs_fzkmOrig() ); // Abhängigkeit von Verkehrsnachfrage: - plotsZb.add( figures2.nkvNeu_vs_dtv( NKV_ORIG) ); -// plotsZb.add( figures2.nkvNeu_vs_dtv( NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD ) ); + figures.put( createHeader1( "Abhängigkeit NKV von Verkehrsmenge:" ), figures2.nkv_vs_dtv( NKV_ORIG ) ); +// figures.add( figures2.nkvNeu_vs_dtv( NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD ) ); // Veränderung NKV durch ... // ... Investitionskosten: - plotsZb.add( figures2.nkvNew_vs_nkvOrig( 10, NKV_INVCOSTTUD ) ); + figures.put( createHeader1( "Veränderung NKV durch ..." ) + createHeader2( "... veränderte Investitionskosten (deutl. Minderung NKVs in den meisten Fällen):" ), figures2.nkvNew_vs_nkvOrig( 10, NKV_INVCOSTTUD ) ); // ... induzierten Verkehr: - plotsZb.add( figures2.nkvNew_vs_nkvOrig( 10, NKV_ELTTIME ) ); + figures.put( createHeader2( "... veränderten induz. Strassenmehrverkehr (wenig Änderung):" ), figures2.nkvNew_vs_nkvOrig( 10, NKV_ELTTIME ) ); // ... erhöhten CO2-Kosten: - plotsZb.add( figures2.nkvNew_vs_nkvOrig( 10, NKV_CARBON700ptpr0 ) ); + figures.put( createHeader2( "... erhöhte CO2-Kosten (eher wenig Änderung):" ), figures2.nkvNew_vs_nkvOrig( 10, NKV_CARBON700ptpr0 ) ); + + // ... induz x CO2: + figures.put( createHeader2( "... Kombination induz. Strassenmehrverkehr + erh. CO2-Kosten (deutl. Minderung NKVs bei Kombination dieser beiden Einflüsse):" ), figures2.nkvNew_vs_nkvOrig( 10, NKV_ELTTIME_CARBON700ptpr0 )); // ... alle drei: - plotsZb.add( figures2.nkvNew_vs_nkvOrig( 10, NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD ) ); + figures.put( createHeader2( "... veränderte/erhöhte Investitionskosten/induzierten Verkehr/CO2-Kosten (nochmals deutl. Minderung NKVs in den meisten Fällen):" ), figures2.nkvNew_vs_nkvOrig( 10, NKV_ELTTIME_CARBON700ptpr0_INVCOSTTUD ) ); + + // ... plus eMob: + figures.put( createHeader2( "... zusätzlich Berücksichtigung E-Mobilität:" ), + figures2.nkvNew_vs_nkvOrig( 10, NKV_ELTTIME_CARBON700ptpr0_EMOB_INVCOSTTUD ) ); + + figures.put( createHeader1( "Inv.Kosten vs NKV mit veränderten/erhöhten Investitionskosten/induziertem Verkehr/CO2-Kosten/E-Mobilität:"), + figures2.getFigures( 10, NKV_ELTTIME_CARBON700ptpr0_EMOB_INVCOSTTUD ).get( 0 ) ); +// addHeaderPlusMultipleFigures( figures, createHeader1( "XXX vs. NKV mit veränderten/erhöhten Investitionskosten/induziertem Verkehr/CO2-Kosten/E-Mobilität:" ), +// figures2.getFigures( 10, NKV_ELTTIME_CARBON700ptpr0_EMOB_INVCOSTTUD ) ); + + // ... plus CO2 Preis 2000: + figures.put( createHeader1( "Inv.Kosten vs NKV mit veränderten/erhöhten Investitionskosten/induziertem Verkehr/CO2-Kosten++/E-Mobilität:"), + figures2.getFigures( 10, NKV_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD ).get( 0 ) ); + + + // N pro CO2: + table.addColumns( table.doubleColumn( NKV_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD ) + .multiply( table.doubleColumn( INVCOST_TUD ) ) + .divide( table.doubleColumn( CO2_ELTTIME ) ) + .setName( NProCo2_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD ) + ); + + figures.put( createDefaultKey( figures ), figures2.nProCo2_vs_nkv( NProCo2_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD, NKV_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD ) ); - // andere Darstellung "alle drei": - plotsZb.addAll( figures2.getFigures( 10, NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD ) ); + figures.put( createDefaultKey( figures ), figures2.getFigures( Integer.MAX_VALUE, NProCo2_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD ).get( 0 ) ); + + figures.put( createDefaultKey( figures ), figures2.getFigures( Integer.MAX_VALUE, NProCo2_ELTTIME_CARBON2000ptpr0_EMOB_INVCOSTTUD ).get( 1 ) ); // Änlichkeit zwischen carbon cost und Investitionskosten: - plotsZb.add( figures2.carbon_vs_invcostTud() ); + figures.put( createHeader1( "Ähnlichkeit CO2-Kosten und Investitionskosten:" ), figures2.carbon_vs_invcostTud() ); // ### nicht verwendet: // changes in investment cost: - plots2.add( figures2.invcost_tud_vs_orig() ); + figures.put( createDefaultKey( figures ), figures2.invcost_tud_vs_orig() ); -// plots2.add( figures2.cost_VS_nkvOrig() ); +// figures.add( figures2.cost_VS_nkvOrig() ); -// plots2.add( figures2.costOrigVsCumulativeCostOrig() ); +// figures.add( figures2.costOrigVsCumulativeCostOrig() ); -// plots2.addAll( figures2.getFigures( 5, NKV_ORIG ) ); -// plots2.addAll( figures2.getFigures( 5, NKV_ELTTIME_CARBON215_INVCOSTTUD ) ); +// figures.addAll( figures2.getFigures( 5, NKV_ORIG ) ); +// figures.addAll( figures2.getFigures( 5, NKV_ELTTIME_CARBON215_INVCOSTTUD ) ); -// plots2.add( figures2.invcosttud_vs_nkvEl03Cprice215Invcosttud( 5) ); -// plots2.add( figures2.cumulativeCostTud_vs_nkvEl03Cprice215InvcostTud(5 ) ); -// plots2.add( figures2.cumulativeCostTud_vs_nkvEl03Cprice215InvcostTud(Integer.MAX_VALUE ) ); -// plots2.add( figures2.invcosttud_vs_nkvEl03Cprice215Invcosttud( Integer.MAX_VALUE) ); +// figures.add( figures2.invcosttud_vs_nkvEl03Cprice215Invcosttud( 5) ); +// figures.add( figures2.cumulativeCostTud_vs_nkvEl03Cprice215InvcostTud(5 ) ); +// figures.add( figures2.cumulativeCostTud_vs_nkvEl03Cprice215InvcostTud(Integer.MAX_VALUE ) ); +// figures.add( figures2.invcosttud_vs_nkvEl03Cprice215Invcosttud( Integer.MAX_VALUE) ); // -// plots2.add( figures2.invcosttud_vs_nkvElttimeCarbon700Invcosttud(5) ); -//// plots2.add( figures2.invcost50_vs_NkvEl03Cprice700InvcostTud() ); -//// plots2.add( figures2.cumcost50_vs_nkvEl03Cprice700InvcostTud() ); -// plots2.add( figures2.invcosttud_vs_nkvElttimeCarbon2000Invcosttud() ); +// figures.add( figures2.invcosttud_vs_nkvElttimeCarbon700Invcosttud(5) ); +//// figures.add( figures2.invcost50_vs_NkvEl03Cprice700InvcostTud() ); +//// figures.add( figures2.cumcost50_vs_nkvEl03Cprice700InvcostTud() ); +// figures.add( figures2.invcosttud_vs_nkvElttimeCarbon2000Invcosttud() ); // -// plots2.add( figures2.carbon_vs_nkvEl03Cprice215Invcost50Capped5() ); +// figures.add( figures2.carbon_vs_nkvEl03Cprice215Invcost50Capped5() ); // -// plots2.add( figures2.nco2v_vs_vs_nkvElttimeCarbon700Invcosttud(5 ) ); +// figures.add( figures2.nco2v_vs_vs_nkvElttimeCarbon700Invcosttud(5 ) ); // === - StringBuilder page = new StringBuilder( MultiPlotUtils.pageTop() + System.lineSeparator() ); - for( int ii=0; ii" + str + ""; + } + static String createHeader2( String str ) { + return "

" + str + "

"; + } + static void addHeaderPlusMultipleFigures( Map figuresMap, String str, List
figuresList ) { + figuresMap.put( str, figuresList.removeFirst() ); + for( Figure figure : figuresList ){ + figuresMap.put( createDefaultKey( figuresMap ), figure ); + } + } + private static String createDefaultKey( Map figures ){ + return "

Plot Nr. " + figures.size() + ":

"; + } } diff --git a/src/test/java/org/tub/vsp/bvwp/computation/ComputationKNTest.java b/src/test/java/org/tub/vsp/bvwp/computation/ComputationKNTest.java index e6df894..1e5f913 100644 --- a/src/test/java/org/tub/vsp/bvwp/computation/ComputationKNTest.java +++ b/src/test/java/org/tub/vsp/bvwp/computation/ComputationKNTest.java @@ -18,11 +18,11 @@ void test() { , 5305.683); double baukosten = 2737.176; { - double nkv = nkv(new Modifications(145., 0., 1, 1. ), amounts, benefits, baukosten ); + double nkv = nkv(new Modifications(145., 0., 1, 1., 1. ), amounts, benefits, baukosten ); Assertions.assertEquals(1.938378, nkv, 0.001); } { - double nkv = nkv(new Modifications(5. * 145., amounts.getPkwkm_induz() * 4., 1, 1. ), amounts, benefits, baukosten ); + double nkv = nkv(new Modifications(5. * 145., amounts.getPkwkm_induz() * 4., 1, 1., 1. ), amounts, benefits, baukosten ); Assertions.assertEquals(-0.2963518828995041, nkv, 0.001); } @@ -30,7 +30,7 @@ void test() { // and lkw: amounts = new ComputationKN.Amounts(131.53, 143.95, 9.75, -18.56, 1.46, 0.13, 48_689.94, 48_689.94); { - double nkv = nkv(new Modifications(5. * 145., amounts.getPkwkm_induz() * 4., 1, 1. ), amounts, benefits, baukosten ); + double nkv = nkv(new Modifications(5. * 145., amounts.getPkwkm_induz() * 4., 1, 1., 1. ), amounts, benefits, baukosten ); Assertions.assertEquals(-0.089529, nkv, 0.001); } }