From c0e59319e2c50ceaf8f33a47228696209ebd0055 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Thu, 20 May 2021 08:52:13 +0200 Subject: [PATCH] Add argument dirname --- Analysis/distribution_function.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Analysis/distribution_function.py b/Analysis/distribution_function.py index 00eb7a1d..4d528987 100755 --- a/Analysis/distribution_function.py +++ b/Analysis/distribution_function.py @@ -4,6 +4,7 @@ import shapefile import numpy as np import matplotlib.pyplot as plt import itertools +from os import path def plot_distr_funct(x, label = None, ax = None): """Sort and plot distribution function. x should be a Numpy array.""" @@ -19,19 +20,22 @@ def plot_distr_funct(x, label = None, ax = None): print("number of values:", nx, "\n") -def read(): - """Read the three dbf files and return speed, radius and amplitude of - outermost contour, radius and amplitude of maximum speed contour, - as Numpy arrays. +def read(dirname): + """Read the three dbf files in dirname and return speed, radius and + amplitude of outermost contour, radius and amplitude of maximum + speed contour, as Numpy arrays. Select valid speed values and valid outermost contour (with sufficient area). """ + extr_file = path.join(dirname, "extremum") + outer_file = path.join(dirname, "outermost_contour") + max_speed_file = path.join(dirname, "max_speed_contour") - with shapefile.Reader("extremum") as extremum, \ - shapefile.Reader("outermost_contour") as outerm_cont, \ - shapefile.Reader("max_speed_contour") as max_speed_cont: + with shapefile.Reader(extr_file) as extremum, \ + shapefile.Reader(outer_file) as outerm_cont, \ + shapefile.Reader(max_speed_file) as max_speed_cont: speed = [] rad_outer = [] rad_speed = [] @@ -124,6 +128,8 @@ def plot_all(dict_list, label = None): label) if __name__ == "__main__": - d = read() + import sys + + d = read(sys.argv[1]) plot_all([d]) plt.show() -- GitLab