pydynpeak.model¶
-
class
pydynpeak.model.
DynpeakExecuter
¶ Bases:
object
Provides methods necessary to load hormonal signals, adjust detection parameters, detect pulses in signals and visualize graphs for data and detection.
Note
This class uses FigureWidget to visualize graphs. FigureWidget enables callback interactions (on_click event, etc.) on the graphs. However, renderer for FigureWidget is not able to export FigureWidget`s to other formats like “html” or “pdf” using notebook’s `File -> Download as menu.
To export the notebook to “pdf” or “html” using File->Download as menu, use DynpeakExecuterWrapper. This will only disable interaction on detection graph to view peak interval for a selected point.
-
property
currentseries
¶ Returns index of the current series.
Current series is the selected series in the dataframe. When no index is specified, all operations are executed on the current series.
- Returns
one-based index of the series in data set as current series.
- Return type
-
detect_peaks
(index=None, **params)¶ Updates LH peak parameters for the series at index with values from **params, detects peaks and returns detection results.
- Parameters
index (int, default None) – one-based index of the series in data. If no index is specified, updates parameters for the current series and detects peaks on the current series.
**params (dict, keyword arguments, dynpeak.core.utils.make_struct.<locals>._Struct) –
LH peak detection values to update. Possible keywords are:
- detectionthresholdfloat
a real value >= 0
- globalreltolfloat
a real value in the interval [0,1]
- localabstolfloat
a real value > 0
- periodfloat
a real value > 0
- threepointtolfloat
a real value in the interval [0,1]
- uncertaintylist/array of float
a list/array of the form [[a1,a2],[b1,b2]] where a1, a2 >= 0, a1 < a2, b1, b2 in interval [0, 1] and b1 <= b2.
- ignoredpointslist/array of int
list/array of sampling time indexes. Values in the list should be in range [0, n) where “n” equals the number of sampling signals in the selected interval.
- imposedpeakslist/array of int
list/array of sampling time indexes. Values in the list should be in range [0, n) where “n” equals the number of sampling signals in the selected interval.
- intervallist/array of int
a list/array with two elements [start, end] where “start” < “end” and values are in range [0, n] where “n” equals the number of sampling signals.
- Returns
a dictionary that contains detection results with the following keys:
- lh_framepandas.DataFrame
dataframe that contains the series for which detection is executed.
- ipi_framepandas.DataFrame
dataframe that contains ipi, median, t-high and t-low series after detection.
- paramsdynpeak.core.utils.make_struct.<locals>._Struct
parameters used for detection
- detected_peakspandas.Series
series that contains detected peak times and values.
- Return type
-
detect_peaks_and_plot
(index=None, **params)¶ Updates LH peak parameters for the series at index with values from **params, detects peaks, and plots results.
- Parameters
index (int, default None) – one-based index of the series in data. If no index is specified, updates parameters and detects peaks on the current series.
**params (dict, keyword arguments, dynpeak.core.utils.make_struct.<locals>._Struct) –
LH peak detection values to update. Possible keywords are:
- detectionthresholdfloat
a real value >= 0
- globalreltolfloat
a real value in the interval [0,1]
- localabstolfloat
a real value > 0
- periodfloat
a real value > 0
- threepointtolfloat
a real value in the interval [0,1]
- uncertaintylist/array of float
a list/array of the form [[a1,a2],[b1,b2]] where a1, a2 >= 0, a1 < a2, b1, b2 in interval [0, 1] and b1 <= b2.
- ignoredpointslist/array of int
list/array of sampling time indexes. Values in the list should be in range [0, n) where “n” equals the number of sampling signals.
- imposedpeakslist/array of int
list/array of sampling time indexes. Values in the list should be in range [0, n) where “n” equals the number of sampling signals.
- intervallist/array of int
a list/array with two elements [start, end] where “start” < “end” and values are in range [0, n) where “n” equals the number of sampling signals.
- Returns
a subplot of two graphs that shows LH series and detection series.
- Return type
DetectionGraphWidget
-
get_detection_params
(index=None)¶ Returns LH peak parameters for the series at index.
- Parameters
index (int, default None) – one-based index of the series in data.
- Returns
detection parameters for the series at index. If index is not specified, returns parameters for the current series. The returned structure is a copy of the values in dynpeak executer. Changing the values outside dynpeak executer does not affect the values inside.
- Return type
dynpeak.core.utils.make_struct.<locals>._Struct
-
get_peak_list
(index=None)¶ Returns peak list for the series at index.
- Parameters
index (int, default None) – one-based index of the series in data. If no index is specified, displays peaks detected for the current series.
- Returns
series that contains detected peak times and values.
If no detection is executed for the series at index, displays an error log and returns None.
- Return type
-
load_csv
(filepath, sep=',', header=None, names=None, seriesname='', timeinterval=10, timecolumn=None)¶ Loads the contents of the CSV file at filepath as dataframe.
- Parameters
filepath (str) – absolute/relative path of the CSV file.
sep (str, default ',') – separator of the CSV file.
header (int, default 'None') – None means no header, a positive integer value indicates the row number in CSV file to be used as column headers.
names (array-like, default None) – List of column names to use. If file contains no header row, then you should explicitly pass header=None.
seriesname (str, default empty str) –
column name to be used in combination with one-based column index, in the case headers do not exist in CSV file.
Example
Caraty ewes1, Caraty ewes2,… when seriesname is specified as Caraty ewes.
timeinterval (int, default 10) – time interval to generate the sampling time values.
timecolumn (int, default None) – zero-based column index that specifies the index of the column that contains sampling time values. If None, sampling time values are generated using timeinterval.
-
load_excel
(filepath, sheet_name=0, header=None, names=None, seriesname='', timeinterval=10, timecolumn=None)¶ Loads the contents of the Excel file at filepath as dataframe.
- Parameters
filepath (str) – absolute/relative path of the Excel file.
sheet_name (str or int, default 0) – Strings are used for sheet names. Integers are used in zero-indexed sheet positions.
header (str, default 'None') – None means no header, a positive integer value indicates the row number in Excel file to be used as column headers.
names (array-like, default None) – List of column names to use. If file contains no header row, then you should explicitly pass header=None.
seriesname (str, default empty str) –
column name to be used in combination with one-based column index, in the case headers do not exist in CSV file.
Example
Caraty ewes1, Caraty ewes2,… when seriesname is specified as Caraty ewes.
timeinterval (int, default 10) – time interval to generate the sampling time values.
timecolumn (int, default None) – zero-based column index that specifies the index of the column that contains sampling time values. If None, sampling time values are generated using timeinterval.
-
plot_detection_graph
(index=None)¶ Displays a subplot of two graphs that shows LH series and detection series.
- Parameters
index (int, default None) – one-based index of the series in data. If no index is specified, displays detection graph for the current series.
- Returns
a subplot of two graphs that shows LH series and detection series.
If no detection is executed for the series at index displays an error log to user and returns.
- Return type
DetectionGraphWidget
-
plot_lh
(index=None, header=None)¶ Displays the series at index.
- Parameters
index (int, default None) –
one-based index of the series in data. If index is not specified, displays the current series.
If index is negative or greater than the number of series in the dataframe, prints an error message and returns.
header (str, default None) – text to display as header for the graph.
- Returns
graph that displays the series at index.
- Return type
FigureWidget
-
plot_lh_all
(header=None)¶ Displays all the series in data in a single graph.
- Parameters
header (str, default None) – text to display as header for the graph. If not set, defaults to seriesname specified while loading data. If no seriesname is specified, it is empty string.
- Returns
graph that displays all the series in data.
- Return type
FigureWidget
-
print_detection_params
(index=None)¶ Prints LH peak parameters for the series at index.
- Parameters
index (int, default None) – one-based index of the series in data. If index is not specified, prints parameters for the current series.
-
print_peaks
(index=None)¶ Prints peak list for the series at index.
If no detection is executed for the series at index, displays an error log.
- Parameters
index (int, default None) – one-based index of the series in data. If no index is specified, displays peaks detected for the current series.
-
update_detection_params
(index=None, **params)¶ Updates LH peak parameters for the series at index with values from **params.
- Parameters
index (int, default None) – one-based index of the series in data. If index is not specified, updates parameters for the current series.
**params (dict, keyword arguments, dynpeak.core.utils.make_struct.<locals>._Struct) –
LH peak values to update. Possible keywords are:
- detectionthresholdfloat
a real value >= 0
- globalreltolfloat
a real value in the interval [0,1]
- localabstolfloat
a real value > 0
- periodfloat
a real value > 0
- threepointtolfloat
a real value in the interval [0,1]
- uncertaintylist/array of float
a list/array of the form [[a1,a2],[b1,b2]] where a1, a2 >= 0, a1 < a2, b1, b2 in interval [0, 1] and b1 < b2.
- ignoredpointslist/array of int
list/array of sampling time indexes. Values in the list should be in range [0, n) where “n” equals the number of sampling signals.
- imposedpeakslist/array of int
list/array of sampling time indexes. Values in the list should be in range [0, n) where “n” equals the number of sampling signals.
- intervallist/array of int
a list/array with two elements [start, end] where “start” < “end” and values are in range [0, n) where “n” equals the number of sampling signals.
- Returns
True if peak detection parameters are updated; False otherwise.
- Return type
-
view_all
()¶ Displays all rows in data.
- Returns
table that displays all rows in data.
- Return type
FigureWidget
-
view_head
(n=10)¶ Displays first n rows of data.
- Parameters
n (int, default 10) – number of rows to be shown.
- Returns
table that displays first n rows of data.
- Return type
FigureWidget
-
view_sampling_times
()¶ Displays sampling time values.
- Returns
table that displays sampling time values.
- Return type
FigureWidget
-
property
-
class
pydynpeak.model.
DynpeakExecuterWrapper
¶ Bases:
pydynpeak.model.dynpeakexecuter.DynpeakExecuter
A wrapper class for DynpeakExecuter to be able to export notebook to other formats like pdf or html.
-
detect_peaks_and_plot
(index=None, **params)¶ Updates LH peak parameters for the series at index with values from **params, detects peaks, and plots results.
- Parameters
index (int, default None) – one-based index of the series in data. If no index is specified, updates parameters and detects peaks on the current series.
**params (dict, keyword arguments, dynpeak.core.utils.make_struct.<locals>._Struct) –
LH peak detection values to update. Possible keywords are:
- detectionthresholdfloat
a real value >= 0
- globalreltolfloat
a real value in the interval [0,1]
- localabstolfloat
a real value > 0
- periodfloat
a real value > 0
- threepointtolfloat
a real value in the interval [0,1]
- uncertaintylist/array of float
a list/array of the form [[a1,a2],[b1,b2]] where a1, a2 >= 0, a1 < a2, b1, b2 in interval [0, 1] and b1 <= b2.
- ignoredpointslist/array of int
list/array of sampling time indexes. Values in the list should be in range [0, n) where “n” equals the number of sampling signals.
- imposedpeakslist/array of int
list/array of sampling time indexes. Values in the list should be in range [0, n) where “n” equals the number of sampling signals.
- intervallist/array of int
a list/array with two elements [start, end] where “start” < “end” and values are in range [0, n) where “n” equals the number of sampling signals.
- Returns
a subplot of two graphs that shows LH series and detection series.
- Return type
DetectionGraphWidget
-
plot_detection_graph
(index=None)¶ Displays a subplot of two graphs that shows LH series and detection series.
- Parameters
index (int, default None) – one-based index of the series in data. If no index is specified, displays detection graph for the current series.
- Returns
a subplot of two graphs that shows LH series and detection series.
If no detection is executed for the series at index displays an error log to user and returns.
- Return type
DetectionGraphWidget
-
plot_lh
(index=None, header=None)¶ Displays the series at index.
- Parameters
index (int, default None) –
one-based index of the series in data. If index is not specified, displays the current series.
If index is negative or greater than the number of series in the dataframe, prints an error message and returns.
header (str, default None) – text to display as header for the graph.
- Returns
graph that displays the series at index.
- Return type
FigureWidget
-
plot_lh_all
(header=None)¶ Displays all the series in data in a single graph.
- Parameters
header (str, default None) – text to display as header for the graph. If not set, defaults to seriesname specified while loading data. If no seriesname is specified, it is empty string.
- Returns
graph that displays all the series in data.
- Return type
FigureWidget
-
view_all
()¶ Displays all rows in data.
- Returns
table that displays all rows in data.
- Return type
FigureWidget
-
view_head
(n=10)¶ Displays first n rows of data.
- Parameters
n (int, default 10) – number of rows to be shown.
- Returns
table that displays first n rows of data.
- Return type
FigureWidget
-
view_sampling_times
()¶ Displays sampling time values.
- Returns
table that displays sampling time values.
- Return type
FigureWidget
-