1
0
mirror of https://github.com/Ahp06/SUMO_Emissions.git synced 2024-11-22 03:26:30 +00:00

Changed some doc method

This commit is contained in:
Ahp06 2019-01-21 11:25:45 +01:00
parent 96cfba4b16
commit 777cb89123
4 changed files with 9 additions and 11 deletions

View File

@ -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")

View File

@ -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)))

View File

@ -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)

View File

@ -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: