Commit a2044d2b authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

added only-echo to atariplot

parent 5d4e97b9
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -13,7 +13,9 @@ from pysen.atarilib import fit_echo_current, Spectrum

def atari_plot(hdfile, iecho=0, **kwargs):
    "atari plot"

    #
    only_echo = kwargs.pop('only_echo', False)
    #
    tbin1   = kwargs.pop('tbin1',0)      # TOF bins
    tbin2   = kwargs.pop('tbin2',None)
    # FIXME: HARDCODED
@@ -102,8 +104,6 @@ def atari_plot(hdfile, iecho=0, **kwargs):
        #for key in res:
        #    print(key, res[key])

        R = 2*res['amplitude'][0]/( res['up'][0] - res['dn'][0] )

        p = plt.errorbar(cur[:nph], pha, yerr=epha, fmt='.', lw=1)
        dcol = p[0].get_color()
        plt.errorbar(cur[nph:n_idx['up']], dn, fmt='.', color=dcol)
@@ -111,12 +111,15 @@ def atari_plot(hdfile, iecho=0, **kwargs):
        plt.plot(xef, yef, '--')
        plt.axvline(phase0,   color='blue',  lw=1, ls='--', label='%.3fA' % phase0  )
        plt.axvline(phase_ef, color='red',   lw=2, ls='-',  label='%.3fA' % phase_ef)
        ax = plt.gca()

        if not only_echo:
            R = 2*res['amplitude'][0]/( res['up'][0] - res['dn'][0] )
            plt.text(0.01, 1.01, r'$R(Q,t)$=%.3g' % R, transform=ax.transAxes)
            plt.axhline(np.average(up))
            plt.axhline(np.average(dn))
        ax = plt.gca()
        plt.text(0.18, 0.10, r'$R(Q,t)$=%.3g' % R,
                 horizontalalignment='center', verticalalignment='center', transform=ax.transAxes)
        plt.xlabel(r'phase current [A]')

        plt.legend(loc='best')
        plt.grid(True)
        plt.suptitle(r'%s    $Q$=%.3f$\AA^{-1}$ $\tau$=%.3gns' % (comment.decode("utf-8"), q0,tau0))
@@ -134,13 +137,14 @@ def main():
                        help='set min TOF bin (default=%(default)s)')
    parser.add_argument('--t2',  '-T',  dest='tbin2', type=int,   default=-1,
                        help='set max TOF bin (default=%(default)s)')
    #parser.add_argument('--phase','-p',  dest='phase', type=int,   default=None,
    #                    help='set center phase(default=%(default)s)')
    parser.add_argument('--only-echo', '-N', dest='only_echo', action='store_true',   default=False,
                        help='show only echo (no up/down)')
    args = parser.parse_args()

    kwargs = vars(args)
    for filename in args.file:
        with h5py.File(filename, 'r') as hdf5file:
            atari_plot(hdf5file, iecho=args.echo, tbin1=args.tbin1, tbin2=args.tbin2)
            atari_plot(hdf5file, iecho=args.echo, **kwargs)
    plt.show()

if __name__ == "__main__":