Loading pysen/inout/reader.py +5 −5 Original line number Diff line number Diff line Loading @@ -488,7 +488,7 @@ def read_echo(filename): slength = result.scan.pop('scan0_length' , -1) nphase = result.scan.get('no_of_phases') _log.debug('read preamble') _log.debug('read preamble: sparam=%s, slength=%s, nphase=%s', sparam, slength, nphase) data = [] act_slength = 0 while True: Loading @@ -507,10 +507,10 @@ def read_echo(filename): for _ip in range(nphase) ] data.append(AttrDict(zip(('tech', 'phys', 'params', 'phase'), ( tech, physics , params, phasept)))) _log.info(r'read %s=%d/%d', sparam, act_slength, slength) _log.info(r'read_echo %s=%d/%d', sparam, act_slength, slength) #print('.',end='', flush=True) except RuntimeError as exc: _log.warning('read %s=%d/%d failed (%s), skipping it...', sparam, act_slength, slength, str(exc)) _log.warning('read_echo %s=%d/%d failed (%s), skipping it...', sparam, act_slength, slength, str(exc)) act_slength = act_slength -1 continue # skip this # PAZ - FIXME - allow for incomplete runs Loading Loading @@ -742,9 +742,9 @@ def read_xyz(filename): detector = parse_detimage(lines) data.append(AttrDict(zip(('xyz', 'params', 'tech', 'detector'), ( xyz , params, tech, detector )))) _log.info(r'read %s=%d/%d', sparam, act_length, length) _log.info(r'read_xyz %s=%d/%d', sparam, act_length, length) except RuntimeError as exc: _log.warning('read %s=%d/%d failed (%s), skipping it...', sparam, act_length, length, str(exc)) _log.warning('read_xyz %s=%d/%d failed (%s), skipping it...', sparam, act_length, length, str(exc)) act_length = act_length -1 continue # skip this except StopIteration: Loading pysen/inout/scans.py +10 −5 Original line number Diff line number Diff line Loading @@ -173,29 +173,33 @@ class EchoScan(BaseScan): ctau = itau res = [] res.append(ipha) if res: taus.append((ctau, res)) # loop over taus and check that up and down phases are present # and number of phases is the same for all taus nphases = 0 ntaus = len(taus) updn_present = True for t,p in taus: has_dn, has_up = False, False if DN_IDX in p: has_dn = True p.remove(DN_IDX) has_dn = True if UP_IDX in p: has_up = True p.remove(UP_IDX) has_up = True if not (has_dn and has_up): self.log.warning('%s: up and/or down phase missing for tau=%d', self.info['base'], t) updn_present = updn_present and has_up and has_dn # check number of phases if not nphases: nphases=len(p) if nphases!=len(p): self.log.warning('%s: tau %s has different number of phases %d (previously %d)', self.info['base'], t, len(p), nphases) return ntaus, nphases return ntaus, nphases, updn_present def get_phase_step(self, npha, max_phase_step=180.0): "get average phase step and round it to a degree" Loading Loading @@ -224,7 +228,7 @@ class EchoScan(BaseScan): if not super().read_nexus(nxsfilename, scan_type='echo', **kwargs): return False ntaus, nphases = self.get_taus_and_phases() ntaus, nphases, has_updn = self.get_taus_and_phases() avg_step = self.get_phase_step(nphases) if phase_step is None: phase_step = round(avg_step,0) Loading @@ -235,6 +239,7 @@ class EchoScan(BaseScan): self.info['nphases'] = nphases self.info['phase_step'] = phase_step self.info['has_updn'] = has_updn # post processing self.log.info('%s: found %s tau(s), %d phases/tau, phase_step=%g (deg)', Loading pysen/inout/writer.py +8 −2 Original line number Diff line number Diff line Loading @@ -206,9 +206,15 @@ class EchoWriter(EchoScan): out.write(f"scan {echobase}\n") out.write( "* presetcounter time\n") out.write(f"* preset {preset:.2f}\n") if self.info.get('has_updn'): out.write(f"* no_of_phases {nphases+PHASE_UP}\n") else: out.write(f"* no_of_phases {nphases}\n") out.write(f"* point_to_down {nphases}\n") if self.info.get('has_updn'): out.write(f"* point_to_up {nphases+PHASE_DN}\n") else: out.write(f"* point_to_up {nphases}\n") out.write(f"* phase_step {phastep}\n") out.write( "eof\n\n") return out.getvalue() Loading pysen/plot/nseplotlib.py +4 −4 Original line number Diff line number Diff line Loading @@ -260,7 +260,7 @@ def plot_atari(hdfile, iecho=None, **kwargs): ax.axhline(ypix2-1, color='gray') ax.text(0.00, 1.01, rf"Q={qave:.3f}$\pm${qvar:.3f} $\AA^{-1}$", transform=ax.transAxes) ax.text(0.55, 1.01, rf"$\tau$={tave:.3f}$\pm${tvar:.3f} ns", transform=ax.transAxes) ax.text(0.55, 1.01, rf"$\tau$={tave:.3g}$\pm${tvar:.2g} ns", transform=ax.transAxes) ax = axes[1,1] pha = det [:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2] Loading Loading @@ -308,8 +308,8 @@ def plot_atari(hdfile, iecho=None, **kwargs): _amp[0], _amp[1], res['average'][0], res['average'][1]) else: res['up'] = average(up),sqrt(sum(up)/len(up)) res['dn'] = average(dn),sqrt(sum(dn)/len(dn)) res['up'] = average(up),sqrt(sum(up)/max(1,len(up))) res['dn'] = average(dn),sqrt(sum(dn)/max(1,len(dn))) fres = 2*res['amplitude'][0]/( res['up'][0] - res['dn'][0] ) e_fres = fres * res['amplitude'][1]/res['amplitude'][0] ax.errorbar(cur[nph:n_idx['up']], dn, fmt='.', color=dcol) Loading @@ -323,7 +323,7 @@ def plot_atari(hdfile, iecho=None, **kwargs): res['amplitude'][0], res['amplitude'][1], res['up'][0], res['up'][1], res['dn'][0], res['dn'][1]) ax.text(0.01, 1.01, _txt, transform=ax.transAxes) ax.text(0.50, 1.01, _txt, transform=ax.transAxes, horizontalalignment='center') if savefile: label=f"tau={tave:.3g}ns" outfile =f"{savefile}-{label}" Loading pysen/revision.py +2 −2 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ PySEN revision module """ import sys __version__ = "2.1.0.dev10" __date__ = "Mar 19, 2026" __version__ = "2.1.0.dev11" __date__ = "Apr 13, 2026" def version(full=False): "get pysen version number" Loading Loading
pysen/inout/reader.py +5 −5 Original line number Diff line number Diff line Loading @@ -488,7 +488,7 @@ def read_echo(filename): slength = result.scan.pop('scan0_length' , -1) nphase = result.scan.get('no_of_phases') _log.debug('read preamble') _log.debug('read preamble: sparam=%s, slength=%s, nphase=%s', sparam, slength, nphase) data = [] act_slength = 0 while True: Loading @@ -507,10 +507,10 @@ def read_echo(filename): for _ip in range(nphase) ] data.append(AttrDict(zip(('tech', 'phys', 'params', 'phase'), ( tech, physics , params, phasept)))) _log.info(r'read %s=%d/%d', sparam, act_slength, slength) _log.info(r'read_echo %s=%d/%d', sparam, act_slength, slength) #print('.',end='', flush=True) except RuntimeError as exc: _log.warning('read %s=%d/%d failed (%s), skipping it...', sparam, act_slength, slength, str(exc)) _log.warning('read_echo %s=%d/%d failed (%s), skipping it...', sparam, act_slength, slength, str(exc)) act_slength = act_slength -1 continue # skip this # PAZ - FIXME - allow for incomplete runs Loading Loading @@ -742,9 +742,9 @@ def read_xyz(filename): detector = parse_detimage(lines) data.append(AttrDict(zip(('xyz', 'params', 'tech', 'detector'), ( xyz , params, tech, detector )))) _log.info(r'read %s=%d/%d', sparam, act_length, length) _log.info(r'read_xyz %s=%d/%d', sparam, act_length, length) except RuntimeError as exc: _log.warning('read %s=%d/%d failed (%s), skipping it...', sparam, act_length, length, str(exc)) _log.warning('read_xyz %s=%d/%d failed (%s), skipping it...', sparam, act_length, length, str(exc)) act_length = act_length -1 continue # skip this except StopIteration: Loading
pysen/inout/scans.py +10 −5 Original line number Diff line number Diff line Loading @@ -173,29 +173,33 @@ class EchoScan(BaseScan): ctau = itau res = [] res.append(ipha) if res: taus.append((ctau, res)) # loop over taus and check that up and down phases are present # and number of phases is the same for all taus nphases = 0 ntaus = len(taus) updn_present = True for t,p in taus: has_dn, has_up = False, False if DN_IDX in p: has_dn = True p.remove(DN_IDX) has_dn = True if UP_IDX in p: has_up = True p.remove(UP_IDX) has_up = True if not (has_dn and has_up): self.log.warning('%s: up and/or down phase missing for tau=%d', self.info['base'], t) updn_present = updn_present and has_up and has_dn # check number of phases if not nphases: nphases=len(p) if nphases!=len(p): self.log.warning('%s: tau %s has different number of phases %d (previously %d)', self.info['base'], t, len(p), nphases) return ntaus, nphases return ntaus, nphases, updn_present def get_phase_step(self, npha, max_phase_step=180.0): "get average phase step and round it to a degree" Loading Loading @@ -224,7 +228,7 @@ class EchoScan(BaseScan): if not super().read_nexus(nxsfilename, scan_type='echo', **kwargs): return False ntaus, nphases = self.get_taus_and_phases() ntaus, nphases, has_updn = self.get_taus_and_phases() avg_step = self.get_phase_step(nphases) if phase_step is None: phase_step = round(avg_step,0) Loading @@ -235,6 +239,7 @@ class EchoScan(BaseScan): self.info['nphases'] = nphases self.info['phase_step'] = phase_step self.info['has_updn'] = has_updn # post processing self.log.info('%s: found %s tau(s), %d phases/tau, phase_step=%g (deg)', Loading
pysen/inout/writer.py +8 −2 Original line number Diff line number Diff line Loading @@ -206,9 +206,15 @@ class EchoWriter(EchoScan): out.write(f"scan {echobase}\n") out.write( "* presetcounter time\n") out.write(f"* preset {preset:.2f}\n") if self.info.get('has_updn'): out.write(f"* no_of_phases {nphases+PHASE_UP}\n") else: out.write(f"* no_of_phases {nphases}\n") out.write(f"* point_to_down {nphases}\n") if self.info.get('has_updn'): out.write(f"* point_to_up {nphases+PHASE_DN}\n") else: out.write(f"* point_to_up {nphases}\n") out.write(f"* phase_step {phastep}\n") out.write( "eof\n\n") return out.getvalue() Loading
pysen/plot/nseplotlib.py +4 −4 Original line number Diff line number Diff line Loading @@ -260,7 +260,7 @@ def plot_atari(hdfile, iecho=None, **kwargs): ax.axhline(ypix2-1, color='gray') ax.text(0.00, 1.01, rf"Q={qave:.3f}$\pm${qvar:.3f} $\AA^{-1}$", transform=ax.transAxes) ax.text(0.55, 1.01, rf"$\tau$={tave:.3f}$\pm${tvar:.3f} ns", transform=ax.transAxes) ax.text(0.55, 1.01, rf"$\tau$={tave:.3g}$\pm${tvar:.2g} ns", transform=ax.transAxes) ax = axes[1,1] pha = det [:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2] Loading Loading @@ -308,8 +308,8 @@ def plot_atari(hdfile, iecho=None, **kwargs): _amp[0], _amp[1], res['average'][0], res['average'][1]) else: res['up'] = average(up),sqrt(sum(up)/len(up)) res['dn'] = average(dn),sqrt(sum(dn)/len(dn)) res['up'] = average(up),sqrt(sum(up)/max(1,len(up))) res['dn'] = average(dn),sqrt(sum(dn)/max(1,len(dn))) fres = 2*res['amplitude'][0]/( res['up'][0] - res['dn'][0] ) e_fres = fres * res['amplitude'][1]/res['amplitude'][0] ax.errorbar(cur[nph:n_idx['up']], dn, fmt='.', color=dcol) Loading @@ -323,7 +323,7 @@ def plot_atari(hdfile, iecho=None, **kwargs): res['amplitude'][0], res['amplitude'][1], res['up'][0], res['up'][1], res['dn'][0], res['dn'][1]) ax.text(0.01, 1.01, _txt, transform=ax.transAxes) ax.text(0.50, 1.01, _txt, transform=ax.transAxes, horizontalalignment='center') if savefile: label=f"tau={tave:.3g}ns" outfile =f"{savefile}-{label}" Loading
pysen/revision.py +2 −2 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ PySEN revision module """ import sys __version__ = "2.1.0.dev10" __date__ = "Mar 19, 2026" __version__ = "2.1.0.dev11" __date__ = "Apr 13, 2026" def version(full=False): "get pysen version number" Loading