Source code for panpython.sdk.stat.htc_result_post_processing

"""
"Stat: HTC Result Results Processing" Module
============================================
The core module of htc result post-processing
"""

from panpython._libs.parser import PanHTCOutputFilesParser


[docs]class PandatHTCResultProcessor: """A post-processing class merging all Data from a HTC into a single csv file Parameters ---------- cal_type: str Type of HTC calculation parent_path: str Parent path of HTC results file_name: str Table names to be processed Examples -------- >>> from panpython.sdk.stat.htc_result_post_processing import PandatHTCResultProcessor >>> >>> htc_result_parent_path = 'source/default' >>> file_name = 'Table/Default.table' >>> dump_path = './output/' >>> file_output = 'merged.csv' >>> >>> m_processor = PandatHTCResultProcessor(parent_path=htc_result_parent_path, ... file_name=file_name, ... cal_type='point') >>> m_processor.save_to_csv(output_path=dump_path, output_file=file_output) """ def __init__(self, cal_type, parent_path, file_name): """ Initialize the post-procesing instance Parameters ---------- cal_type: str Type of HTC calculation parent_path: str Parent path of HTC results file_name: str Table names to be processed Returns ------- """ self._m_output_files_parser = PanHTCOutputFilesParser(cal_type, parent_path, file_name)
[docs] @staticmethod def get_table_group(cal_type, parent_path): """ Return a list of table group for post-processing Parameters ---------- cal_type: str type of HTC calculation parent_path: str the folder holding sub folders of htc calculations Returns ------- list a list of htc result table group """ return PanHTCOutputFilesParser.get_table_group(cal_type, parent_path)
[docs] @staticmethod def htc_condition_dict_creator(cal_type, parent_path, output_path, output_file='htc_condition.json'): """ Create a dictionary of htc conditions. Save the condition to a JSON file. Return the dictionary Parameters ---------- cal_type: str type of HTC calculation parent_path: str the folder holding sub folders of htc calculations output_path: str folder of output file output_file: str, optional name of output file Returns ------- dict a dictionary of htc conditions using task_id as key """ PanHTCOutputFilesParser.htc_condition_dict_creator(cal_type, parent_path, output_path, output_file)
[docs] def save_to_csv(self, output_path, output_file): """Save generated mega table of HTC result to csv Parameters ---------- output_path: str path of output of csv file output_file: str name of the output csv file Returns ------- """ self._m_output_files_parser.save_to_csv(output_path, output_file)