|
| 1 | + |
| 2 | + |
| 3 | +import os |
| 4 | +import sys |
| 5 | + |
| 6 | + |
| 7 | +import numpy as np |
| 8 | +import matplotlib.pyplot as plt |
| 9 | +import tofu as tf |
| 10 | + |
| 11 | + |
| 12 | +# ##################################################### |
| 13 | +# ##################################################### |
| 14 | +# DEFAULTS |
| 15 | +# ##################################################### |
| 16 | + |
| 17 | + |
| 18 | +_PATH_HERE = os.path.dirname(__file__) |
| 19 | + |
| 20 | + |
| 21 | +_PFE_DCROSS = os.path.join( |
| 22 | + _PATH_HERE, |
| 23 | + 'd2cross_Ee01eV-100MeV-80log_Eph1eV-100MeV-81log_ntheta61_EH.npz', |
| 24 | +) |
| 25 | + |
| 26 | + |
| 27 | +# ##################################################### |
| 28 | +# ##################################################### |
| 29 | +# Fig 1 - cross-section |
| 30 | +# ##################################################### |
| 31 | + |
| 32 | + |
| 33 | +def fig01_cross_section( |
| 34 | + pfe=None, |
| 35 | + Eph_eV=[5e3, 50e3, 500e3], |
| 36 | + Ee0_eV=[1e5, 1e6], |
| 37 | +): |
| 38 | + |
| 39 | + # -------------- |
| 40 | + # load |
| 41 | + # -------------- |
| 42 | + |
| 43 | + dout = { |
| 44 | + kk: vv.tolist() |
| 45 | + for kk, vv in dict(np.load(pfe, allow_pickle=True)).items() |
| 46 | + } |
| 47 | + |
| 48 | + # -------------- |
| 49 | + # extract |
| 50 | + # -------------- |
| 51 | + |
| 52 | + indEph = [ |
| 53 | + np.argmin(np.abs(dout['E_ph']['data'] - eph)) |
| 54 | + for eph in Eph_eV |
| 55 | + ] |
| 56 | + |
| 57 | + indEe0 = [ |
| 58 | + np.argmin(np.abs(dout['E_e0']['data'] - e0)) |
| 59 | + for e0 in Ee0_eV |
| 60 | + ][0] |
| 61 | + |
| 62 | + Ee0 = dout['E_e0']['data'][0, indEe0, 0] |
| 63 | + Eph = dout['E_ph']['data'][0, 0, indEph] |
| 64 | + theta_ph = dout['theta_ph']['data'].squeeze()*180/np.pi |
| 65 | + |
| 66 | + cross = dout['cross']['EH']['data'][:, indEe0, indEph] |
| 67 | + |
| 68 | + units = dout['cross']['EH']['units'] |
| 69 | + |
| 70 | + # -------------- |
| 71 | + # prepare plot |
| 72 | + # -------------- |
| 73 | + |
| 74 | + fig = plt.figure(figsize=(13, 7)) |
| 75 | + gs = None |
| 76 | + dax = {} |
| 77 | + |
| 78 | + ax0 = fig.add_subplot(121) |
| 79 | + ax0.set_xlabel( |
| 80 | + "Angle of photon emission" + r"$\theta_{ph}$" + " (deg)", |
| 81 | + fontweight='bold', |
| 82 | + fontsize=14, |
| 83 | + ) |
| 84 | + ax0.set_ylabel( |
| 85 | + f'Cross-section {units}', |
| 86 | + fontweight='bold', |
| 87 | + fontsize=14, |
| 88 | + ) |
| 89 | + |
| 90 | + ax1 = fig.add_subplot(122, sharex=ax0) |
| 91 | + ax1.set_xlabel( |
| 92 | + "Angle of photon emission" + r"$\theta_{ph}$" + " (deg)", |
| 93 | + fontweight='bold', |
| 94 | + fontsize=14, |
| 95 | + ) |
| 96 | + ax1.set_ylabel( |
| 97 | + f'Cross-section {units}', |
| 98 | + fontweight='bold', |
| 99 | + fontsize=14, |
| 100 | + ) |
| 101 | + |
| 102 | + # -------------- |
| 103 | + # plot |
| 104 | + # -------------- |
| 105 | + |
| 106 | + for ii, eph in enumerate(Eph): |
| 107 | + |
| 108 | + l0, = ax0.plot( |
| 109 | + theta_ph, |
| 110 | + cross[:, ii], |
| 111 | + label=f"Eph = {eph*1e-3:3.0f} keV", |
| 112 | + ) |
| 113 | + |
| 114 | + ax1.plot( |
| 115 | + theta_ph, |
| 116 | + cross[:, ii] / np.max(cross[:, ii]), |
| 117 | + color=l0.get_color(), |
| 118 | + label=f"Eph = {eph*1e-3:03.0f} keV", |
| 119 | + ) |
| 120 | + |
| 121 | + # -------------- |
| 122 | + # adjust |
| 123 | + # -------------- |
| 124 | + |
| 125 | + ax0.set_xlim(0, 180) |
| 126 | + ax0.set_ylim(bottom=0) |
| 127 | + ax1.set_ylim(0, 1) |
| 128 | + ax0.legend() |
| 129 | + |
| 130 | + return dax |
0 commit comments