.. _pp_pandat_htc_precip-label: Post-Processing of data from Precipitation HTC ============================================== This example demonstrates how to use **PanPython SDK** handling the raw data from HTC precipitation simulation and perform statistical analysis of these data. In this example, raw data are commingled in two merged CSV files (Default.table.csv and generated.table.csv) and a JSON file containing HTC conditions. The merged files are then visualized through a Jupyter notebook. Precipitation HTC is discussed in :ref:`c_python_htc_precip-label` About precipitation HTC ----------------------- Precipitation HTC allows a user to perform simulations for numerous compositions/heat treatments in the user-defined state space by a simple setting. Alloy compositions and heat treatment conditions that satisfy user-defined criteria can then be identified through data mining of the simulated results. A step-by-step guide -------------------- .. note:: A video guide will be available very soon. 1. Open the demo folder "*/Solution Examples/panhtc_precipitation_post_process/*" from PyCharm IDE. See :ref:`installation-label` to setup the IDE environment. 2. Build a task script An example script *panhtc_precipitation_post_process.py* has already been include. Following the steps the create your script: Import packages .. code-block:: python from panpython.sdk.stat.htc_result_post_processing import PandatHTCResultProcessor import os Setup working folders and input files: .. code-block:: python dir_name = os.path.abspath(__file__) file_name = os.path.basename(__file__) task_path = dir_name[:-len(file_name)] htc_result_parent_path = 'source/default' Setup table name of each point calculation: .. code-block:: python file_name = ['Table/Default.table', 'Table/generated.table'] Setup output path .. code-block:: python dump_path = os.path.join(task_path, 'output') Run post-processing of point HTC: .. code-block:: python if __name__ == "__main__": htc_condition_dict = PandatHTCResultProcessor.htc_condition_dict_creator( cal_type='precipitation', parent_path=htc_result_parent_path, output_path=dump_path) for f in file_name: m_processor = PandatHTCResultProcessor(parent_path=htc_result_parent_path, file_name=f, cal_type='precipitation') m_processor.save_to_csv(output_path=dump_path, output_file='') 3. Run the post-processing script After the post-processing is finished, two csv files (Default.table.csv and generated.table.csv) and a JSON file (htc_condition.json) is ready to be used. See :ref:`inputs_outputs_c_python_htc_point_pp-label` for details. Visualize post-processed data ------------------------------ An example Jupyter notebook *panhtc_precipitation_post_process.ipynb* has already been included. Run it through terminal: .. code-block:: python >jupyter notebook panhtc_precipitation_post_process.ipynb The first plot from the notebook contains two figures. The left-hand figure is a color map of max yield strength among heat treatment temperatures. And the right-hand figure is a color map of the minimal time when the max yield strength is reached at a given composition. .. image:: Precp_Jupyter_map.png :width: 800 :alt: Jupyter notebook for precipitation HTC: color map The next plot from the notebook is an interactive color map of max yield strength among heat treatment temperatures. User can assign heat treatment time through the range bar to explore yield strength's dependence. .. image:: Precp_Jupyter_map_range_bar.png :width: 800 :alt: Jupyter notebook for precipitation HTC: color map with interactive range bar Run through the notebook, and click "Display/Refresh" button, an interactive plot will be displayed: .. image:: Precp_Jupyter.png :width: 800 :alt: Jupyter notebook for precipitation HTC See details about this interactive plot in section :ref:`pp_python_htc_point_viz-lable` of :ref:`pp_python_htc_point-lable`. .. _inputs_outputs_c_python_htc_precip_pp-label: The inputs and outputs of this post-processing task --------------------------------------------------- The following figure displays inputs and outputs of this post-processing task. .. image:: PP_diagram_with_HTC_condition.png :width: 600 :alt: Post-Processing diagram with HTC condition - File structure The follow diagram displays the file structure used by this post-processing task: .. note:: The "resource" folder is a copy of Pandat workspace. See details of Pandat workspace in `Chapter 2.1 `_ of Pandat Manual: . .. code-block:: html panhtc_precipitation_post_process |- output # outputs | |- Default.table.csv # A CSV file containing combined results of all Default.table files | |- generated.table.csv # A CSV file containing combined results of all generated.table files | └─ htc_condition.json # A JSON file describing HTC condition └─ resource # a copy of Pandat workspace folder └─ default # The parent folder containing all HTC points └─ Precipitation Simulation_PX_X # The child folder (id: PX_X) of precipitation calculation └─ Table # The folder containing .table file |- Default.table # the default .table file from a Pandat calculation └─ generated.table # the generated .table file from a Pandat calculation - Inputs The input files are under */resource* folder. - **resource/default/Precipitation Simulation_PX_X/Table/Default.table**: A Pandat .table file containing a precipitation calculation result with default columns. - **resource/default/Precipitation Simulation_PX_X/Table/generated.table**: A Pandat .table file containing a precipitation calculation result with customized columns. - Outputs The output files are under */output* folder. - **Default.table.csv**: A CSV file containing combined results of all Default.table files - **generated.table.csv**: A CSV file containing combined results of all generated.table files - **htc_condition.json**: A JSON file describing HTC condition. See details of this file in :ref:`pp_pandat_htc_condition_json-label`. .. _pp_pandat_htc_condition_json-label: HTC condition JSON file ----------------------- Every single calculation of HTC has its own condition. The condition together with its task id are stored in the HTC condition JSON file. The PanPython API will use task id to query condition when performing statistical analysis and visualization The structure of this HTC condition JSON file is visualized using https://jsonviewer.io/: .. image:: HTC_condition_file_example_with_box.png :width: 800 :alt: htc condition json file After expanding **points** node, the composition of this calculation is displayed .. image:: HTC_condition_file_example_point.png :width: 600 :alt: htc condition json file: point After expanding **condition** node, the thermal history of this calculation is displayed .. image:: HTC_condition_file_example_thermal.png :width: 500 :alt: htc condition json file: thermal