Example #1
0
    def mk_R_axis(self, axes, Rj, plunge=0, tlab=None, xlab=''):
        if tlab is None:
            tlab = Rj
        R = self.pos[:, 0]

        i0, i1 = self['Rs'].plunges(plunge, 'in')
        R_in = R[i1:i0:-1]
        tj_in = AmpSignal(R_in.t, R_in.x)(Rj).x

        i0, i1 = self['Rs'].plunges(plunge, 'out')
        R_out = R[i0:i1]
        tj_out = AmpSignal(R_out.t, R_out.x)(Rj).x

        tj_inout = np.r_[tj_in[::-1], tj_out]
        tlab_inout = np.r_[tlab[::-1], tlab]

        axes_ = [ax.get_2nd_axes(xloc='top') for ax in axes[:]]
        ax0_ = axes_[0]
        ax0_.set_xlabel(xlab)
        ax0_.set_xticks(tj_inout)
        ax0_.set_xticklabels(tlab_inout)
        for ax_ in axes_[1:]:
            ax_.set_xticks(tj_inout)
            ax_.set_xticklabels([])
        return axes_
Example #2
0
    def __init__(self, x, t, amp=None, dtype=np.float64, **kw):
        kw.setdefault('type', 'Current')
        kw.setdefault('units', 'A')

        AmpSignal.__init__(self, x, t, amp, dtype, **kw)

        self.V = kw.get('V', None)
        self.C = kw.get('C', None)
Example #3
0
    def __init__(self, x, t, amp=None, dtype=np.float64, **kw):
        kw.setdefault('type', 'Voltage')
        kw.setdefault('units', 'V')

        self.dt = kw.pop('dt', 0.1)
        self.min_ptp = kw.pop('min_ptp', 50)

        AmpSignal.__init__(self, x, t, amp, dtype, **kw)
Example #4
0
    def __init__(self, x, t, amp=None, dtype=np.float64, **kw):
        kw.setdefault('type', 'Position')
        kw.setdefault('units', 'm')

        AmpSignal.__init__(self, x, t, amp, dtype, **kw)

        self.baseline_slice = kw.get('baseline_slice', slice(None, 1000))
        self.lvl_fact = kw.get('lvl_fact', 0.1)
        self.dist_threshold = kw.get('dist_threshold', 1000)
Example #5
0
 def make_sig(self, node, x, t):
     if self.window is not None:
         x = x[self.window]
         t = t[self.window]
     if node in self.amp:
         amp = self.amp[node]
     else:
         amp = None
     return AmpSignal(x, t, amp=amp, dtype=np.float64, name=node)
Example #6
0
    def get_separatrix(self, chn='H-5'):
        S = self[chn]
        t = np.asanyarray(S.t, np.float64)
        Spl = (self._psi_spl[chn] - 1.).eval_x(t)

        sep = np.zeros((t.size, 2))
        sep.fill(np.nan)
        for spl, s in izip(Spl, sep):
            spl.roots(s)

        kw = dict(units='m', label=chn)
        sep = ma.masked_invalid(sep)
        (Rm, zm), (RM, zM) = self.geom.get_rays(chn)
        dR, dz = RM - Rm, zM - zm
        d = np.sqrt(dR * dR + dz * dz)

        R = AmpSignal(Rm + dR * sep, t, type='Rsep', **kw)
        z = AmpSignal(zm + dz * sep, t, type='zsep', **kw)
        d = AmpSignal(d * (sep[:, 1] - sep[:, 0]), t, type='dsep', **kw)
        sep = dict(R=R, z=z, d=d)
        return sep
Example #7
0
    def mapsig(self):
        x = self.get_sig('ampR')
        nans = np.zeros(x.shape, np.float32)
        nans.fill(np.nan)
        Nans = AmpSignal(nans, x._t)

        def get_sig_amp(key):
            try:
                return self.get_sig(key), self.get_amp(key)
            except KeyError:
                return Nans, amp_unity

        x, amp = get_sig_amp('ampR')
        R = PositionSignal(x._x, x._t, amp * x.amp, name='R')

        S = OrderedDict(R=R)

        for tip in self.head.tips:
            i = tip.number
            keys = self.get_keys(tip.name)

            x, amp = get_sig_amp(keys['V'])
            V = VoltageSignal(x._x,
                              x._t,
                              amp * x.amp,
                              number=i,
                              name='V%d' % i,
                              label=tip.label)

            x, amp = get_sig_amp(keys['I'])
            I = CurrentSignal(x._x,
                              x._t,
                              amp * x.amp,
                              V=V,
                              number=i,
                              name='I%d' % i,
                              label=tip.label)

            S[tip.name] = I

        return S
Example #8
0
 def psi_n(self):
     psi = self.psi
     fact = 1. / (self.psi1._x - self.psi0._x)
     offs = -self.psi0._x * fact
     amp = Amp(fact[:, None, None], offs[:, None, None])
     return AmpSignal(psi._x, psi._t, amp, psi.dtype, **psi.kw)
Example #9
0
 def __init__(self, x, t, *args, **kw):
     kw.setdefault('name', 'psi_n')
     kw.setdefault('type', 'Normalized flux')
     kw.setdefault('label', 'Normalized flux')
     kw.setdefault('units', '')
     AmpSignal.__init__(self, x, t, *args, **kw)