feat: change CSV output format to use tab delimiters instead of comma delimiters
This commit is contained in:
@@ -212,10 +212,12 @@ class BetaSpectrumAnalyzer:
|
||||
branch_endpoint_keV = branch.endpoint_MeV * 1000
|
||||
neutrino_mass_keV = self.config.neutrino_mass_MeV * 1000
|
||||
is_excluded_by_mass = branch_endpoint_keV <= neutrino_mass_keV
|
||||
is_excluded_by_intensity = branch.intensity < self.config.intensity_cutoff
|
||||
is_excluded_by_intensity = (
|
||||
branch.intensity < self.config.intensity_cutoff
|
||||
)
|
||||
if not is_excluded_by_mass and not is_excluded_by_intensity:
|
||||
active_branches += 1
|
||||
|
||||
|
||||
if active_branches < self._n_branches:
|
||||
title += f" ({active_branches} of {self._n_branches} branches)"
|
||||
else:
|
||||
@@ -227,13 +229,13 @@ class BetaSpectrumAnalyzer:
|
||||
branch = self._unified_branches[i]
|
||||
e0 = branch.endpoint_MeV * 1000
|
||||
intensity_pct = branch.intensity * 100
|
||||
|
||||
|
||||
# Check if branch is excluded
|
||||
branch_endpoint_keV = branch.endpoint_MeV * 1000
|
||||
neutrino_mass_keV = self.config.neutrino_mass_MeV * 1000
|
||||
is_excluded_by_mass = branch_endpoint_keV <= neutrino_mass_keV
|
||||
is_excluded_by_intensity = branch.intensity < self.config.intensity_cutoff
|
||||
|
||||
|
||||
if is_excluded_by_mass:
|
||||
return f"Br. {i + 1}: {e0:.1f} keV ({intensity_pct:.1f}%) - excluded (endpoint < m_nu)"
|
||||
elif is_excluded_by_intensity:
|
||||
@@ -333,7 +335,9 @@ class BetaSpectrumAnalyzer:
|
||||
branch_endpoint_keV = self._unified_branches[i].endpoint_MeV * 1000
|
||||
neutrino_mass_keV = self.config.neutrino_mass_MeV * 1000
|
||||
is_excluded_by_mass = branch_endpoint_keV <= neutrino_mass_keV
|
||||
is_excluded_by_intensity = self._unified_branches[i].intensity < self.config.intensity_cutoff
|
||||
is_excluded_by_intensity = (
|
||||
self._unified_branches[i].intensity < self.config.intensity_cutoff
|
||||
)
|
||||
if not is_excluded_by_mass and not is_excluded_by_intensity:
|
||||
active_branch_indices.append(i)
|
||||
|
||||
@@ -426,14 +430,16 @@ class BetaSpectrumAnalyzer:
|
||||
label="Total spectrum",
|
||||
zorder=10,
|
||||
)
|
||||
|
||||
|
||||
# Only plot active branches (not excluded by neutrino mass or intensity cutoff)
|
||||
active_branch_indices = []
|
||||
for i in range(n_branches):
|
||||
branch_endpoint_keV = self._unified_branches[i].endpoint_MeV * 1000
|
||||
neutrino_mass_keV = self.config.neutrino_mass_MeV * 1000
|
||||
is_excluded_by_mass = branch_endpoint_keV <= neutrino_mass_keV
|
||||
is_excluded_by_intensity = self._unified_branches[i].intensity < self.config.intensity_cutoff
|
||||
is_excluded_by_intensity = (
|
||||
self._unified_branches[i].intensity < self.config.intensity_cutoff
|
||||
)
|
||||
if not is_excluded_by_mass and not is_excluded_by_intensity:
|
||||
active_branch_indices.append(i)
|
||||
|
||||
@@ -800,7 +806,7 @@ class BetaSpectrumAnalyzer:
|
||||
data[f"branch_{i + 1}"] = branch_spectrum
|
||||
|
||||
df = pd.DataFrame(data)
|
||||
df.to_csv(filename, index=False, float_format="%.4e")
|
||||
df.to_csv(filename, index=False, float_format="%.4e", sep='\t')
|
||||
|
||||
with open(filename, "r") as f:
|
||||
content = f.read()
|
||||
|
||||
@@ -460,8 +460,8 @@ class TestMultiBranchCSVExport:
|
||||
|
||||
import pandas as pd
|
||||
|
||||
# Read CSV (skip comment headers)
|
||||
df = pd.read_csv(csv_path, comment="#")
|
||||
# Read CSV (skip comment headers, use tab delimiter)
|
||||
df = pd.read_csv(csv_path, comment="#", sep='\t')
|
||||
|
||||
# Should have total spectrum column
|
||||
assert "total_spectrum" in df.columns
|
||||
@@ -500,7 +500,7 @@ class TestMultiBranchCSVExport:
|
||||
|
||||
import pandas as pd
|
||||
|
||||
df = pd.read_csv(csv_path, comment="#")
|
||||
df = pd.read_csv(csv_path, comment="#", sep='\t')
|
||||
|
||||
assert "total_spectrum" in df.columns
|
||||
assert "branch_1_spectrum" in df.columns
|
||||
|
||||
Reference in New Issue
Block a user