c_map = fmts.ColorMap() c_map.assign_new_c_map(plt.get_cmap("tab10").colors) a_paths = [] for cur_data in data: if cur_data.line_calculation_settings_calculate == False: continue else: pass cur_data.root_dir = fio.get_part_of_path( cur_data.root_dir_settings_root_dir, -1) cur_data.all_files_paths = fio.get_files( cur_data.root_dir_settings_root_dir, ["csv"], [], []) a_paths = fio.get_files(cur_data.root_dir_settings_root_dir) cur_data.file_names = fio.get_parts_of_paths_list(cur_data.all_files_paths, -1) cur_data.last_dirs_names = fio.get_parts_of_paths_list( cur_data.all_files_paths, -2) # root_dir = fio.get_part_of_given_os_path(cur_data.root_dir_settings_root_dir, -1) # all_files_paths = fio.get_files_from_dirs(cur_data.root_dir_settings_root_dir,[],[], ["csv"]) # a_paths = fio.get_files_from_dirs(cur_data.root_dir_settings_root_dir) # file_names = fio.get_parts_of_given_os_path_list(cur_data.all_files_paths, -1) # last_dirs_names = fio.get_parts_of_given_os_path_list(cur_data.all_files_paths, -2) if cur_data.line_label_plot_settings_text == "file_name": cur_data.labels_line = [ "{}{}{}".format(cur_data.line_label_plot_settings_text_pref, i, cur_data.line_label_plot_settings_text_post) for i in cur_data.file_names ]
apaths = fio.get_files(cwd, extension = ['xlsx'], contains = [res_name], not_contains=['~'], print_path=False) for name in apaths: calc = input("results file has been found, calculate again ? ") """ # ============================================================================= # CALCULATION STARTING POINT # ============================================================================= """ if calc == '1' or calc == 'y': # ============================================================================= # getting all data file names # ============================================================================= abs_paths = fio.get_files(cwd, extension = ['xlsm'], contains = included_dirs_keywords, not_contains = excluded_dirs_keywords, print_path=False) root_dirs = fio.get_parts_of_paths_list(abs_paths, -3) sample_dirs = fio.get_parts_of_paths_list(abs_paths, -2) filenames = fio.get_parts_of_paths_list(abs_paths, -1) # ============================================================================= # filtering all data-files based on conditions, calculating means of selected values # ============================================================================= filtered_frames_list = [] for num, (abs_path, root_dir, sample_dir, filename) in enumerate(zip(abs_paths, root_dirs, sample_dirs, filenames)): print('Processing file ({}/{}) ........ {} / {} / {}'.format( '{x:02d}'.format(x=num+1), '{x:02d}'.format(x=len(abs_paths)), sample_dir, filename, root_dir)) input_frame = pd.read_excel(abs_path, usecols=column_indexes, skiprows=skip_rows).apply(pd.to_numeric, errors='coerce', downcast='float') input_frame = input_frame.dropna(axis=0, how='any').reset_index(drop=True) input_frame.columns = column_names input_frame = input_frame[sorted_columns]
script_path = os.path.normpath(os.path.abspath(__file__)) cwd = os.path.split(script_path)[0] os.makedirs('{}/{}'.format(cwd, 'results'), exist_ok=True) def find_nearest(array,value): idx = np.searchsorted(array, value, side="left") if idx > 0 and (idx == len(array) or math.fabs(value - array[idx-1]) < math.fabs(value - array[idx])): return idx-1 else: return idx columns = ['sample','assembly force 1', 'assembly force 2', 'assembly force 3', 'assembly force 4', 'assembly force 5', 'assembly force 6', 'assembly force 7', 'assembly force 8', 'assembly force 9', 'assembly force 10'] llist = [] files = fio.get_files(cwd, extension=['csv']) dirs = fio.get_parts_of_paths_list(files, -2) for file, dirr in zip(files, dirs): data = fcsv.read_data_from_csv_file(file, [0,2], 7, None, 0) data = fdp.nested_list_to_numpy_arr(data) fig = plt.figure(figsize=(13,7)) plt.plot(data[1], data[0]) plt.title(dirr) points = np.arange(0,11)*34 for index, i in enumerate(points): if index == 0: points[index] = 0 elif index == 1: