From 3b8ad66e47b44f34856086ca3a82725c817f2b49 Mon Sep 17 00:00:00 2001 From: Bruno Sorban Date: Tue, 4 Oct 2022 00:33:11 +0200 Subject: [PATCH 1/2] Export function to csv complete --- rocketpy/utilities.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index dc847ea3c..d60283d3f 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- -__author__ = "Franz Masatoshi Yuri, Lucas Kierulff Balabram, Guilherme Fernandes Alves" +__author__ = "Franz Masatoshi Yuri, Lucas Kierulff Balabram, Guilherme Fernandes Alves, Bruno Abdulklech Sorban" __copyright__ = "Copyright 20XX, RocketPy Team" __license__ = "MIT" +import csv import numpy as np from scipy.integrate import solve_ivp @@ -37,7 +38,7 @@ def compute_CdS_from_drop_test( """ - return 2 * rocket_mass * g / ((terminal_velocity**2) * air_density) + return 2 * rocket_mass * g / ((terminal_velocity ** 2) * air_density) # TODO: Needs tests @@ -197,3 +198,27 @@ def du(z, u): velocityFunction() return altitudeFunction, velocityFunction, final_sol + + +def export_mean_dispersion_to_csv(dispersion_results, filename): + """Exports the mean dispersion of the rocket to a CSV file. + + Parameters + ---------- + dispersion_results : dictionary + List containing the dispersion results of each iteration. + filename : str + Name of the file to be exported. + + """ + + for axis in dispersion_results: + dispersion_results[axis] = np.mean(dispersion_results[axis]) + + names = list(dispersion_results.keys()) + values = list(dispersion_results.values()) + + with open(filename, "w", newline="") as csvfile: + writer = csv.writer(csvfile, delimiter=",") + writer.writerow(names) + writer.writerow(values) From b259b1a91cceeccd4788ec75436fb298e476ec21 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Mon, 3 Oct 2022 22:35:57 +0000 Subject: [PATCH 2/2] Fix code style issues with Black --- rocketpy/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index d60283d3f..a28d0a2f5 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -38,7 +38,7 @@ def compute_CdS_from_drop_test( """ - return 2 * rocket_mass * g / ((terminal_velocity ** 2) * air_density) + return 2 * rocket_mass * g / ((terminal_velocity**2) * air_density) # TODO: Needs tests