ndarrays.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:stream2segment 作者: rizac 项目源码 文件源码
def get_velocity_displacement(time_step, acceleration, units="cm/s/s",
                                  velocity=None, displacement=None):
        '''
        Returns the velocity and displacement time series using simple integration.
        By providing `velocity` or `displacement` as argument(s), you can speed up
        this function by skipping either or both calculations.

        :param time_step: float: Time-series time-step (s)
        :param acceleration: numpy.ndarray: the acceleration
        :param units: the acceleration units, either "m/s/s", "m/s**2", "m/s^2", "g", "cm/s/s",
        "cm/s**2", "cm/s^2". The acceleration is supposed to
        be in centimeters over seconds square: if 'units' is not one of the last three strings,
        it will be conveted to cm/s^2 before calculation
        :param velocity: numpt.ndarray or None: if None, the velocity will be computed. Otherwise it
        is the already-computed vector of velocities and it will be returned by this function
        :param displacement: numpt.ndarray or None: if None, the displacement will be computed.
        Otherwise it is the already-computed vector of displacements and it will be returned by this
        function

        :returns:
            velocity - Velocity Time series (cm/s)
            displacement - Displacement Time series (cm)
        '''
        acceleration = ResponseSpectrum.convert_accel_units(acceleration, units)
        if velocity is None:
            velocity = time_step * cumtrapz(acceleration, initial=0.)
        if displacement is None:
            displacement = time_step * cumtrapz(velocity, initial=0.)
        return velocity, displacement
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号