fix(scripts): list min/max calls, typed mains, drop unused header reads

This commit is contained in:
2026-09-30 03:11:05 +03:00
parent dc350aacfc
commit f5b79000a4
4 changed files with 55 additions and 41 deletions
+10 -9
View File
@@ -94,8 +94,6 @@
" endpoint_MeV=0.294,\n",
" transition_type=\"F2\",\n",
" e_step_MeV=0.001,\n",
" use_phase_space=True,\n",
" use_fermi=True,\n",
" use_screening=True,\n",
" use_finite_size=True,\n",
" use_charge_dist=True,\n",
@@ -410,13 +408,16 @@
}
],
"source": [
"multi_analyzer = BetaSpectrumAnalyzer(multi_spectrum, multi_config)\n",
"\n",
"fig, ax = plt.subplots(figsize=(12, 6))\n",
"ax.plot(T_keV, total, \"k-\", linewidth=2.5, label=\"Total spectrum\")\n",
"\n",
"branch_spectra = multi_spectrum.get_branch_normalized_spectra(W)\n",
"for i, bs in enumerate(branch_spectra):\n",
" ax.plot(T_keV, bs, alpha=0.6, linewidth=1.5,\n",
" label=\"Branch {} (E0={:.0f} keV)\".format(i+1, branches[i].endpoint_MeV*1000))\n",
"# Physical branch spectra: core (phase_space x fermi) x all enabled corrections\n",
"for i, b in enumerate(branches):\n",
" physical = multi_analyzer.physical_branch_spectrum(i)\n",
" ax.plot(T_keV, physical, alpha=0.6, linewidth=1.5,\n",
" label=\"Branch {} (E0={:.0f} keV)\".format(i+1, b.endpoint_MeV*1000))\n",
"\n",
"for i, b in enumerate(branches):\n",
" br_end_keV = W_to_T(T_to_W(b.endpoint_MeV))\n",
@@ -430,7 +431,7 @@
"ax.set_xlim(0, W0_max_keV)\n",
"ax.grid(True, alpha=0.3)\n",
"plt.tight_layout()\n",
"plt.show()"
"plt.show()\n"
]
},
{
@@ -541,8 +542,8 @@
}
],
"source": [
"analyzer = BetaSpectrumAnalyzer(multi_spectrum, multi_config)\n",
"analyzer.plot_analysis(show_components=True)"
"analyzer = multi_analyzer\n",
"analyzer.plot_analysis(show_components=True)\n"
]
},
{
+2 -10
View File
@@ -81,11 +81,7 @@
"\n",
"# Detect header size from file\n",
"def detect_header_size(filepath):\n",
" \"\"\"Detect MCA header size by checking for binary pattern.\"\"\"\n",
" with open(filepath, 'rb') as f:\n",
" header = f.read(128)\n",
" # Check if first 32 bytes look like a header (small ints)\n",
" # and bytes 32-128 also look like header\n",
" \"\"\"Detect MCA header size from the file size.\"\"\"\n",
" # Simple heuristic: if file is exactly 32 + 4096*4 = 16412, header=32\n",
" # If file is 128 + 4096*4 = 16512, header=128\n",
" import os\n",
@@ -97,11 +93,7 @@
" elif size == expected_128:\n",
" return 128\n",
" else:\n",
" # Try to detect by checking if byte 32 looks like an int\n",
" with open(filepath, 'rb') as f:\n",
" f.seek(32)\n",
" test = f.read(4)\n",
" return 32 # default\n",
" return 32 # default\n",
"\n",
"# --- Raw run spectrum ---\n",
"header_size = detect_header_size(RAW_FILE)\n",