Esempio n. 1
0
    def Delay(self, delayProf):
        """
        Compute the delayed profile composed of *self* profile and *delayProf*,
        received by a node for which this *self* profile is the output profile on the sender side.
        The delay profile describes the delay as a function of time for the link.

        This function implements the operation: 

        .. math::
            o[t + \delta[t]] = l[t]

        Where

        * :math:`\delta[t]` is the delay profile
        * :math:`l[t]` is the profile transmitted into the link (*self*)
        * :math:`o[t]` is the output profile received at the other end of the link

        :rtype: :class:`Profile`, :math:`o[t]`

        :param in delayProf: :class:`Profile` describing the delay
        """
        delays = delayProf.entries['latency']
        all0 = True
        for time, delay in delays:
            if delay != 0:
                all0 = False
        if all0: return copy.deepcopy(self)
        datas = self.entries['data']
        endTime = datas[-1][0]
        times = [ x[0] for x in delays ]
        times.extend( [ x[0] for x in datas ] )
        times = sorted(list(set(times)))
        newDatas = []
        for t in times:
            d = utils.get_value_at_time(datas, t)
            delay = utils.get_value_at_time(delays, t, interpolate = 'latency' in self.interpolated_profiles)
            newDatas.append([ t + delay, d ])
        newDatas = utils.remove_degenerates(newDatas)
        newDatas, remainder = utils.split(newDatas, endTime)
        if remainder:
            t = -remainder[0][0]
            utils.shift(remainder, t)
            r_slopes = utils.derive(remainder)
            d_slopes = utils.derive(newDatas)
            d_slopes = utils.add_values(d_slopes,r_slopes)
            newDatas = utils.integrate(d_slopes, endTime)

        retProf = Profile()
        retProf.entries['data'] = newDatas
        retProf.Derive()
        return retProf
    def updateDatasets(self, fields, helper):
        """	This function should *update* the dataset(s) returned by getDatasets
        """
        # get the input dataset - helper provides methods for getting other
        # datasets from Veusz
        ds_y = np.array(helper.getDataset(fields['ds_y']).data)
        # get the value to add
        order = fields['order']
        method = fields['method']
        smooth_num = fields['smooth']
        ds_x = None
        if smooth_num > 0:
            ds_y = smooth(ds_y, smooth_num, 'hanning')
        if fields['ds_x'] != '':
            # Derive with respect to X
            ds_x = np.array(helper.getDataset(fields['ds_x']).data)
            if smooth_num > 0:
                ds_x = smooth(ds_x, smooth_num, 'hanning')
            out = xyderive(ds_x, ds_y, order, method)
        else:
            # Derive with respect to point indexes
            out = derive(ds_y, method, order)

        self.ds_out.update(data=out)
        return [self.ds_out]
Esempio n. 3
0
 def Derive(self):
     """Derives the slope entries from the data entries"""
     self.entries['slope'] = utils.derive( self.entries['data'] )
     self.AggregateSlopes()