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

nseplotlib fixes

parent 1f0a80db
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ def plot_field(ax,t,v,**kwargs):
    axis     = kwargs.get('axis', -1)
    label    = kwargs.get('label'  , '')
    max_chi2 = kwargs.get('max_chi2', MAX_CHI2_DEFAULT_BFIELD)
    v0 = sqrt(sum(v**2,axis=-1))
    v0 = sqrt(np.sum(v**2,axis=-1))
    if axis>0:
        v0 = v[:,axis-1]
        label = "%s (%s)" % (label,{1:'x',2:'y',3:'z'}.get(axis,''))
@@ -196,7 +196,7 @@ def plot_atari(hdfile, iecho=None, **kwargs):
        #
        edet = sqrt(det)/pcha
        det  = det/pcha
        wlen = sum(det, axis=(0,1,2)) # all but TOF axis
        wlen = np.sum(det, axis=(0,1,2)) # all but TOF axis
        #

        YY, XX, TT = np.mgrid[ypix1:ypix2, xpix1:xpix2, tbin1:tbin2 or nt]
@@ -221,7 +221,7 @@ def plot_atari(hdfile, iecho=None, **kwargs):
        ax.grid(True)

        ax = axes[0,1]
        xatari = sum(det, axis=(1,2)).T
        xatari = np.sum(det, axis=(1,2)).T
        extent = (cur[0], cur[nph-1])
        if tbin2 is None:
            extent = extent + (lmax[tbin1]/ANGSTROM, max(lmax)/ANGSTROM)
@@ -232,7 +232,7 @@ def plot_atari(hdfile, iecho=None, **kwargs):
        ax.imshow(xatari, origin='lower', extent=extent, aspect='auto')

        ax = axes[1,0]
        img = sum(det[:,:,:,tbin1:tbin2], axis=(0,-1))
        img = np.sum(det[:,:,:,tbin1:tbin2], axis=(0,-1))
        if logz:
            norm = colors.LogNorm(max(1,vmin), vmax)
            im = ax.imshow(img , aspect='equal', norm=norm)
@@ -251,13 +251,13 @@ def plot_atari(hdfile, iecho=None, **kwargs):
        ax = axes[1,1]
        pha  = det [:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2]
        epha = edet[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2]
        wlen = sum(pha, axis=(0,1,2)) # all but TOF axis
        wlen = np.sum(pha, axis=(0,1,2)) # all but TOF axis

        dn   = sum(pha[nph:n_idx['up']], axis=(1,2,3))
        up   = sum(pha[n_idx['up']:], axis=(1,2,3))
        #epha = sqrt(sum(pha[:nph], axis=(1,2,3)))
        epha = sqrt(sum(epha[:nph]**2, axis=(1,2,3)))
        pha  = sum(pha[:nph], axis=(1,2,3))
        dn   = np.sum(pha[nph:n_idx['up']], axis=(1,2,3))
        up   = np.sum(pha[n_idx['up']:], axis=(1,2,3))
        #epha = sqrt(np.sum(pha[:nph], axis=(1,2,3)))
        epha = sqrt(np.sum(epha[:nph]**2, axis=(1,2,3)))
        pha  = np.sum(pha[:nph], axis=(1,2,3))

        spectrum =  Spectrum(lam=lmax[tbin1:tbin2], dlam=dlam[tbin1:tbin2], flux=wlen)# [tbin1:tbin2])
        (phase_ef, phase_err), (xef, yef), res = fit_echo_current(cur[:nph], (pha, epha), spectrum, global_fit=phase_pf is None,
@@ -383,7 +383,7 @@ def plot_map(hdfile, iecho=None, **kwargs):
        pcha0 = average(pcha)
        pcha = pcha[:,np.newaxis,np.newaxis,np.newaxis]/float(pcha0)
        det  = det/pcha
        #wlen = sum(det, axis=(0,1,2))
        #wlen = np.sum(det, axis=(0,1,2))

        #spectrum =  Spectrum(lam=lmax, dlam=dlam, flux=wlen)
        #spectrum =  Spectrum(lam=lmax[tbin1:tbin2], dlam=dlam[tbin1:tbin2], flux=wlen[tbin1:tbin2])
@@ -395,13 +395,13 @@ def plot_map(hdfile, iecho=None, **kwargs):
        nxx = nx//npix
        pha = det.reshape(npx, nyy, npix, nxx, npix, nt)
        pha = pha.sum(axis=(2, 4)) # pixel rebin
        pha = sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation
        pha = np.sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation


        dn  = average(pha[nph:n_idx['up'],:,:], axis=0)
        up  = average(pha[n_idx['up']:   ,:,:], axis=0)

        #y  = sum(det[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2], axis=(1,2,3))
        #y  = np.sum(det[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2], axis=(1,2,3))
        #ey = sqrt(y)
        #(phase_ef0,_) , (xef,yef), res = fit_echo_current(cur[:nph], (y[:nph], ey[:nph]), spectrum,
        #                                             lam0=lam0, phase0=phase0, phasesens=phasesens,
@@ -515,12 +515,12 @@ def plot_echo(hdfile, iecho=None, **kwargs):
        pcha0 = average(pcha)
        pcha = pcha[:,np.newaxis,np.newaxis,np.newaxis]/float(pcha0)
        det  = det/pcha
        wlen = sum(det, axis=(0,1,2))
        wlen = np.sum(det, axis=(0,1,2))

        #spectrum =  Spectrum(lam=lmax, dlam=dlam, flux=wlen)
        spectrum =  Spectrum(lam=lmax[tbin1:tbin2], dlam=dlam[tbin1:tbin2], flux=wlen[tbin1:tbin2])

        y  = sum(det[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2], axis=(1,2,3))
        y  = np.sum(det[:,ypix1:ypix2,xpix1:xpix2,tbin1:tbin2], axis=(1,2,3))
        ey = sqrt(y)
        dn = y[nph:n_idx['up']]
        up = y[n_idx['up']:]
@@ -563,7 +563,7 @@ def plot_echo(hdfile, iecho=None, **kwargs):
        nxx = nx//npix
        pha = det.reshape(npx, nyy, npix, nxx, npix, nt)
        pha = pha.sum(axis=(2, 4)) # pixel rebin
        pha = sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation
        pha = np.sum(pha[:,:,:,tbin1:tbin2],axis=-1) # tof summation


        fig, axes = plt.subplots(nxx,nyy, figsize=(8,8))
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ def version(full=False):
    if __release__ == 'release':
        ver = "%s" % __version__
    else:
        ver = "%s.%s" % (__version__, __release__)
        ver = "%s%s" % (__version__, __release__)
    if full:
        py_ver = " Python %s.%s" % (sys.version_info.major, sys.version_info.minor)
        ver = "%s (%s) %s" % (ver, __date__, py_ver)