Commit 35f04586 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

fixed atari bug

crash when echo phase0 was 0
parent 29b86257
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ def plot_magnetic_fields(hdfile, iecho=None, **kwargs):
        fig.suptitle(r'%s | %s | $\lambda$=%.2g$\AA$ $Q$=%.3f$\AA^{-1}$ $\tau$=%.3fns' %
                     (sample, base, lam0/ANGSTROM, q0, tau0))
        log = logging.getLogger()
        for iplt, bsensor in enumerate(bfield):
        for iplt, bsensor in enumerate(reversed(bfield)):
            bmag  = bfield[bsensor]
            label = bsensor.split('.')[-1]
            ax    = axes[iplt//nxplot,iplt%nxplot]
@@ -183,13 +183,16 @@ def plot_atari(hdfile, iecho=None, **kwargs):
        q0       = physics.attrs['hkl'][0]
        lam0     = physics.attrs['lambda']
        #J1       = physics.attrs['prim_fieldintegral']
        phase0   = float(tech.attrs['i5'][0]) or phase_pf
        phase0   = float(tech.attrs['i5'][0])
        theta0   = float(tech.attrs['mophi'][0])
        #
        lmax     = _get_lambda(params)
        dlam  = np.ones_like(lmax)*(lmax[1]-lmax[0])
        avlam = lmax - dlam/2.0

        if phase_pf is not None:
            phase0 = phase_pf

        phasesens = float(params['phaseangle'].attrs['sensitivities'][0])

        det  = phase['detector'][...]
@@ -287,6 +290,10 @@ def plot_atari(hdfile, iecho=None, **kwargs):
        if only_echo:
            _txt = r'$A(Q,t)$=%.3g$\pm$%.3g' % res['amplitude']
            minup, maxup = None, None
            log.info("Phase=%.4g(%.4g) Amp=%.4g(%.4g) Average=%.4g(%.4g)",
                phase_ef, phase_err,
                res['amplitude'][0], res['amplitude'][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))
+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ PySEN revision module
"""
import sys
__version__  = "1.2"
__release__  = "rc6"
__date__     = "Dec 6, 2022"
__release__  = "rc7"
__date__     = "Jan 6, 2023"

def version(full=False):
    "get pysen version number"
+6 −6
Original line number Diff line number Diff line
@@ -12,27 +12,27 @@ class ConfigTestCase(unittest.TestCase):
    def test_tau_limits(self):
        #
        tmin, tmax = cfg.tau_limits( 5.0, mode='shorty_2')
        self.assertAlmostEqual(  0.0116 , tmin, 4)
        self.assertAlmostEqual(  0.0023 , tmin, 4)
        self.assertAlmostEqual(  0.4659 , tmax, 4)
        #
        tmin, tmax = cfg.tau_limits( 8.0, mode='shorty_2')
        self.assertAlmostEqual(  0.0477 , tmin, 4)
        self.assertAlmostEqual(  0.0095 , tmin, 4)
        self.assertAlmostEqual(  1.9083 , tmax, 4)
        #
        tmin, tmax = cfg.tau_limits(11.0, mode='shorty_2')
        self.assertAlmostEqual(  0.1240 , tmin, 4)
        self.assertAlmostEqual(  0.0248 , tmin, 4)
        self.assertAlmostEqual(  4.9607 , tmax, 4)
        #
        tmin, tmax = cfg.tau_limits( 5.0, mode='standard')
        self.assertAlmostEqual(  0.0466 , tmin, 4)
        self.assertAlmostEqual(  0.0233 , tmin, 4)
        self.assertAlmostEqual( 13.0447 , tmax, 4)
        #
        tmin, tmax = cfg.tau_limits( 8.0, mode='standard')
        self.assertAlmostEqual(  0.1908 , tmin, 4)
        self.assertAlmostEqual(  0.0954 , tmin, 4)
        self.assertAlmostEqual( 53.4313 , tmax, 4)
        #
        tmin, tmax = cfg.tau_limits(11.0, mode='standard')
        self.assertAlmostEqual(  0.4961 , tmin, 4)
        self.assertAlmostEqual(  0.2480 , tmin, 4)
        self.assertAlmostEqual(138.9004 , tmax, 4)

    def test_pixel_angle(self):