|
fosanalysis
A framework to evaluate distributed fiber optic sensor data
|
Contains miscellaneous standalone functions. More...
Functions | |
| np.array | datetime_to_timestamp (np.array datetime_array) |
| Converts an array of datetime entries to an array of Unix timestamps. | |
| tuple | find_closest_value (np.array arr, float v) |
Returns index and value in arr, that is closest to the given v. | |
| np.array | last_finite_index (np.array arr, int axis=-1) |
Returns an array with the indices of the most recent finite entry when traversing the arr along the specified axis. | |
| np.array | nan_diff (np.array arr, int axis=-1) |
| Calculate the difference to the previous finite entry. | |
| np.array | nan_diff_1d (np.array arr) |
| Calculate the difference to the previous finite entry. | |
| tuple | next_finite_neighbor (np.array array, int index, bool to_left, int recurse=0) |
Find the next finite neighbor of the entry array[index]. | |
| np_to_python (data) | |
| Convert the given data to a Python built-in type. | |
| np.array | timestamp_to_datetime (np.array timestamp_array) |
| Converts an array of Unix timestamps to an array of datetime entries. | |
Contains miscellaneous standalone functions.
| np.array fosanalysis.utils.misc.datetime_to_timestamp | ( | np.array | datetime_array | ) |
| tuple fosanalysis.utils.misc.find_closest_value | ( | np.array | arr, |
| float | v ) |
Returns index and value in arr, that is closest to the given v.
In case of equal distance of v to both neighbors, the smaller one is chosen.
| arr | Array like (1D) of values in ascending order. |
| v | The target value, to which the distance should be minimized. |
(<index>, <entry>) | np.array fosanalysis.utils.misc.last_finite_index | ( | np.array | arr, |
| int | axis = -1 ) |
Returns an array with the indices of the most recent finite entry when traversing the arr along the specified axis.
The returned array has the same shape as arr.
Example:
The first element is assumed to be a finite value. All indices before the first finite entry will be 0.
| arr | Array like. |
| axis | Axis along which to apply the indexing. Defaults to the last axis. |
Definition at line 34 of file misc.py.
| np.array fosanalysis.utils.misc.nan_diff | ( | np.array | arr, |
| int | axis = -1 ) |
Calculate the difference to the previous finite entry.
This is similar to np.diff(), but skipping NaN or inf entries. This function is a wrapper around nan_diff_1d().
Example:
| arr | Array like. |
| axis | Axis along which to calculate the incremental difference. Defaults to the last axis. |
| np.array fosanalysis.utils.misc.nan_diff_1d | ( | np.array | arr | ) |
Calculate the difference to the previous finite entry.
This is similar to np.diff(), but skipping NaN or inf entries.
Example:
| arr | Array like, needs to be 1D. |
Definition at line 71 of file misc.py.
| tuple fosanalysis.utils.misc.next_finite_neighbor | ( | np.array | array, |
| int | index, | ||
| bool | to_left, | ||
| int | recurse = 0 ) |
Find the next finite neighbor of the entry array[index].
An entry <entry> is finite, if np.isfinite(<entry>) == True.
| array | Array, on which the search is carried out. |
| index | Position in the array, where the search is started. |
| to_left | True, if a neighbor to the left of the starting index should be found, False for a neighbor to the right. |
| recurse | Number of recursions, that are done. Examples:
|
(<index>, <entry>). If no finite value could be found before reaching the end of array (None, None) is returned. Definition at line 114 of file misc.py.
| fosanalysis.utils.misc.np_to_python | ( | data | ) |
Convert the given data to a Python built-in type.
This function should be used, when type-checking. Iterables are recursively converted into list and instances of np.scalar are converted into standard data types using the method np.item().
Definition at line 150 of file misc.py.
| np.array fosanalysis.utils.misc.timestamp_to_datetime | ( | np.array | timestamp_array | ) |