简表末尾输出 Q_system = exp(mean|ln A_i|)
- A_i = 半高右展宽/左展宽;宽带结构(FWHM > 3x 中位数)与翼被截断的线不计入 - 同时打印参与统计的峰编号与 N
This commit is contained in:
1 parent
d03b4b0979
commit
5e40fe65db
1 file changed
+25
-3
+25
-3
@@ -1505,9 +1505,6 @@ def run(args) -> int:
|
||||
|
||||
if args.output is None:
|
||||
args.output = str(default_output_directory(args.input, indices))
|
||||
meta_out = {"created": _timestamp(),
|
||||
"recording": str(Path(args.input).expanduser().resolve())}
|
||||
result = export_all(hq, spectrum, lines, calibration, selected, args, meta_out)
|
||||
|
||||
shapes = []
|
||||
for line in lines:
|
||||
@@ -1515,6 +1512,28 @@ def run(args) -> int:
|
||||
for other in lines if other is not line]
|
||||
limit = 0.5 * min(gaps) if gaps else float("nan")
|
||||
shapes.append(ten_percent_widths(spectrum, line, limit_px=limit))
|
||||
widths = np.array([line["fwhm_px"] for line in lines
|
||||
if np.isfinite(line["fwhm_px"])])
|
||||
median_width = float(np.median(widths)) if widths.size else float("nan")
|
||||
ratios, used_ids = [], []
|
||||
for line, shape in zip(lines, shapes):
|
||||
ratio = shape["ratio"]
|
||||
if not np.isfinite(ratio) or ratio <= 0:
|
||||
continue
|
||||
if (np.isfinite(median_width) and np.isfinite(line["fwhm_px"])
|
||||
and line["fwhm_px"] > 3.0 * median_width):
|
||||
continue # broad continuum structure, not a line
|
||||
ratios.append(ratio)
|
||||
used_ids.append(line["id"])
|
||||
q_system = (float(np.exp(np.mean(np.abs(np.log(ratios))))) if ratios else float("nan"))
|
||||
|
||||
meta_out = {"created": _timestamp(),
|
||||
"recording": str(Path(args.input).expanduser().resolve()),
|
||||
"asymmetry": {"formula": "Q_system = exp(mean(|ln(A_i)|))",
|
||||
"A_i": "right_half_width / left_half_width",
|
||||
"q_system": q_system, "n_lines": len(ratios)}}
|
||||
result = export_all(hq, spectrum, lines, calibration, selected, args, meta_out)
|
||||
|
||||
write_csv(result["output"] / "peak_summary.csv",
|
||||
["id", "x_px", "left_half_px", "right_half_px", "ratio_right_over_left"],
|
||||
([line["id"], _num(line["sensor_x_px"], 4), _num(shape["left_px"], 4),
|
||||
@@ -1551,6 +1570,9 @@ def run(args) -> int:
|
||||
tell(f"{line['id']:6s}{line['sensor_x_px']:11.3f}"
|
||||
f"{_shape(shape['left_px'])}{_shape(shape['right_px'])}"
|
||||
f"{_shape(shape['ratio'])}")
|
||||
if np.isfinite(q_system):
|
||||
tell(f"Q_system = exp(mean|ln A_i|) = {q_system:.4f} (A_i = right/left, "
|
||||
f"N = {len(ratios)} of {len(lines)} lines)")
|
||||
tell(f"exported : {result['output'].expanduser().resolve()}")
|
||||
if calibration is not None:
|
||||
outside = [line["id"] for line in lines if line["extrapolated"]]
|
||||
|
||||
Reference in new issue
Block a user