get_capture_results¶
- typhoon.test.capture.get_capture_results(wait_capture=False, time_format='relative')¶
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.
time_format (str) –
Default is None. The available options are
'relative'
,'sim_absolute'
, and'global_absolute'
.If
'relative'
, the time index of the capture is relative to this function call.If
'sim_absolute'
, the time index of the capture is the simulation time.If
'global_absolute'
, the time index of the capture is the HIL Device synchronized time.
If this parameter is not defined the behavior will be dependent of the
absolute_time
parameter of the typhoon.test.capture.start_capture function previously defined. Ifabsolute_time = False
the time format used will be'relative'
, otherwise ifabsolute_time = True
the time format used will besim_absolute
.Note
The
'global_absolute'
will be effective only if the HIL Device is already synchronized (PTP or IRIG-B). Otherwise, the exceptionGlobalTimeSyncError
will be raised.
- Returns:
All captured signals, selectable by name, with time index
- Return type:
pandas.DataFrame
- Raises:
GlobalTimeSyncError – Raised when
timeFormat = 'global_absolute'
is used on the function:typhoon.test.capture.start_capture` and the HIL Device is not synchronized –
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