diff --git a/sumo_project/config.py b/sumo_project/config.py index 4c17a9c..87ff052 100644 --- a/sumo_project/config.py +++ b/sumo_project/config.py @@ -82,14 +82,9 @@ class Config: def init_traci(self, simulation_dir): """ Init the Traci API + :param simulation_dir: The path to the simulation directory :return: """ - if 'SUMO_HOME' in os.environ: - tools = os.path.join(os.environ['SUMO_HOME'], 'tools') - sys.path.append(tools) - else: - sys.exit("please declare environment variable 'SUMO_HOME'") - self._SUMOCFG = f'files/simulations/{simulation_dir}/osm.sumocfg' sumo_binary = os.path.join(os.environ['SUMO_HOME'], 'bin', self._SUMOCMD) self.sumo_cmd = [sumo_binary, "-c", self._SUMOCFG] @@ -97,6 +92,7 @@ class Config: def init_logger(self, dump_name, save_logs=False): """ Init the application logger + :param dump_name: The name of the data dump to use :param save_logs: If save_logs is True, it will save the logs into the logs directory :return: """ @@ -108,7 +104,7 @@ class Config: log_filename = f'files/logs/{dump_name}_{current_date}.log' - logger = logging.getLogger("sumo_logger") + logger = logging.getLogger(f'sumo_logger_{dump_name}') logger.setLevel(logging.INFO) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") diff --git a/sumo_project/emissions.py b/sumo_project/emissions.py index 7cf265b..c341f0b 100644 --- a/sumo_project/emissions.py +++ b/sumo_project/emissions.py @@ -113,7 +113,7 @@ def get_reduction_percentage(ref, total): return (ref - total) / ref * 100 -def export_data_to_csv(config, grid,dump_name): +def export_data_to_csv(config, conf, grid, dump_name): """ Export all Emission objects as a CSV file into the csv directory :param config: The simulation configuration @@ -126,7 +126,7 @@ def export_data_to_csv(config, grid,dump_name): now = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S") - with open(f'files/csv/{dump_name}_{now}.csv', 'w') as f: + with open(f'files/csv/{dump_name}_{conf}_{now}.csv', 'w') as f: writer = csv.writer(f) # Write CSV headers writer.writerow(itertools.chain(('Step',), (a.name for a in grid))) diff --git a/sumo_project/model.py b/sumo_project/model.py index 2d1593f..5c80053 100644 --- a/sumo_project/model.py +++ b/sumo_project/model.py @@ -129,7 +129,7 @@ class Emission: """ Add two emission objects :param other: The other Emission object to add - :return: A new object whose emission values ​​are the sum of both Emission object + :return: A new object whose emission values are the sum of both Emission object """ return Emission(self.co2 + other.co2, self.co + other.co, self.nox + other.nox, self.hc + other.hc, self.pmx + other.pmx) diff --git a/sumo_project/runner.py b/sumo_project/runner.py index e732027..eea0723 100644 --- a/sumo_project/runner.py +++ b/sumo_project/runner.py @@ -57,7 +57,8 @@ def add_options(parser): def create_dump(dump_name, simulation_dir, areas_number): """ Create a new dump with config file and dump_name chosen - :param cfg_file: The simulation file + :param dump_name: The name of the data dump + :param simulation_dir: The simulation directory :param areas_number: The number of areas in grid :return: """ @@ -86,6 +87,7 @@ def run(data : Data, config : Config, logger): """ Run a data set :param data: The data instance + :param config: The config instance :param logger: The logger instance """ try: