From a58bf4f0196b66ddf9712c447a739307b0c17673 Mon Sep 17 00:00:00 2001 From: Florez Ospina Juan Felipe Date: Tue, 26 Mar 2024 13:57:19 +0100 Subject: [PATCH] Refactored import dependencies. --- src/g5505_file_reader.py | 15 +++++---------- src/hdf5_lib.py | 28 ++++++++++++++++++---------- src/smog_chamber_file_reader.py | 14 +++++++++----- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/g5505_file_reader.py b/src/g5505_file_reader.py index 2589448..c86a2ee 100644 --- a/src/g5505_file_reader.py +++ b/src/g5505_file_reader.py @@ -1,17 +1,13 @@ +import os + import numpy as np import pandas as pd -import matplotlib.pyplot as plt -import plotly.express as px -import plotly.graph_objects as go -from plotly.subplots import make_subplots from igor2.binarywave import load as loadibw -#import h5py -import os -import tempfile -import shutil +import src.g5505_utils as utils + + import h5py -import g5505_utils as utils ROOT_DIR = os.path.abspath(os.curdir) @@ -125,7 +121,6 @@ def read_txt_files_as_dict(filename : str ): print(line_number, len(column_names )) break - # Subdivide line into words, and join them by single space. # I asumme this can produce a cleaner line that contains no weird separator characters \t \r or extra spaces and so on. list_of_substrings = line.split() diff --git a/src/hdf5_lib.py b/src/hdf5_lib.py index ad41383..7126179 100644 --- a/src/hdf5_lib.py +++ b/src/hdf5_lib.py @@ -1,17 +1,20 @@ -import pandas as pd -import h5py +import sys import os -#import sys -#from itertools import product +root_dir = os.path.abspath(os.curdir) +sys.path.append(root_dir) + +import pandas as pd import numpy as np #import g5505_file_reader -import g5505_utils as utils -#import smog_chamber_file_reader +import src.g5505_utils as utils +import input_files.config_file as config_file +import src.hdf5_vis as hdf5_vis -import config_file +import h5py +import yaml def read_mtable_as_dataframe(filename): @@ -456,8 +459,14 @@ def main(): select_file_keywords = config_file.select_file_keywords #['20220726','2022.07.26'] output_filename_path = os.path.join(config_file.outputfile_dir,config_file.output_filename) - create_hdf5_file_from_filesystem_path(output_filename_path,inputfile_dir,select_dir_keywords,select_file_keywords) - #display_group_hierarchy_on_a_treemap(output_filename_path) + if not os.path.exists(output_filename_path): + create_hdf5_file_from_filesystem_path(output_filename_path,inputfile_dir,select_dir_keywords,select_file_keywords) + + # hdf5_vis.display_group_hierarchy_on_a_treemap(output_filename_path) + output_yml_filename_path = hdf5_vis.take_yml_snapshot_of_hdf5_file(output_filename_path) + + + return output_filename_path, output_yml_filename_path def main_mtable_h5_from_dataframe(): @@ -503,7 +512,6 @@ def main_mtable_h5_from_dataframe(): print(':)') - if __name__ == '__main__': main() diff --git a/src/smog_chamber_file_reader.py b/src/smog_chamber_file_reader.py index 61f145c..5bdb8ec 100644 --- a/src/smog_chamber_file_reader.py +++ b/src/smog_chamber_file_reader.py @@ -1,9 +1,13 @@ - -import pandas as pd -import numpy as np -import matplotlib.pyplot as plt import os -import g5505_utils as utils + +import numpy as np +import pandas as pd +from igor2.binarywave import load as loadibw + +import src.g5505_utils as utils + + +import h5py #def read_txt_files_as_dict(filename : str ,instrument_folder : str): def read_txt_files_as_dict(filename : str ):