peak_heigth.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. from matplotlib import gridspec
  2. from charged_shells import expansion, interactions, mapping, functions
  3. from charged_shells.parameters import ModelParams
  4. import numpy as np
  5. from typing import Literal
  6. from pathlib import Path
  7. from functools import partial
  8. import json
  9. from plot_settings import *
  10. from dataclasses import dataclass
  11. Array = np.ndarray
  12. Expansion = expansion.Expansion
  13. RotConfig = Literal['ep', 'pp', 'sep']
  14. @dataclass
  15. class Peak:
  16. rot_config: str
  17. y_label: str
  18. ex1: Expansion
  19. ex2: Expansion
  20. emanuele_data_column: int
  21. log_y: bool
  22. kappaR_axis_in_expansion: int = None
  23. class PeakEP(Peak):
  24. def __init__(self, ex: Expansion, log_y: bool = False, kappaR_axis_in_expansion: int = None):
  25. self.emanuele_data_column = 4
  26. self.y_label = r'$|V_\mathrm{EP}|$' if log_y else r'$V_\mathrm{EP}$'
  27. self.ex1 = ex.clone()
  28. self.ex2 = ex.clone()
  29. self.ex1.rotate_euler(alpha=0, beta=np.pi / 2, gamma=0)
  30. self.log_y = log_y
  31. self.kappaR_axis_in_expansion = kappaR_axis_in_expansion
  32. class PeakPP(Peak):
  33. def __init__(self, ex: Expansion, log_y: bool = False, kappaR_axis_in_expansion: int = None):
  34. self.emanuele_data_column = 3
  35. self.y_label = r'$V_\mathrm{PP}$'
  36. self.ex1 = ex.clone()
  37. self.ex2 = ex.clone()
  38. self.log_y = log_y
  39. self.kappaR_axis_in_expansion = kappaR_axis_in_expansion
  40. class PeakSEP(Peak):
  41. def __init__(self, ex: Expansion, log_y: bool = False, kappaR_axis_in_expansion: int = None):
  42. self.emanuele_data_column = 5
  43. self.y_label = r'$|V_\mathrm{sEP}|$' if log_y else r'$V_\mathrm{sEP}$'
  44. self.ex1 = ex.clone()
  45. self.ex2 = ex.clone()
  46. self.ex1.rotate_euler(alpha=0, beta=np.pi / 4, gamma=0)
  47. self.ex2.rotate_euler(alpha=0, beta=3 * np.pi / 4, gamma=0)
  48. self.log_y = log_y
  49. self.kappaR_axis_in_expansion = kappaR_axis_in_expansion
  50. def get_charge_energy_dicts(peak: Peak, params: ModelParams, emanuele_data: Array, sigma0: Array, abar_cs: list, sigma_tilde=0.001):
  51. abar_ic, inverse, counts = np.unique(emanuele_data[:, 1], return_counts=True, return_inverse=True)
  52. energy_fn = mapping.parameter_map_two_expansions(partial(interactions.charged_shell_energy, dist=2),
  53. peak.kappaR_axis_in_expansion)
  54. energy = energy_fn(peak.ex1, peak.ex2, params)
  55. data_dict_ic = {}
  56. data_dict_cs = {}
  57. k = 0
  58. for i in range(len(abar_ic)):
  59. ab = np.around(abar_ic[i], 5)
  60. if ab in np.around(abar_cs, 5):
  61. idx, = np.nonzero(inverse == i)
  62. charge = emanuele_data[idx, 0]
  63. en = emanuele_data[idx, peak.emanuele_data_column]
  64. sort = np.argsort(charge)
  65. if peak.log_y:
  66. data_dict_ic[ab] = np.stack((charge[sort] / 280 + 2, np.abs(en)[sort])).T
  67. data_dict_cs[ab] = np.stack((sigma0 / sigma_tilde, np.abs(energy[k]))).T
  68. else:
  69. data_dict_ic[ab] = np.stack((charge[sort] / 280 + 2, en[sort])).T
  70. data_dict_cs[ab] = np.stack((sigma0 / sigma_tilde, energy[k])).T
  71. k += 1
  72. return data_dict_ic, data_dict_cs
  73. def get_kappaR_energy_dicts(peak: Peak, params: ModelParams, emanuele_data: Array,
  74. kappaR: Array, abar_cs: list, max_kappaR: float = 50, only_loaded: bool = False):
  75. abar_ic, inverse = np.unique(emanuele_data[:, 1], return_inverse=True)
  76. energy_fn = mapping.parameter_map_two_expansions(partial(interactions.charged_shell_energy, dist=2),
  77. peak.kappaR_axis_in_expansion)
  78. if not only_loaded:
  79. energy = energy_fn(peak.ex1, peak.ex2, params)
  80. else:
  81. energy = np.full((len(abar_cs), len(kappaR)), 1.)
  82. data_dict_ic = {}
  83. data_dict_cs = {}
  84. k = 0
  85. for i in range(len(abar_ic)):
  86. ab = np.around(abar_ic[i], 5)
  87. if ab in np.around(abar_cs, 5):
  88. idx, = np.nonzero(inverse == i)
  89. kR = emanuele_data[idx, 2][emanuele_data[idx, 2] <= max_kappaR]
  90. en = emanuele_data[idx, peak.emanuele_data_column][emanuele_data[idx, 1] <= max_kappaR]
  91. sort = np.argsort(kR)
  92. if peak.log_y:
  93. data_dict_ic[ab] = np.stack((kR[sort], np.abs(en)[sort])).T
  94. data_dict_cs[ab] = np.stack((kappaR, np.abs(energy[k]))).T
  95. else:
  96. data_dict_ic[ab] = np.stack((kR[sort], en[sort])).T
  97. data_dict_cs[ab] = np.stack((kappaR, energy[k])).T
  98. k += 1
  99. return data_dict_ic, data_dict_cs
  100. def get_abar_energy_dicts(peak: Peak, params: ModelParams, emanuele_data: Array, a_bar: Array, kR_cs: list, max_abar: float = 0.8):
  101. kR_ic, inverse = np.unique(emanuele_data[:, 2], return_inverse=True)
  102. energy_fn = mapping.parameter_map_two_expansions(partial(interactions.charged_shell_energy, dist=2),
  103. peak.kappaR_axis_in_expansion)
  104. energy = energy_fn(peak.ex1, peak.ex2, params)
  105. data_dict_ic = {}
  106. data_dict_cs = {}
  107. k = 0
  108. for i in range(len(kR_ic)):
  109. kr = np.around(kR_ic[i], 5)
  110. if kr in np.around(kR_cs, 5):
  111. idx, = np.nonzero(inverse == i)
  112. abar = emanuele_data[idx, 1][emanuele_data[idx, 1] <= max_abar]
  113. en = emanuele_data[idx, peak.emanuele_data_column][emanuele_data[idx, 1] <= max_abar]
  114. sort = np.argsort(abar)
  115. if peak.log_y:
  116. data_dict_ic[kr] = np.stack((abar[sort], np.abs(en)[sort])).T
  117. data_dict_cs[kr] = np.stack((a_bar, np.abs(energy[k]))).T
  118. else:
  119. data_dict_ic[kr] = np.stack((abar[sort], en[sort])).T
  120. data_dict_cs[kr] = np.stack((a_bar, energy[k])).T
  121. k += 1
  122. return data_dict_ic, data_dict_cs
  123. def save_data(data_dict_ic, data_dict_cs, a_bar: list):
  124. if save_data:
  125. ic_save = {str(key): val for key, val in data_dict_ic.items()}
  126. cs_save = {str(key): val for key, val in data_dict_cs.items()}
  127. ic_save['abar'] = a_bar
  128. cs_save['abar'] = a_bar
  129. with open(Path("/home/andraz/ChargedShells/charged-shells/config.json")) as config_file:
  130. config_data = json.load(config_file)
  131. np.savez(Path(config_data["figure_data"]).joinpath("fig_11_IC.npz"), **ic_save)
  132. np.savez(Path(config_data["figure_data"]).joinpath("fig_11_CS.npz"), **cs_save)
  133. def IC_peak_energy_plot(config_data: dict,
  134. a_bar: list,
  135. which: RotConfig,
  136. min_kappaR: float = 0.01,
  137. max_kappaR: float = 50.,
  138. R: float = 150,
  139. save_as: Path = None,
  140. save_data: bool = False,
  141. quad_correction: bool = False,
  142. log_y: bool = True):
  143. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_11"))
  144. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_PANELS_BDF"))
  145. em_data = np.load(em_data_path.joinpath("newpair_energy.npz"))
  146. data = em_data['fixA']
  147. num = 100 if which == 'sep' else 30
  148. kappaR = np.geomspace(min_kappaR, max_kappaR, num)
  149. params = ModelParams(R=R, kappaR=kappaR)
  150. ex = expansion.MappedExpansionQuad(np.array(a_bar)[:, None], params.kappaR[None, :], 0.00099, l_max=20)
  151. if which == 'ep':
  152. peak = PeakEP(ex, log_y, kappaR_axis_in_expansion=1)
  153. elif which == 'pp':
  154. peak = PeakPP(ex, log_y, kappaR_axis_in_expansion=1)
  155. elif which == 'sep':
  156. peak = PeakSEP(ex, log_y, kappaR_axis_in_expansion=1)
  157. else:
  158. raise ValueError
  159. data_dict_ic, data_dict_cs = get_kappaR_energy_dicts(peak, params, data, kappaR, a_bar, max_kappaR)
  160. corrected_data = {}
  161. for key, data in data_dict_ic.items():
  162. corrected_data[key] = data[:, 1] * higher_multipole_ic_correction(data[:, 0], float(key), higher_l=4)
  163. corrected_data2 = {}
  164. for key, data in data_dict_ic.items():
  165. corrected_data2[key] = data[:, 1] * higher_multipole_ic_correction(data[:, 0], float(key), higher_l=6)
  166. colors = cycle(plt.rcParams['axes.prop_cycle'].by_key()['color'])
  167. fig = plt.figure(figsize=(2, 1.8))
  168. gs = gridspec.GridSpec(1, 1, figure=fig)
  169. gs.update(left=0.25, right=0.95, top=0.97, bottom=0.21)
  170. ax = fig.add_subplot(gs[0, 0])
  171. i = 0
  172. for (key, data1), data2, cd, cd2 in zip(data_dict_ic.items(), data_dict_cs.values(), corrected_data.values(), corrected_data2.values()):
  173. i += 1
  174. if i == 1:
  175. current_color = next(colors)
  176. ax.plot(data1[:, 0], data1[:, 1], label=rf'$\bar a = {key:.2f}$', c=current_color)
  177. ax.plot(data2[:, 0], data2[:, 1], ls='--', c=current_color)
  178. ax.plot(data1[:, 0], cd, ls='-', c='r', label=r'$l=4$')
  179. ax.plot(data1[:, 0], cd2, ls='-', c='g', label=r'$l=6$')
  180. ax.legend(fontsize=9, ncol=1, frameon=False, handlelength=0.7, loc='upper right',
  181. bbox_to_anchor=(0.7, 0.52),
  182. # bbox_to_anchor=(0.42, 0.9)
  183. )
  184. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=11)
  185. ax.set_xlabel(r'$\kappa R$', fontsize=11)
  186. ax.set_ylabel(peak.y_label, fontsize=11)
  187. if log_y:
  188. ax.set_yscale('log')
  189. ax.set_xscale('log')
  190. # plt.tight_layout()
  191. if save_as is not None:
  192. plt.savefig(save_as, dpi=300)
  193. plt.show()
  194. def IC_peak_energy_abar_plot(config_data: dict,
  195. kappaR: list,
  196. which: RotConfig,
  197. min_abar: float = 0.01,
  198. max_abar: float = 50.,
  199. R: float = 150,
  200. save_as: Path = None,
  201. save_data: bool = False,
  202. quad_correction: bool = False,
  203. log_y: bool = True):
  204. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_11"))
  205. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_PANELS_BDF"))
  206. em_data = np.load(em_data_path.joinpath("newpair_energy.npz"))
  207. data = em_data['fixA']
  208. num = 100 if which == 'sep' else 30
  209. a_bar = np.linspace(min_abar, max_abar, num)
  210. params = ModelParams(R=R, kappaR=np.array(kappaR))
  211. ex = expansion.MappedExpansionQuad(np.array(a_bar)[None, :], params.kappaR[:, None], 0.001, l_max=20)
  212. if which == 'ep':
  213. peak = PeakEP(ex, log_y, kappaR_axis_in_expansion=0)
  214. elif which == 'pp':
  215. peak = PeakPP(ex, log_y, kappaR_axis_in_expansion=0)
  216. elif which == 'sep':
  217. peak = PeakSEP(ex, log_y, kappaR_axis_in_expansion=0)
  218. else:
  219. raise ValueError
  220. data_dict_ic, data_dict_cs = get_abar_energy_dicts(peak, params, data, a_bar, kappaR, max_abar)
  221. colors = cycle(plt.rcParams['axes.prop_cycle'].by_key()['color'])
  222. fig, ax = plt.subplots(figsize=(4.25, 3))
  223. for (key, data1), data2 in zip(data_dict_ic.items(), data_dict_cs.values()):
  224. current_color = next(colors)
  225. ax.plot(data1[:, 0], data1[:, 1], label=rf'$\kappa R = {key:.2f}$', c=current_color)
  226. ax.plot(data2[:, 0], data2[:, 1], ls='--', c=current_color)
  227. ax.legend(fontsize=14, ncol=1, frameon=False, handlelength=0.7,
  228. # loc='lower right',
  229. # bbox_to_anchor=(0.42, 0.42),
  230. # bbox_to_anchor=(0.42, 0.9)
  231. )
  232. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=15)
  233. ax.set_xlabel(r'$\bar a$', fontsize=15)
  234. ax.set_ylabel(peak.y_label, fontsize=15)
  235. if log_y:
  236. ax.set_yscale('log')
  237. # ax.set_xscale('log')
  238. plt.tight_layout()
  239. if save_as is not None:
  240. plt.savefig(save_as, dpi=600)
  241. plt.show()
  242. def IC_peak_energy_charge_plot(config_data: dict,
  243. a_bar: list,
  244. which: RotConfig,
  245. max_kappaR: float = 30.,
  246. R: float = 150,
  247. save_as: Path = None,
  248. save_data: bool = False,
  249. quad_correction: bool = False,
  250. log_y: bool = False):
  251. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_11"))
  252. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_PANELS_BDF"))
  253. em_data = np.load(em_data_path.joinpath("newpair_energy.npz"))
  254. data = em_data['changeZc']
  255. params = ModelParams(R=R, kappaR=3)
  256. sigma0 = np.linspace(-0.0003, 0.0003, 300)
  257. sigma_tilde = 0.001
  258. ex = expansion.MappedExpansionQuad(np.array(a_bar), kappaR=3, sigma0=sigma0, l_max=20, sigma_tilde=sigma_tilde)
  259. if which == 'ep':
  260. peak = PeakEP(ex, log_y)
  261. elif which == 'pp':
  262. peak = PeakPP(ex, log_y)
  263. elif which == 'sep':
  264. peak = PeakSEP(ex, log_y)
  265. else:
  266. raise ValueError
  267. data_dict_ic, data_dict_cs = get_charge_energy_dicts(peak, params, data, sigma0, a_bar, sigma_tilde)
  268. colors = cycle(plt.rcParams['axes.prop_cycle'].by_key()['color'])
  269. fig, ax = plt.subplots(figsize=(4.25, 3))
  270. for (key, data1), data2 in zip(data_dict_ic.items(), data_dict_cs.values()):
  271. current_color = next(colors)
  272. ax.plot(data1[:, 0], data1[:, 1], label=rf'$\bar a = {key:.2f}$', c=current_color)
  273. ax.plot(data2[:, 0], data2[:, 1], ls='--', c=current_color)
  274. ax.legend(fontsize=14, ncol=1, frameon=False, handlelength=0.7, loc='upper right',
  275. # bbox_to_anchor=(0.42, 0.95),
  276. # bbox_to_anchor=(0.7, 1),
  277. bbox_to_anchor=(0.42, 1),
  278. )
  279. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=15)
  280. ax.set_xlabel(r'$\eta$', fontsize=15)
  281. ax.set_ylabel(peak.y_label, fontsize=15)
  282. if log_y:
  283. ax.set_yscale('log')
  284. # ax.set_xscale('log')
  285. plt.tight_layout()
  286. if save_as is not None:
  287. plt.savefig(save_as, dpi=300)
  288. plt.show()
  289. def IC_peak_energy_kappaR_combined_plot(config_data: dict,
  290. a_bar: list,
  291. R: float = 150,
  292. save_as: Path = None,
  293. min_kappaR: float = 0.01,
  294. max_kappaR: float = 50.,
  295. ):
  296. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_11"))
  297. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_PANELS_BDF"))
  298. em_data = np.load(em_data_path.joinpath("newpair_energy.npz"))
  299. data = em_data['fixA']
  300. num = 50
  301. kappaR = np.geomspace(min_kappaR, max_kappaR, num)
  302. params = ModelParams(R=R, kappaR=kappaR)
  303. ex = expansion.MappedExpansionQuad(np.sort(np.array(a_bar))[:, None], # sorting necessary as it is also in energy_dicts()
  304. params.kappaR[None, :], 0.00099, l_max=20)
  305. peak_ep = PeakEP(ex, log_y=True, kappaR_axis_in_expansion=1)
  306. peak_pp = PeakPP(ex, log_y=True, kappaR_axis_in_expansion=1)
  307. peak_sep = PeakSEP(ex, log_y=False, kappaR_axis_in_expansion=1)
  308. peaks = [peak_ep, peak_pp, peak_sep]
  309. data_ic = []
  310. data_cs = []
  311. for peak in peaks:
  312. dict_ic, dict_cs = get_kappaR_energy_dicts(peak, params, data, kappaR, a_bar, max_kappaR, only_loaded=False)
  313. data_ic.append(dict_ic)
  314. data_cs.append(dict_cs)
  315. legend_coords = [(0.55, 0.45), (0.55, 0.43), (0.55, 0.63)]
  316. # fig, axs = plt.subplots(3, 1, figsize=(2, 5.4))
  317. fig = plt.figure(figsize=(2, 5.4))
  318. gs = gridspec.GridSpec(3, 1, figure=fig)
  319. gs.update(left=0.25, right=0.95, top=0.99, bottom=0.07, hspace=0.3)
  320. axs = [fig.add_subplot(gs[0, 0]), fig.add_subplot(gs[1, 0]), fig.add_subplot(gs[2, 0])]
  321. for ax, data_dict_ic, data_dict_cs, peak, lc in zip(axs, data_ic, data_cs, peaks, legend_coords):
  322. colors = cycle(plt.rcParams['axes.prop_cycle'].by_key()['color'])
  323. for ab in a_bar:
  324. key = np.around(ab, 5)
  325. current_color = next(colors)
  326. ax.plot(data_dict_ic[key][:, 0], data_dict_ic[key][:, 1], label=rf'$\bar a = {key:.1f}$', c=current_color, linewidth=1.5)
  327. ax.plot(data_dict_cs[key][:, 0], data_dict_cs[key][:, 1], ls='--', c=current_color, linewidth=1.5)
  328. ax.axvline(x=10, c='k', ls=':', linewidth=1)
  329. ax.axvline(x=3, c='k', ls=':', linewidth=1)
  330. ax.axvline(x=1, c='k', ls=':', linewidth=1)
  331. ax.legend(fontsize=9, ncol=1, frameon=False, handlelength=0.7, loc='upper right', bbox_to_anchor=lc)
  332. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=11)
  333. # if ax == axs[-1]:
  334. ax.set_xlabel(r'$\kappa R$', fontsize=11)
  335. ax.set_ylabel(peak.y_label, fontsize=11)
  336. if peak.log_y:
  337. ax.set_yscale('log')
  338. ax.set_xscale('log')
  339. ax.yaxis.set_label_coords(-0.25, 0.5)
  340. ax.xaxis.set_label_coords(0.5, -0.12)
  341. # plt.subplots_adjust(left=0.1)
  342. # plt.tight_layout()
  343. # plt.subplots_adjust(left=0.25, right=0.97, top=0.85, bottom=0.15)
  344. if save_as is not None:
  345. plt.savefig(save_as, dpi=300)
  346. plt.show()
  347. def IC_peak_energy_charge_combined_plot(config_data: dict,
  348. a_bar: list,
  349. R: float = 150,
  350. save_as: Path = None,
  351. log_y: bool = False):
  352. # em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_11"))
  353. em_data_path = (Path(config_data["emanuele_data"]).joinpath("FIG_4_PANELS_BDF"))
  354. em_data = np.load(em_data_path.joinpath("newpair_energy.npz"))
  355. data = em_data['changeZc']
  356. params = ModelParams(R=R, kappaR=3)
  357. sigma0 = np.linspace(-0.000297, 0.000297, 300)
  358. sigma_tilde = 0.00099
  359. ex = expansion.MappedExpansionQuad(np.sort(np.array(a_bar)), # sorting necessary as it is also in energy_dicts()
  360. kappaR=3, sigma0=sigma0, l_max=20, sigma_tilde=sigma_tilde)
  361. peak_ep = PeakEP(ex, log_y)
  362. peak_pp = PeakPP(ex, log_y)
  363. peak_sep = PeakSEP(ex, log_y)
  364. peaks = [peak_ep, peak_pp, peak_sep]
  365. data_ic = []
  366. data_cs = []
  367. for peak in peaks:
  368. dict_ic, dict_cs = get_charge_energy_dicts(peak, params, data, sigma0, a_bar, sigma_tilde)
  369. data_ic.append(dict_ic)
  370. data_cs.append(dict_cs)
  371. # fig, axs = plt.subplots(3, 1, figsize=(3, 7.8))
  372. fig = plt.figure(figsize=(2, 5.4))
  373. gs = gridspec.GridSpec(3, 1, figure=fig)
  374. gs.update(left=0.25, right=0.95, top=0.99, bottom=0.07, hspace=0.3)
  375. axs = [fig.add_subplot(gs[0, 0]), fig.add_subplot(gs[1, 0]), fig.add_subplot(gs[2, 0])]
  376. for ax, data_dict_ic, data_dict_cs, peak in zip(axs, data_ic, data_cs, peaks):
  377. colors = cycle(plt.rcParams['axes.prop_cycle'].by_key()['color'])
  378. for ab in a_bar:
  379. key = np.around(ab, 5)
  380. current_color = next(colors)
  381. ax.plot(data_dict_ic[key][:, 0], data_dict_ic[key][:, 1], label=rf'$\bar a = {key:.1f}$', c=current_color, linewidth=1.5)
  382. ax.plot(data_dict_cs[key][:, 0], data_dict_cs[key][:, 1], ls='--', c=current_color, linewidth=1.5)
  383. ax.legend(fontsize=9, ncol=1, frameon=False, handlelength=0.7, loc='upper right',
  384. bbox_to_anchor=(0.77, 1.03),
  385. )
  386. ax.tick_params(which='both', direction='in', top=True, right=True, labelsize=11)
  387. # if ax == axs[-1]:
  388. ax.set_xlabel(r'$\eta$', fontsize=11)
  389. ax.set_ylabel(peak.y_label, fontsize=11)
  390. if peak.log_y:
  391. ax.set_yscale('log')
  392. # ax.set_xscale('log')
  393. ax.yaxis.set_label_coords(-0.18, 0.5)
  394. ax.xaxis.set_label_coords(0.5, -0.12)
  395. # plt.subplots_adjust(left=0.3)
  396. # plt.tight_layout()
  397. if save_as is not None:
  398. plt.savefig(save_as, dpi=300)
  399. plt.show()
  400. def higher_multipole_ic_correction(kappaR, abar, higher_l: int = 4):
  401. return (functions.sph_bessel_k(3, kappaR) * functions.sph_bessel_i(2, kappaR * abar) * abar ** (higher_l - 2) /
  402. (functions.sph_bessel_k(higher_l + 1, kappaR) * functions.sph_bessel_i(higher_l, kappaR * abar)))
  403. def main():
  404. with open(Path("/home/andraz/ChargedShells/charged-shells/config.json")) as config_file:
  405. config_data = json.load(config_file)
  406. a_bar = [0.2, 0.5, 0.8]
  407. # IC_peak_energy_plot(config_data, a_bar=a_bar, which='pp', min_kappaR=0.01, max_kappaR=50,
  408. # save_as=Path('/home/andraz/ChargedShells/Figures/Emanuele_data/peak_pp_kappaR_higher_correction_abar02.png'),
  409. # save_data=False,
  410. # quad_correction=False,
  411. # log_y=False
  412. # )
  413. # IC_peak_energy_kappaR_combined_plot(config_data, a_bar,
  414. # save_as=Path(
  415. # '/home/andraz/ChargedShells/Figures/final_figures/peak_combined_kappaR.png')
  416. # )
  417. a_bar = [0.1, 0.2, 0.3]
  418. # IC_peak_energy_charge_plot(config_data, a_bar=a_bar, which='sep',
  419. # # save_as=Path('/home/andraz/ChargedShells/Figures/Emanuele_data/peak_sep_charge.png'),
  420. # )
  421. IC_peak_energy_charge_combined_plot(config_data, a_bar,
  422. save_as=Path('/home/andraz/ChargedShells/Figures/final_figures/peak_combined_charge.png')
  423. )
  424. kappaR = [0.01, 3.02407, 30]
  425. # IC_peak_energy_abar_plot(config_data, kappaR=kappaR, which='sep', min_abar=0.2, max_abar=0.8,
  426. # save_as=Path('/home/andraz/ChargedShells/Figures/Emanuele_data/peak_sep_abar.png'),
  427. # save_data=False,
  428. # quad_correction=False,
  429. # log_y=False
  430. # )
  431. if __name__ == '__main__':
  432. main()