From 43d37f0f5e6d9b5768a353b3b73ff2833baeb199 Mon Sep 17 00:00:00 2001 From: Brett Viren Date: Fri, 22 Dec 2023 08:47:08 -0500 Subject: [PATCH] Generate splat smears as org table --- wirecell/gen/__main__.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/wirecell/gen/__main__.py b/wirecell/gen/__main__.py index 76d9981..c4ea9bf 100644 --- a/wirecell/gen/__main__.py +++ b/wirecell/gen/__main__.py @@ -361,11 +361,6 @@ def morse_splat(output, summary): ''' Spit out configuration for DepoFluxSplat given a morse summary ''' - if ".json" in output: - fmt = "json" - else: - fmt = "text" - from .morse import load_frame_peaks summary = load_frame_peaks(summary) @@ -386,14 +381,24 @@ def morse_splat(output, summary): res.append(dict(tick_sigma=tsigma, pitch_sigma=psigma)) with open(output, "w") as out: - if fmt == "text": - for one in res: - out.write('sigmas: tick={tick_sigma} pitch={pitch_sigma}\n'.format(**one)) - else: # json + if '.json' in output: # match schema for DepoFluxSplat dfs = dict(smear_long = [r['tick_sigma'] for r in res], smear_tran = [r['pitch_sigma'] for r in res]) out.write(json.dumps(dfs, indent=4)) + if '.org' in output: + lines=[ + '|plane|tick|pitch|', + '|-----|----|-----|' + ] + for l,r in zip("UVZ",res): + line = f'|{l}|{r["tick_sigma"]:.3f}|{r["pitch_sigma"]:.3f}|' + lines.append(line) + print('\n'.join(lines)) + + else: + for one in res: + out.write('sigmas: tick={tick_sigma} pitch={pitch_sigma}\n'.format(**one)) @cli.command("morse-plots")