rf_misc#
Save/read data to/from Matlab files.
Functions
|
Add two transfer functions in num/den format |
|
Get a bit from the data, the bit index starts from 0. |
|
Get the current time string. |
|
Load a matlab data file into a dict. |
|
Draw Guassiand distribution (see |
|
Draw an ellipse (see |
|
Save a dictionary into matlab file. |
- add_tf(num1, den1, num2, den2)[source]#
Add two transfer functions in num/den format
A/B+C/D = (AD+BC)/BD
.- Parameters:
num1 – list, polynomial coeffcients of transfer function1
den1 – list, polynomial coeffcients of transfer function1
num2 – list, polynomial coeffcients of transfer function2
den2 – list, polynomial coeffcients of transfer function2
- Returns:
num_sum, den_sum – list, polynomial coefficients of the sum
- get_bit(data, bit_id=0)[source]#
Get a bit from the data, the bit index starts from 0.
- Parameters:
data – int, the input data
bit_id – int, index of the bit
- Returns:
bit – int, 1 or 0
- get_curtime_str(format='%Y-%m-%d %H:%M:%S')[source]#
Get the current time string.
- Parameters:
format – string of format
- Returns:
time_str – string, the time string
- load_mat(file_name, to_list=False)[source]#
Load a matlab data file into a dict. this function should be called instead of direct spio.loadmat as it cures the problem of not properly recovering python dictionaries from mat files. It calls the function check keys to cure all entries which are still mat-objects.
- Parameters:
file_name – full file name including path
- Returns:
status – boolean, success (True) or fail (False)
data – dict, contain the data with the key the var name in Matlab
Note
This implementation can be found here https://stackoverflow.com/questions/7008608/scipy-io-loadmat-nested-structures-i-e-dictionaries.
- plot_Guassian(n, a=1.0, mu=0.0, sigma=1.0, plot=False)[source]#
Draw Guassiand distribution (see
fit_Guassian
function inrf_fit
module).- Parameters:
n – int, number of points
a – float, magnitude scale factor
mu – float, mean value
sigma – float, standard deviation
plot – boolean, True for enabling displaying
- Returns:
status – boolean, True for success
X, Y – numpy array, points on the curve
- plot_ellipse(n, a=1.0, b=1.0, x0=0.0, y0=0.0, sita=0.0, plot=False)[source]#
Draw an ellipse (see
fit_ellipse
function inrf_fit
module).- Parameters:
n – int, number of points
a – float, semi-major
b – float, semi-minor
x0 – float, center of the ellipse
y0 – float, center of the ellipse
sita – float, angle of the ellipse, rad
plot – boolean, True for enabling displaying
- Returns:
status – boolean, True for success
X, Y – numpy array, points on the ellipse