.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/comparisons/compare_E.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_comparisons_compare_E.py: Comparing Calculated and TSUNAMI-IP E for a Set of SDF Files ============================================================ This example demonstrates the use of ``tsunami_ip_utils`` for calculating the similarity index :math:`E` for a set of TSUNAMI-IP SDF files and comparing to the TSUNAMI-IP calculated value. This example uses a set of 12 SDF files generated from the highly enriched uranium fast metal (HMF) series of critical experiments [Bess2019]_. .. GENERATED FROM PYTHON SOURCE LINES 9-20 .. code-block:: Python from tsunami_ip_utils.comparisons import E_calculation_comparison import pandas as pd import pickle from paths import EXAMPLES # Create a list of application and experiment SDF files (same set of applications and experiments) applications = [ f"{EXAMPLES}/data/example_sdfs/HMF/HEU-MET-FAST-003-00{i}.sdf" for i in range(1, 3) ] experiments = applications data = E_calculation_comparison(applications, experiments) E_total_comparison = data['total'] .. rst-class:: sphx-glr-script-out .. code-block:: none Done with calculations Creating pandas dataframes .. GENERATED FROM PYTHON SOURCE LINES 21-23 The output is a pandas dataframe. The application is the first index, and can be accessed via passing the application number as an index. For example, to access the first application: .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python print(E_total_comparison[1]) .. rst-class:: sphx-glr-script-out .. code-block:: none Attribute Calculated Manual Uncertainty ... Relative Difference in Mean Relative Difference in Manual Uncertainty Experiment Number ... 1 1.000E+00+/-1.71E-03 1.71E-03 ... 3.3307E-15 2.8798E-01 2 9.983E-01+/-1.72E-03 1.72E-03 ... 2.8934E-04 2.8323E-01 [2 rows x 5 columns] .. GENERATED FROM PYTHON SOURCE LINES 27-28 From the output, you can see that each application has a few attributes that are calculated. The attributes are: .. GENERATED FROM PYTHON SOURCE LINES 28-31 .. code-block:: Python print(E_total_comparison[1].keys()) .. rst-class:: sphx-glr-script-out .. code-block:: none Index(['Calculated', 'Manual Uncertainty', 'TSUNAMI-IP', 'Relative Difference in Mean', 'Relative Difference in Manual Uncertainty'], dtype='object', name='Attribute') .. GENERATED FROM PYTHON SOURCE LINES 32-33 To access, for example, the calculated E value, you can pass the appropriate key .. GENERATED FROM PYTHON SOURCE LINES 33-36 .. code-block:: Python print(E_total_comparison[1]['Calculated']) .. rst-class:: sphx-glr-script-out .. code-block:: none Experiment Number 1 1.000E+00+/-1.71E-03 2 9.983E-01+/-1.72E-03 Name: Calculated, dtype: object .. GENERATED FROM PYTHON SOURCE LINES 37-40 This gives the calculated E value for application 1 compared to all other experiments. To select a specific application experiement pair, you can pass the experiment number as the second index. For example, to access the calculated E value for application 1 compared to experiment 2: .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python print(E_total_comparison[1]['Calculated'][2]) .. rst-class:: sphx-glr-script-out .. code-block:: none 9.983E-01+/-1.72E-03 .. GENERATED FROM PYTHON SOURCE LINES 44-47 Now the pandas dataframe comparison for each of the :math:`E` types (i.e. :math:`E_{\text{total}}`, :math:`E_{\text{fission}}`, :math:`E_{\text{capture}}`, and :math:`E_{\text{scatter}}`) can be written to an excel file. The gold standard data is also provided in the ``gold`` directory. .. GENERATED FROM PYTHON SOURCE LINES 47-59 .. code-block:: Python # Save output data as xlsx for E_type in data.keys(): data[E_type].to_excel(f"{E_type}_comparison.xlsx") # Test that the calculated E comparison is the same as the gold standard for E_type in data.keys(): dumped_data = pd.read_excel( f"{E_type}_comparison.xlsx" ) gold_data = pd.read_excel( f"{EXAMPLES}/gold/{E_type}_comparison.xlsx" ) assert dumped_data.equals( gold_data ) .. GENERATED FROM PYTHON SOURCE LINES 60-63 References ---------- .. [Bess2019] J. Bess, "International handbook of evaluated criticality safety benchmark experiments (ICSBEP)," Organization for Economic Co-operation and Development-Nuclear Energy Agency Report NEA/NSC/DOC (95) 3 (2019). .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 47.520 seconds) .. _sphx_glr_download_auto_examples_comparisons_compare_E.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: compare_E.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: compare_E.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: compare_E.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_