matsim-org / matsim-libs

Multi-Agent Transport Simulation
www.matsim.org
464 stars 435 forks source link

Matsim's emission contrib #2453

Closed neda-git closed 1 year ago

neda-git commented 1 year ago

Hello, I would like to use matsim's emission contrib, I exported the hbefa data and converted to the csv, when I ran that I got the errors, could you please help me? thank you in advance.

Exception in thread "main" com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 at org.matsim.contrib.emissions.EmissionModule.(EmissionModule.java:65) while locating org.matsim.contrib.emissions.EmissionModule

1 error at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:226) at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1053) at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1086) at org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents.main(RunComputeEmissionsEvents.java:72) Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 at org.matsim.contrib.emissions.HbefaTables.mapAmbientCondPattern2ParkingTime(HbefaTables.java:119) at org.matsim.contrib.emissions.HbefaTables.createColdKey(HbefaTables.java:80) at org.matsim.contrib.emissions.HbefaTables.load(HbefaTables.java:57) at org.matsim.contrib.emissions.HbefaTables.loadAverageCold(HbefaTables.java:38) at org.matsim.contrib.emissions.EmissionModule.createLookupTables(EmissionModule.java:144) at org.matsim.contrib.emissions.EmissionModule.(EmissionModule.java:73) at org.matsim.contrib.emissions.EmissionModule$$FastClassByGuice$$3f5bb797.newInstance() at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306) at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050) ... 2 more

kainagel commented 1 year ago

Dear neda-git, as usual difficult to tell without the full context. I think that the offending line is

        String parkingTimeString = string.split(",")[1];

If so, then after the split there is no element [1]. Either the string is empty, or it does not contain a comma. This is called from

        key.setParkingTime(mapAmbientCondPattern2ParkingTime(record.get("AmbientCondPattern")));

So it looks like your AmbientCondPattern column is not there, or not filled, or does not contain a comma.

@rgraebe , could you please take note of this? We need to provide better error messages if the input files contain mistakes.

neda-git commented 1 year ago

Dear @kainagel, Thank you for your response, as an example here is the header and some rows of my csv data:

EFA_ColdStart_Vehcat_2015_Cold_Average.csv

Case;VehCat;Year;TrafficScenario;Component;RoadCat;AmbientCondPattern;EFA_weighted;EFA_km_weighted;EFA_WTT_weighted;EFA_WTT_km_weighted;EFA_WTW_weighted;EFA_WTW_km_weighted

2015_Cold_Average[4.2.2];pass. car;2015;REF F HB42;HC;Urban;Ø/France - Avg;0,575411737;;;;; 2015_Cold_Average[4.2.2];pass. car;2015;REF F HB42;HC;Urban;Ø/France - Avg - spring;0,576464236;;;;;

EFA_ColdStart_Subsegm_2015_Cold_Detailed.csv

Case;VehCat;Year;TrafficScenario;Component;RoadCat;AmbientCondPattern;IDSubsegment;Subsegment;Technology;SizeClasse;EmConcept;KM;%OfSubsegment;EFA;EFA_weighted;EFA_km;EFA_km_weighted;EFA_WTT;EFA_WTT_km;EFA_WTW;EFA_WTW_km 2015_Cold_Detailed[4.2.2];pass. car;2015;REF F HB42;HC;Urban;Ø/France - Avg;111903;PC petrol ECE-15'03;petrol (4S);not specified;PC P Euro-0;212826,0313;7,67883E-05;7,009304523;0,575411737;;;;;;

EFA_HOT_Subsegm_2015_Hot_Detailed.csv

Case;VehCat;Year;TrafficScenario;Component;RoadCat;TrafficSit;Gradient;IDSubsegment;Subsegment;Technology;SizeClasse;EmConcept;KM;%OfSubsegment;V;V_0%;V_100%;EFA;EFA_0%;EFA_100%;V_weighted;V_weighted_0%;V_weighted_100%;EFA_weighted;EFA_weighted_0%;EFA_weighted_100%;AmbientCondPattern;EFA_WTT;EFA_WTT_0%;EFA_WTT_100%;EFA_WTW;EFA_WTW_0%;EFA_WTW_100%

2015_HotDetailed[4.2.2];pass. car;2020;;HC;;RUR/MW/80/Freeflow;0%;132932;PC CNG/petrol Euro-3(P);bifuel CNG/petrol;not specified;PC CNG;50000;1;82,81607056;;;0,009782017;;;;;;;;;Ø/France - Avg;;;;;;

EFA_HOT_Vehcat_2015_Hot_Average.csv

2015_Hot_Average[4.2.2];pass. car;2015;REF F HB42 ;SO2 ;Urban ;URB/Access/50/St+Go2; 0%; 5,839002609; 0,00208513;Ø/France - Avg;;

2015_Hot_Average[4.2.2];HGV;2015;REF F HB42;HC;MW;RUR/MW/80/Freeflow;0%;81,29037476;0,066031165;;;

I've exported the data by following the steps of this link: https://www.matsim.org/apidocs/emissions/0.7.0/org/matsim/contrib/emissions/package-summary.html

My Hbefa version is 4.2.

I found some rows for AmbientCondPattern aren't filled, Do you think, I should select all patterns in COLD START EXCESS EMISSION FACTORS?

neda-git commented 1 year ago

I tried with: [sample_41_EFA_ColdStart_SubSegm_2020detailed.csv] [sample_41_EFA_ColdStart_vehcat_2020average.csv] [sample_41_EFA_HOT_SubSegm_2020detailed.csv] [sample_41_EFA_HOT_vehcat_2020average.csv]

I got the different errors:

2023-03-22T14:10:16,457 INFO EventsManagerImpl:137 event # 1 2023-03-22T14:10:16,458 INFO EventsManagerImpl:137 event # 4 2023-03-22T14:10:16,458 INFO VehicleUtils:324 adding scenario element for allvehicles container 2023-03-22T14:10:16,458 INFO VehicleUtils:337 vehicleId=177837 not in allVehicles; trying standard vehicles container ... 2023-03-22T14:10:16,461 INFO ColdEmissionAnalysisModule:325 try reading detailed values 2023-03-22T14:10:16,461 INFO ColdEmissionAnalysisModule:326 This message given only once. 2023-03-22T14:10:16,461 INFO ColdEmissionAnalysisModule:327 Future occurences of this logging statement are suppressed. 2023-03-22T14:10:16,462 INFO ColdEmissionAnalysisModule:336 try to rewrite from HBEFA3 to HBEFA4 and lookup in detailed table again 2023-03-22T14:10:16,462 INFO ColdEmissionAnalysisModule:337 This message given only once. 2023-03-22T14:10:16,462 INFO ColdEmissionAnalysisModule:338 Future occurences of this logging statement are suppressed. 2023-03-22T14:10:16,468 WARN ColdEmissionAnalysisModule:357 did not find emission factor for efkey=PASSENGER_CAR; PM; 13; 1; diesel; <1,4L; PC diesel Euro-3 (DPF) 2023-03-22T14:10:16,468 WARN ColdEmissionAnalysisModule:358 re-written to PASSENGER_CAR; PM; 13; 1; diesel; average; average 2023-03-22T14:10:16,468 WARN ColdEmissionAnalysisModule:359 will try it with '; average; average' 2023-03-22T14:10:16,468 WARN ColdEmissionAnalysisModule:360 This message given only once. 2023-03-22T14:10:16,468 WARN ColdEmissionAnalysisModule:361 Future occurences of this logging statement are suppressed. 2023-03-22T14:10:16,469 INFO ColdEmissionAnalysisModule:325 try reading detailed values 2023-03-22T14:10:16,469 INFO ColdEmissionAnalysisModule:326 This message given only once. 2023-03-22T14:10:16,469 INFO ColdEmissionAnalysisModule:327 Future occurences of this logging statement are suppressed. 2023-03-22T14:10:16,469 INFO ColdEmissionAnalysisModule:336 try to rewrite from HBEFA3 to HBEFA4 and lookup in detailed table again 2023-03-22T14:10:16,469 INFO ColdEmissionAnalysisModule:337 This message given only once. 2023-03-22T14:10:16,469 INFO ColdEmissionAnalysisModule:338 Future occurences of this logging statement are suppressed. 2023-03-22T14:10:16,469 WARN ColdEmissionAnalysisModule:357 did not find emission factor for efkey=PASSENGER_CAR; BC_exhaust; 13; 1; diesel; <1,4L; PC diesel Euro-3 (DPF) 2023-03-22T14:10:16,469 WARN ColdEmissionAnalysisModule:358 re-written to PASSENGER_CAR; BC_exhaust; 13; 1; diesel; average; average 2023-03-22T14:10:16,469 WARN ColdEmissionAnalysisModule:359 will try it with '; average; average' 2023-03-22T14:10:16,469 WARN ColdEmissionAnalysisModule:360 This message given only once. 2023-03-22T14:10:16,469 WARN ColdEmissionAnalysisModule:361 Future occurences of this logging statement are suppressed. 2023-03-22T14:10:16,471 INFO WarmEmissionHandler:157 Vehicle 177837 is ending its first activity of the day and leaving link 32345 without having entered. 2023-03-22T14:10:16,472 INFO WarmEmissionHandler:158 This is because of the MATSim logic that there is no link enter event for the link of the first activity 2023-03-22T14:10:16,472 INFO WarmEmissionHandler:159 Thus, no emissions are calculated for this link leave event. 2023-03-22T14:10:16,472 INFO VehicleUtils:337 vehicleId=177837 not in allVehicles; trying standard vehicles container ... 2023-03-22T14:10:16,472 INFO VehicleUtils:337 vehicleId=177837 not in allVehicles; trying standard vehicles container ... Exception in thread "main" java.lang.RuntimeException: At least the FREEFLOW condition must be specified for all emission factor keys. It was not found for PASSENGER_CAR; null; URB/Local/60; null; diesel; <1,4L; PC diesel Euro-3 (DPF) at org.matsim.contrib.emissions.WarmEmissionAnalysisModule.getTrafficSituation(WarmEmissionAnalysisModule.java:569) at org.matsim.contrib.emissions.WarmEmissionAnalysisModule.calculateWarmEmissions(WarmEmissionAnalysisModule.java:292) at org.matsim.contrib.emissions.WarmEmissionAnalysisModule.checkVehicleInfoAndCalculateWarmEmissions(WarmEmissionAnalysisModule.java:237) at org.matsim.contrib.emissions.WarmEmissionHandler.handleEvent(WarmEmissionHandler.java:219) at org.matsim.core.events.EventsManagerImpl.callHandlerFast(EventsManagerImpl.java:268) at org.matsim.core.events.EventsManagerImpl.processEvent(EventsManagerImpl.java:141) at org.matsim.core.events.EventsReaderXMLv1.startEvent(EventsReaderXMLv1.java:104) at org.matsim.core.events.EventsReaderXMLv1.startTag(EventsReaderXMLv1.java:80) at org.matsim.core.events.MatsimEventsReader$XmlEventsReader.startTag(MatsimEventsReader.java:140) at org.matsim.core.utils.io.MatsimXmlParser.startElement(MatsimXmlParser.java:347) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:510) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:183) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:351) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2710) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112) at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888) at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824) at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1216) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635) at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:324) at org.matsim.core.utils.io.MatsimXmlParser.parse(MatsimXmlParser.java:197) at org.matsim.core.utils.io.MatsimXmlParser.readFile(MatsimXmlParser.java:149) at org.matsim.core.events.MatsimEventsReader.readFile(MatsimEventsReader.java:79)

rgraebe commented 1 year ago

Dear @neda-git, looking at your input data structure and specifically the contents of your AmbientCondPattern column for all of your different files, I picked up a few things.

here is the header and some rows of my csv data:

EFA_ColdStart_Vehcat_2015_Cold_Average.csv

Case;VehCat;Year;TrafficScenario;Component;RoadCat;AmbientCondPattern;EFA_weighted;EFA_km_weighted;EFA_WTT_weighted;EFA_WTT_km_weighted;EFA_WTW_weighted;EFA_WTW_km_weighted

2015_Cold_Average[4.2.2];pass. car;2015;REF F HB42;HC;Urban;Ø/France - Avg;0,575411737;;;;; 2015_Cold_Average[4.2.2];pass. car;2015;REF F HB42;HC;Urban;Ø/France - Avg - spring;0,576464236;;;;;

These are the two methods within contrib/emissions/HbefaTables.java that use content read from the AmbientCondPattern column:

    private static int mapAmbientCondPattern2Distance(String string) {
        String distanceString = string.split(",")[2];
        String upperbound = distanceString.split("-")[1];
        return Integer.parseInt(upperbound.split("k")[0]);
    }

    private static int mapAmbientCondPattern2ParkingTime(String string) {

        String parkingTimeString = string.split(",")[1];
        if (parkingTimeString.equals(">12h")) {
            return 13;
        } else {
            String upperbound = parkingTimeString.split("-")[1];
            return Integer.parseInt(upperbound.split("h")[0]);
        }
    }

As you can see, these methods convert the string content to parking time and distance, however, in none of your file examples are the relevant information to extract this data from. This tells me that something went wrong (or cannot yet be accommodated/inferred) with your export from HBEFA.

To answer this:

Do you think, I should select all patterns in COLD START EXCESS EMISSION FACTORS?

The process, as you also mention from contrib/emissions/package-summary.html states that you should be selecting "all "patterns" with average temperature, detailed parking time (0-1h .. >12h), and detailed distance (0-1km and 1-2km)". From what I know, this should probably not be something like "Ø/France - Avg", which you have. Can you try to imitate the process to arrive at a csv file where you have these parking times and distances contained in your AmbientCondPattern column?

rgraebe commented 1 year ago

I tried with: [sample_41_EFA_ColdStart_SubSegm_2020detailed.csv] [sample_41_EFA_ColdStart_vehcat_2020average.csv] [sample_41_EFA_HOT_SubSegm_2020detailed.csv] [sample_41_EFA_HOT_vehcat_2020average.csv]

@neda-git, to answer you about this, refer to the error:

Exception in thread "main" java.lang.RuntimeException: At least the FREEFLOW condition must be specified for all emission factor keys. It was not found for PASSENGER_CAR; null; URB/Local/60; null; diesel; <1,4L; PC diesel Euro-3 (DPF)

This exception occurs when the hbefa file provided does not provide emission factors (a record in the hbefa csv file) for the specific vehicles in your scenario. Here, it started to look for the record with the FREEFLOW traffic condition, but couldn't find it. These "sample_41..." input files are small extracts from the more "complete" hbefa files (that you might need in your scenario), so it would make sense that they cause errors because they only serve a certain purpose in many test and example scenarios.

As a starting point, you can open sample_41_EFA_HOT_vehcat_2020average.csv and compare the contents with the record shown in the error _"PASSENGERCAR; null; URB/Local/60; null; diesel; <1,4L; PC diesel Euro-3 (DPF)". You will find that there is no URB/Local/60 traffic situation for the passenger cars - once again, because this is only a sample hbefa file...

I hope this makes the origin of the error clear!

neda-git commented 1 year ago

Dear@rgraebe, Thank you for taking time to answer my questions, I will try to imitate the process to arrive at a csv file as you told me. I will come back to you soon. Ich danke dir.

neda-git commented 1 year ago

Hello @rgraebe , @kainagel,

Related to my hbefa data, I tried to export and complete the data, now I got the other errors, do you think the errors can happen due to my hbefa data? the report is here:

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance. 2023-03-28T10:43:24,045 INFO CommandLine:505 Received 0 positional command line arguments: 2023-03-28T10:43:24,047 INFO CommandLine:506
2023-03-28T10:43:24,047 INFO CommandLine:528 Received 5 command line options with 0 prefixes: 2023-03-28T10:43:24,047 INFO CommandLine:533 config-path = pasdecalais_config.xml 2023-03-28T10:43:24,047 INFO CommandLine:533 hbefa-cold-avg = ./EFA_ColdStart_Vehcat_2015_cold_average.csv 2023-03-28T10:43:24,048 INFO CommandLine:533 hbefa-cold-detailed = ./EFA_ColdStart_Subsegm_2015_cold_detailed.csv 2023-03-28T10:43:24,048 INFO CommandLine:533 hbefa-hot-avg = ./EFA_HOT_Vehcat_2015_Hot_Average-1.csv 2023-03-28T10:43:24,048 INFO CommandLine:533 hbefa-hot-detailed = ./EFA_HOT_Subsegm_2015_hot_detailed.csv 2023-03-28T10:43:24,146 INFO IOUtils:187 Resolved pasdecalais_config.xml to pasdecalais_config.xml 2023-03-28T10:43:24,149 INFO Config:572 setting context to [file:/home/nedam/PycharmProjects/ile-de-france2/output/] 2023-03-28T10:43:24,202 INFO Version:21 HV000001: Hibernate Validator null 2023-03-28T10:43:24,306 INFO MatsimXmlParser:160 starting to parse xml from url file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_config.xml ... 2023-03-28T10:43:24,339 INFO ConfigReader:102 using config_v2-reader 2023-03-28T10:43:24,340 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/config_v2.dtd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:24,802 INFO GlobalConfigGroup:92 setting number of threads to: 4 2023-03-28T10:43:24,805 WARN PlanCalcScoreConfigGroup$ReflectiveDelegate:1622 Setting pathSizeLogitBeta different from zero is experimental. KN, Sep'08 2023-03-28T10:43:24,820 INFO PlanCalcScoreConfigGroup:554 scoring parameters for subpopulation null were just replaced. 2023-03-28T10:43:24,821 WARN PlansCalcRouteConfigGroup:342 The first mode routing params that are explicitly defined clear the default mode routing params. This functionality was removed for 2023-03-28T10:43:24,821 WARN PlansCalcRouteConfigGroup:343 some weeks in the development head, after release 11.x, and before release 12.x; it is now back. If you want to avoid this 2023-03-28T10:43:24,822 WARN PlansCalcRouteConfigGroup:344 warning, use clearModeRoutingParams(true) in code, and "clearDefaultTeleportedModeParams"=true in xml config. 2023-03-28T10:43:24,828 INFO Config:572 setting context to [file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_config.xml] 2023-03-28T10:43:24,847 INFO ScenarioLoaderImpl:134 loading network from file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_network.xml.gz 2023-03-28T10:43:24,848 INFO MatsimXmlParser:160 starting to parse xml from url file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_network.xml.gz ... 2023-03-28T10:43:24,937 INFO MatsimNetworkReader:120 using network_v2-reader. 2023-03-28T10:43:24,937 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/network_v2.dtd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:25,033 INFO NetworkImpl:163 node # 1 2023-03-28T10:43:25,034 INFO NetworkImpl:163 node # 4 2023-03-28T10:43:25,036 INFO NetworkImpl:163 node # 16 2023-03-28T10:43:25,042 INFO NetworkImpl:163 node # 64 2023-03-28T10:43:25,052 INFO NetworkImpl:163 node # 256 2023-03-28T10:43:25,066 INFO NetworkImpl:163 node # 1024 2023-03-28T10:43:25,094 INFO NetworkImpl:163 node # 4096 2023-03-28T10:43:25,165 INFO NetworkImpl:163 node # 16384 2023-03-28T10:43:25,366 INFO NetworkImpl:163 node # 65536 2023-03-28T10:43:25,472 INFO NetworkImpl:159 link # 1 2023-03-28T10:43:25,474 INFO NetworkImpl:159 link # 4 2023-03-28T10:43:25,476 INFO NetworkImpl:159 link # 16 2023-03-28T10:43:25,485 INFO NetworkImpl:159 link # 64 2023-03-28T10:43:25,509 INFO NetworkImpl:159 link # 256 2023-03-28T10:43:25,534 WARN LinkImpl:125 length=0.0 of link id 100555 may cause problems 2023-03-28T10:43:25,535 WARN LinkImpl:127 Future occurences of this logging statement are suppressed. 2023-03-28T10:43:25,556 INFO NetworkImpl:159 link # 1024 2023-03-28T10:43:25,682 INFO NetworkImpl:159 link # 4096 2023-03-28T10:43:26,038 INFO NetworkImpl:159 link # 16384 2023-03-28T10:43:26,656 INFO NetworkImpl:159 link # 65536 2023-03-28T10:43:28,298 INFO ScenarioLoaderImpl:159 loading facilities from file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_facilities.xml.gz 2023-03-28T10:43:28,299 INFO MatsimXmlParser:160 starting to parse xml from url file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_facilities.xml.gz ... 2023-03-28T10:43:28,309 INFO MatsimFacilitiesReader:137 using facilities_v1-reader. 2023-03-28T10:43:28,309 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/facilities_v1.dtd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:28,641 INFO ScenarioLoaderImpl:168 loaded 42169 facilities from file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_facilities.xml.gz 2023-03-28T10:43:28,641 INFO ScenarioLoaderImpl:187 no facility-attributes file set in config, not loading any facility attributes 2023-03-28T10:43:28,641 INFO ScenarioLoaderImpl:195 loading population from file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_population.xml.gz 2023-03-28T10:43:28,645 INFO MatsimXmlParser:160 starting to parse xml from url file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_population.xml.gz ... 2023-03-28T10:43:28,648 INFO PopulationReader:123 using population_v6-reader. 2023-03-28T10:43:28,648 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/population_v6.dtd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:28,740 WARN PopulationReaderMatsimV6:213 coordinate transformation defined both in config and in input file: setting from input file will be used 2023-03-28T10:43:28,760 INFO PopulationImpl:105 person # 1 2023-03-28T10:43:28,770 INFO PopulationImpl:105 person # 4 2023-03-28T10:43:28,791 INFO PopulationImpl:105 person # 16 2023-03-28T10:43:28,822 INFO PopulationImpl:105 person # 64 2023-03-28T10:43:28,868 INFO PopulationImpl:105 person # 256 2023-03-28T10:43:29,161 INFO PopulationImpl:105 person # 1024 2023-03-28T10:43:29,268 INFO PopulationUtils:1087 person # 1498 2023-03-28T10:43:29,268 INFO ScenarioLoaderImpl:243 no person-attributes file set in config, not loading any person attributes 2023-03-28T10:43:29,268 INFO ScenarioLoaderImpl:250 loading households from file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_households.xml.gz 2023-03-28T10:43:29,269 INFO MatsimXmlParser:160 starting to parse xml from url file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_households.xml.gz ... 2023-03-28T10:43:29,272 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/households_v1.0.xsd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:29,368 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/matsimCommon.xsd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:29,474 INFO Counter:69 households # 1 2023-03-28T10:43:29,474 INFO Counter:69 households # 2 2023-03-28T10:43:29,475 INFO Counter:69 households # 4 2023-03-28T10:43:29,476 INFO Counter:69 households # 8 2023-03-28T10:43:29,479 INFO Counter:69 households # 16 2023-03-28T10:43:29,485 INFO Counter:69 households # 32 2023-03-28T10:43:29,493 INFO Counter:69 households # 64 2023-03-28T10:43:29,506 INFO Counter:69 households # 128 2023-03-28T10:43:29,520 INFO Counter:69 households # 256 2023-03-28T10:43:29,536 INFO Counter:69 households # 512 2023-03-28T10:43:29,544 INFO Counter:74 households # 644 2023-03-28T10:43:29,544 INFO ScenarioLoaderImpl:252 households loaded. 2023-03-28T10:43:29,544 INFO ScenarioLoaderImpl:273 no household-attributes file set in config, not loading any household attributes 2023-03-28T10:43:29,546 INFO MatsimXmlParser:160 starting to parse xml from url file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_transit_schedule.xml.gz ... 2023-03-28T10:43:29,549 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/transitSchedule_v2.dtd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:29,927 INFO ScenarioLoaderImpl:324 loading transit vehicles from pasdecalais_transit_vehicles.xml.gz 2023-03-28T10:43:29,928 INFO MatsimXmlParser:160 starting to parse xml from url file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_transit_vehicles.xml.gz ... 2023-03-28T10:43:29,930 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/vehicleDefinitions_v2.0.xsd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:30,020 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/matsimCommon.xsd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:30,109 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/vehicleDefinitionsEnumTypes.xsd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:30,205 INFO MatsimVehicleReader$VehicleReader:75 Found following schemaLocation in vehicle definition file: http://www.matsim.org/files/dtd http://www.matsim.org/files/dtd/vehicleDefinitions_v2.0.xsd 2023-03-28T10:43:30,207 INFO VehicleReaderV2:22 Using org.matsim.vehicles.VehicleReaderV2 2023-03-28T10:43:30,210 INFO Counter:69 [VehiclesImpl] added vehicle # 1 2023-03-28T10:43:30,211 INFO Counter:69 [VehiclesImpl] added vehicle # 2 2023-03-28T10:43:30,211 INFO Counter:69 [VehiclesImpl] added vehicle # 4 2023-03-28T10:43:30,211 INFO Counter:69 [VehiclesImpl] added vehicle # 8 2023-03-28T10:43:30,212 INFO Counter:69 [VehiclesImpl] added vehicle # 16 2023-03-28T10:43:30,212 INFO Counter:69 [VehiclesImpl] added vehicle # 32 2023-03-28T10:43:30,213 INFO Counter:69 [VehiclesImpl] added vehicle # 64 2023-03-28T10:43:30,214 INFO Counter:69 [VehiclesImpl] added vehicle # 128 2023-03-28T10:43:30,216 INFO Counter:69 [VehiclesImpl] added vehicle # 256 2023-03-28T10:43:30,220 INFO Counter:69 [VehiclesImpl] added vehicle # 512 2023-03-28T10:43:30,221 INFO ScenarioLoaderImpl:334 loading vehicles from pasdecalais_vehicles.xml.gz 2023-03-28T10:43:30,221 INFO MatsimXmlParser:160 starting to parse xml from url file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_vehicles.xml.gz ... 2023-03-28T10:43:30,231 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/vehicleDefinitions_v2.0.xsd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:30,322 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/matsimCommon.xsd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:30,412 INFO MatsimXmlParser:276 Trying to load http://www.matsim.org/files/dtd/vehicleDefinitionsEnumTypes.xsd. In some cases (e.g. network interface up but no connection), this may take a bit. 2023-03-28T10:43:30,508 INFO MatsimVehicleReader$VehicleReader:75 Found following schemaLocation in vehicle definition file: http://www.matsim.org/files/dtd http://www.matsim.org/files/dtd/vehicleDefinitions_v2.0.xsd 2023-03-28T10:43:30,509 INFO VehicleReaderV2:22 Using org.matsim.vehicles.VehicleReaderV2 2023-03-28T10:43:30,516 INFO Counter:69 [VehiclesImpl] added vehicle # 1 2023-03-28T10:43:30,516 INFO Counter:69 [VehiclesImpl] added vehicle # 2 2023-03-28T10:43:30,517 INFO Counter:69 [VehiclesImpl] added vehicle # 4 2023-03-28T10:43:30,517 INFO Counter:69 [VehiclesImpl] added vehicle # 8 2023-03-28T10:43:30,518 INFO Counter:69 [VehiclesImpl] added vehicle # 16 2023-03-28T10:43:30,519 INFO Counter:69 [VehiclesImpl] added vehicle # 32 2023-03-28T10:43:30,521 INFO Counter:69 [VehiclesImpl] added vehicle # 64 2023-03-28T10:43:30,524 INFO Counter:69 [VehiclesImpl] added vehicle # 128 2023-03-28T10:43:30,529 INFO Counter:69 [VehiclesImpl] added vehicle # 256 2023-03-28T10:43:30,534 INFO Counter:69 [VehiclesImpl] added vehicle # 512 2023-03-28T10:43:30,543 INFO Counter:69 [VehiclesImpl] added vehicle # 1024 WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/home/nedam/PycharmProjects/ile-de-france2/output/pasdecalais_run.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2023-03-28T10:43:30,983 INFO Injector:81 === printInjector start === 2023-03-28T10:43:30,984 INFO Injector:85 org.matsim.api.core.v01.Scenario 2023-03-28T10:43:30,984 INFO Injector:86 --> provider: ConstantFactory{value=org.matsim.core.scenario.MutableScenario@289778cd}[Scopes.SINGLETON] 2023-03-28T10:43:30,985 INFO Injector:87 --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:65) 2023-03-28T10:43:30,985 INFO Injector:89 --> scope: eager singleton 2023-03-28T10:43:30,985 INFO Injector:94 ==full==> InstanceBinding{key=Key[type=org.matsim.api.core.v01.Scenario, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:65), instance=org.matsim.core.scenario.MutableScenario@289778cd} 2023-03-28T10:43:30,985 INFO Injector:96 2023-03-28T10:43:30,985 INFO Injector:85 org.matsim.core.api.experimental.events.EventsManager 2023-03-28T10:43:30,985 INFO Injector:86 --> provider: ConstantFactory{value=org.matsim.core.events.EventsManagerImpl@7495699f}[Scopes.SINGLETON] 2023-03-28T10:43:30,985 INFO Injector:87 --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:66) 2023-03-28T10:43:30,986 INFO Injector:89 --> scope: eager singleton 2023-03-28T10:43:30,986 INFO Injector:94 ==full==> InstanceBinding{key=Key[type=org.matsim.core.api.experimental.events.EventsManager, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:66), instance=org.matsim.core.events.EventsManagerImpl@7495699f} 2023-03-28T10:43:30,986 INFO Injector:96 2023-03-28T10:43:30,986 INFO Injector:85 org.matsim.contrib.emissions.EmissionModule 2023-03-28T10:43:30,986 INFO Injector:86 --> provider: com.google.inject.internal.ConstructorBindingImpl$Factory@7c2312fa 2023-03-28T10:43:30,986 INFO Injector:87 --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:67) 2023-03-28T10:43:30,986 INFO Injector:89 --> scope: Scopes.NO_SCOPE 2023-03-28T10:43:30,986 INFO Injector:94 ==full==> ConstructorBinding{key=Key[type=org.matsim.contrib.emissions.EmissionModule, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:67), scope=Scopes.NO_SCOPE} 2023-03-28T10:43:30,986 INFO Injector:96 2023-03-28T10:43:30,986 INFO Injector:99 === printInjector end === 2023-03-28T10:43:30,989 INFO EmissionModule:141 entering createLookupTables 2023-03-28T10:43:34,668 INFO EmissionModule:156 leaving createLookupTables 2023-03-28T10:43:34,795 INFO EmissionModule:196 entering createEmissionHandlers Exception in thread "main" com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting constructor, java.lang.RuntimeException: inconsistent at org.matsim.contrib.emissions.EmissionModule.(EmissionModule.java:65) while locating org.matsim.contrib.emissions.EmissionModule

1 error at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:226) at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1053) at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1086) at org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents.main(RunComputeEmissionsEvents.java:72) Caused by: java.lang.RuntimeException: inconsistent at org.matsim.contrib.emissions.WarmEmissionAnalysisModule.(WarmEmissionAnalysisModule.java:171) at org.matsim.contrib.emissions.WarmEmissionHandler.(WarmEmissionHandler.java:80) at org.matsim.contrib.emissions.EmissionModule.createEmissionHandlers(EmissionModule.java:200) at org.matsim.contrib.emissions.EmissionModule.(EmissionModule.java:74) at org.matsim.contrib.emissions.EmissionModule$$FastClassByGuice$$3f5bb797.newInstance() at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306) at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050) ... 2 more

kt86 commented 1 year ago

The error points, that a consistency check of the hbefa tables says, that they are inconsistent: grafik

In the emissionConfigGroup, you can set, what level of detail you prefer for the check: e.g. in code by something like ... emissionsConfigGroup.setHbefaTableConsistencyCheckingLevel(EmissionsConfigGroup.HbefaTableConsistencyCheckingLevel.<....>); or in your config file.

Please see the corresponding comment for some more information: https://github.com/matsim-org/matsim-libs/blob/df88413d1fdcce732284fa53dd6728b22ad0bd12/contribs/emissions/src/main/java/org/matsim/contrib/emissions/utils/EmissionsConfigGroup.java#L83-L88

@rgraebe : Maybe you (we) can also provide some more information in the Exception besides "inconsistent"? Thanks a lot.

neda-git commented 1 year ago

Thanks @kt86, I will try that.

rgraebe commented 1 year ago

Caused by: java.lang.RuntimeException: inconsistent at org.matsim.contrib.emissions.WarmEmissionAnalysisModule.(WarmEmissionAnalysisModule.java:171)

@neda-git, related to this part in your error stack trace, I can advise you on the following:

There is a consistency check in the WarmEmissionAnalysisModule that checks the consistency of your detailed hbefa file (i.e. ./EFA_HOT_Subsegm_2015_hot_detailed.csv for you). This consistency check looks like this (extracted from WarmEmissionAnalysisModule):

// ... the thing to check would be if for each existing
//  roadCategory x vehicleCategory x vehicleAttribute x pollutant
// there is a freeflow and a stopgo entry.  Maybe something like this here:
Set<String> freeflowSet = new HashSet<>();
Set<String> stopgoSet = new HashSet<>();
for (HbefaWarmEmissionFactorKey key : detailedHbefaWarmTable.keySet()) {
String syntheticKey = key.getRoadCategory() + "--" + key.getVehicleCategory() + "--" + key.getVehicleAttributes() + "--" + key.getComponent();
switch ( key.getTrafficSituation() ) {
    case FREEFLOW -> freeflowSet.add( syntheticKey );
    case STOPANDGO -> stopgoSet.add( syntheticKey );
    default -> { } // do nothing
}
}
for (String syntheticKey : freeflowSet) {
if (!stopgoSet.contains(syntheticKey)) {
    throw new RuntimeException("inconsistent");
}
}
for (String syntheticKey : stopgoSet) {
if (!freeflowSet.contains(syntheticKey)) {
    throw new RuntimeException("inconsistent");
}
}

Your error creeps in here:

at org.matsim.contrib.emissions.WarmEmissionAnalysisModule.(WarmEmissionAnalysisModule.java:171)

... at line 171. In the code extract, this is here:

for (String syntheticKey : stopgoSet) { if (!freeflowSet.contains(syntheticKey)) { throw new RuntimeException("inconsistent"); }

meaning that within your detailed hbefa file, for some roadCategory x vehicleCategory x vehicleAttribute x pollutant combination, there is a freeflow entry missing. I would also start troubleshooting here...

neda-git commented 1 year ago

Thanks Dear @rgraebe, It's clear now.

neda-git commented 1 year ago

Dear all, I got the following error, I checked my hbefa hot detailed and the other csv data, but I didn't find any problem in my csv, I checked it for finding the extra semicolon, any space etc but i didn't find any anomaly related to this error:

java.lang.IllegalArgumentException: Index for header 'Component' is 4 but CSVRecord only has 1 values! at org.apache.commons.csv.CSVRecord.get(CSVRecord.java:129) at org.matsim.contrib.emissions.HbefaTables.setCommonParametersOnKey(HbefaTables.java:88) at org.matsim.contrib.emissions.HbefaTables.createWarmKey(HbefaTables.java:69) at org.matsim.contrib.emissions.HbefaTables.lambda$loadDetailedWarm$1(HbefaTables.java:31) at org.matsim.contrib.emissions.HbefaTables.load(HbefaTables.java:57) at org.matsim.contrib.emissions.HbefaTables.loadDetailedWarm(HbefaTables.java:30) at org.matsim.contrib.emissions.EmissionModule.createLookupTables(EmissionModule.java:152) at org.matsim.contrib.emissions.EmissionModule.(EmissionModule.java:73) at org.matsim.contrib.emissions.EmissionModule$$FastClassByGuice$$3f5bb797.newInstance() at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89) at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114) at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306) at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050) ... 2 more

Screenshot from 2023-03-31 13-04-46

neda-git commented 1 year ago

Hello @rgraebe , @kainagel , @kt86, I would like to say thank you for your help, I have successfully finished it. Now, I have emissions events file.

kainagel commented 1 year ago

Glad to hear that.