get_capture_results

typhoon.test.capture.get_capture_results(wait_capture=False)

Return capture results as a Pandas DataFrame.

Parameters:

wait_capture – If True, blocks until capture finishes. If False, immediately stops capture and return captured results so far.

Returns:

All captured signals, selectable by name, with time index

Return type:

pandas.DataFrame

Examples

Importing libraries

>>> from typhoon.test.capture import start_capture, get_capture_results

Returning results immediately

>>> start_capture(duration=20, rate=100000, signals=["P", "Va_rms"])
>>> # do something in meantime which takes 10 seconds...
>>> capture = get_capture_results() # returns capture up to 10 seconds

Waiting whole capture duration

>>> start_capture(duration=20, rate=100000, signals=["P", "Va_rms"])
>>> # do something in meantime which takes 10 seconds...
>>> capture = get_capture_results(wait_capture=True) # waits until the 20 second capture elapses

Individual signals can be accessed in a dict-like fashion:

>>> print(capture) #pandas DataFrame
>>> print(capture["P"]) #pandas Series

The values can be accessed using:

>>> capture["P"].values # return array

The index is a TimedeltaIndex, which contains Typhoon custom Timedeltas:

>>> index = capture["P"].index
>>> index[0] # Time for first point (Timedelta)
>>> index[0].total_seconds() # returns a float with time as seconds

You can slice using time directly using time, for example here from 10 seconds onwards:

>>> capture["P"]["10s":]

Some TyphoonTest functions return timedeltas, which also can be used for slicing:

>>> from typhoon.test.signals import find
>>> t_fullpower = find(capture["P"], region="at", value=100000)
>>> capture["P"][t_fullpower-"1s":t_fullpower] # slices the period 1 second before t_fullpower

Other DataFrame and Series example

>>> from typhoon.test.signals import pandas_3ph_sine
>>> df = pandas_3ph_sine()
>>> df
>>> sine1 = df["sine1"]
>>> sine1

References

Pandas Documentation