mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-22 11:36:29 +00:00
Added data to csv export
This commit is contained in:
parent
c76eea9d76
commit
229ab72279
@ -133,23 +133,21 @@ def export_data_to_csv(config, grid):
|
|||||||
'''if not os.path.exists(f'csv/{current_date}'):
|
'''if not os.path.exists(f'csv/{current_date}'):
|
||||||
os.makedirs(f'csv/{current_date}')'''
|
os.makedirs(f'csv/{current_date}')'''
|
||||||
|
|
||||||
'''with open(f'test.csv', mode='w', newline = '') as emission_file:
|
with open(f'test.csv', mode='w', newline = '') as emission_file:
|
||||||
try:
|
try:
|
||||||
csv_writer = csv.writer(emission_file, delimiter = ' ', quoting=csv.QUOTE_MINIMAL)
|
csv_writer = csv.writer(emission_file, delimiter = ' ', quoting=csv.QUOTE_MINIMAL)
|
||||||
a = list(range(config.n_steps))
|
|
||||||
csv_writer.writerow(['steps'])
|
csv_writer.writerow(['steps'])
|
||||||
|
a = list(range(config.n_steps))
|
||||||
for item in a:
|
for item in a:
|
||||||
csv_writer.writerow([item])
|
csv_writer.writerow([item])
|
||||||
|
|
||||||
for area in grid:
|
for area in grid:
|
||||||
writer = csv.writer(emission_file, delimiter = ' ', quoting=csv.QUOTE_MINIMAL)
|
csv_writer.writerow([f'{area.name}'])
|
||||||
writer.writerow([f'{area.name}'])
|
|
||||||
for emission in area.emissions_by_step:
|
for emission in area.emissions_by_step:
|
||||||
writer.writerow([emission.value()])
|
csv_writer.writerow([emission.value()])
|
||||||
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
emission_file.close()'''
|
emission_file.close()
|
||||||
|
|
||||||
|
|
||||||
def run(config, logger):
|
def run(config, logger):
|
||||||
@ -161,7 +159,6 @@ def run(config, logger):
|
|||||||
start = time.perf_counter()
|
start = time.perf_counter()
|
||||||
|
|
||||||
grid = init_grid(traci.simulation.getNetBoundary(), config.areas_number, config.window_size)
|
grid = init_grid(traci.simulation.getNetBoundary(), config.areas_number, config.window_size)
|
||||||
export_data_to_csv(config,grid)
|
|
||||||
add_data_to_areas(grid)
|
add_data_to_areas(grid)
|
||||||
|
|
||||||
loading_time = round(time.perf_counter() - start, 2)
|
loading_time = round(time.perf_counter() - start, 2)
|
||||||
@ -180,6 +177,7 @@ def run(config, logger):
|
|||||||
|
|
||||||
finally:
|
finally:
|
||||||
traci.close(False)
|
traci.close(False)
|
||||||
|
export_data_to_csv(config,grid)
|
||||||
|
|
||||||
simulation_time = round(time.perf_counter() - start, 2)
|
simulation_time = round(time.perf_counter() - start, 2)
|
||||||
logger.info(f'End of the simulation ({simulation_time}s)')
|
logger.info(f'End of the simulation ({simulation_time}s)')
|
||||||
|
Loading…
Reference in New Issue
Block a user