rf_misc#

Save/read data to/from Matlab files.

Functions

add_tf(num1, den1, num2, den2)

Add two transfer functions in num/den format A/B+C/D = (AD+BC)/BD.

get_bit(data[, bit_id])

Get a bit from the data, the bit index starts from 0.

get_curtime_str([format])

Get the current time string.

load_mat(file_name[, to_list])

Load a matlab data file into a dict.

plot_Guassian(n[, a, mu, sigma, plot])

Draw Guassiand distribution (see fit_Guassian function in rf_fit module).

plot_ellipse(n[, a, b, x0, y0, sita, plot])

Draw an ellipse (see fit_ellipse function in rf_fit module).

save_mat(data_dict, file_name)

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

plot_Guassian(n, a=1.0, mu=0.0, sigma=1.0, plot=False)[source]#

Draw Guassiand distribution (see fit_Guassian function in rf_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 in rf_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

save_mat(data_dict, file_name)[source]#

Save a dictionary into matlab file.

Parameters:
  • data_dict – data dictionary

  • file_name – full file name including path

Returns:

status – boolean, success (True) or fail (False)