Skip to content

Commit

Permalink
QoL improvements
Browse files Browse the repository at this point in the history
Exporting sim data before running a simulation no longer breaks the program.
Export name number starts from the biggest one in the file folder instead of 0.
  • Loading branch information
GuidodiPasquo committed Feb 6, 2022
1 parent f15e3ea commit e01a589
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def natural_sort(l):
return sorted(l, key=alphanum_key)


def get_export_names():
def get_export_names(filepath, exports_path):
r"""
Return a list with the names of the files in the folder /Exports.
Expand All @@ -45,7 +45,7 @@ def get_export_names():
Save files names.
"""
if exports_path == "":
return []
exports_path = filepath
filenames = natural_sort(os.listdir(exports_path))
for i, filename in enumerate(filenames):
# Removes the .csv
Expand Down Expand Up @@ -95,7 +95,7 @@ def get_sitl_modules_names(filepath):
def export_plots(file_name, filepath, names, data, T):
global exports_path
file_name += "_0"
export_names = get_export_names()
export_names = get_export_names(filepath, exports_path)

number_found = False
counter = 0
Expand Down
3 changes: 3 additions & 0 deletions src/simulation/main_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,9 @@ def export_plots(file_name):
if name != "Off":
names_to_csv.append(name)
plots_to_csv = [t_plot]
if first_plot == []:
print("There is nothing to export, please run a simulation.")
return None
if first_plot[0] != None:
plots_to_csv.append(first_plot)
if second_plot[0] != None:
Expand Down

0 comments on commit e01a589

Please sign in to comment.