def integrated_change(ts, integrator=integrate.trapz, clip_floor=None, clip_ceil=float('inf')):
    """Total value * time above the starting value within a TimeSeries"""
    integrator = get_integrator(integrator)
    if clip_floor is None:
        clip_floor = ts[0]
    if clip_ceil < clip_floor:
        polarity = -1
        offset, clip_floor, clip_ceil, = clip_ceil, clip_ceil, clip_floor
    else:
        polarity, offset = 1, clip_floor
    clipped_values = np.clip(ts.values - offset, clip_floor, clip_ceil)
    print(polarity, offset, clip_floor, clip_ceil)
    print(clipped_values)
    integrator_types = set(['trapz', 'cumtrapz', 'simps', 'romb'])
    if integrator in integrator_types:
        integrator = getattr(integrate, integrator)
    integrator = integrator or integrate.trapz
    # datetime units converted to seconds (since 1/1/1970)
    return integrator(clipped_values, ts.index.astype(np.int64) / 10 ** 9)
def integrated_change ( ts , integrator = integrate . trapz , clip_floor = None , clip_ceil = float ( 'inf' ) ) : integrator = get_integrator ( integrator ) if clip_floor is None : clip_floor = ts [ 0 ] if clip_ceil < clip_floor : polarity = - 1 offset , clip_floor , clip_ceil , = clip_ceil , clip_ceil , clip_floor else : polarity , offset = 1 , clip_floor clipped_values = np . clip ( ts . values - offset , clip_floor , clip_ceil ) print ( polarity , offset , clip_floor , clip_ceil ) print ( clipped_values ) integrator_types = set ( [ 'trapz' , 'cumtrapz' , 'simps' , 'romb' ] ) if integrator in integrator_types : integrator = getattr ( integrate , integrator ) integrator = integrator or integrate . trapz return integrator ( clipped_values , ts . index . astype ( np . int64 ) / 10 ** 9 )
Total value * time above the starting value within a TimeSeries