This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rant = data['r'][0][0] | |
zant = data['z'][0][0] | |
sep_z = data['sep_z'] | |
sep_r = data['sep_r'] | |
sep_ra = np.linalg.norm(np.array([sep_r-rant,sep_z-zant]),axis=0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def expand_time(time, shape, verbose=True): | |
if verbose: | |
print 'Old time shape:',time.shape,'new shape:',shape | |
output = np.tile(time, shape[1]).reshape(np.fliplr([shape])[0]).T | |
if verbose: | |
print 'output time shape:',output.shape | |
return output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Calculate mean std of clipped array""" | |
import numpy as np | |
from scipy import interpolate | |
def calc_func_clipped(X, Y, func=np.mean, npoints=None, verbose=False): | |
""" Calculates func of Y values, where Y is clipped to the longest continuous | |
values of X to prevent aliasing | |
""" | |
# Size of each data vector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
def func(verbose=False, log=False): | |
if log: | |
logging.basicConfig(level=getattr(logging, log.upper(), 10)) | |
logger = logging.getLogger() | |
msg = "Message" | |
logger.info(msg) | |
if verbose: | |
print msg | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def getData(fd, sweepnr, sweepwidth=3000, rawdatatype='int16' ): | |
byte_offset = sweepwidth * sweepnr * np.dtype(rawdatatype).itemsize | |
fd.seek(byte_offset) | |
sig = np.fromfile(fd,dtype=rawdatatype,count=sweepwidth) | |
return sig | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy import signal | |
def filtfilt_lowpass(sig,cutoff,Fs=1,order=5): | |
""" Low pass butterworth filt filter | |
""" | |
nyq = np.float(Fs)/2 | |
cutoffnorm = cutoff/nyq; | |
b, a = signal.butter(order,cutoffnorm,btype='low'); | |
sig = signal.filtfilt(b,a,sig) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def filtfilt_lowpass(sig,cutoff,Fs=1,order=5): | |
""" Low pass butterworth filt filter | |
""" | |
nyq = np.float(Fs)/2 | |
cutoffnorm = cutoff/nyq; | |
b, a = signal.butter(order,cutoffnorm,btype='low'); | |
sig = signal.filtfilt(b,a,sig) | |
return sig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy.signal | |
def freq_hilbert(sig,Fs): | |
""" Calcultes the instantaneous frequency based on the hilbert | |
transform | |
""" | |
sigorig = sig | |
sig = sig.real | |
ts = 1.0/Fs | |
hilb = scipy.signal.hilbert(sig) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_moving_avg_std(x, window=10): | |
""" | |
Calculates the moving average and standard deviation along the window | |
Parameters | |
---------- | |
x : array | |
window : int (default=10) | |
Window size | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert_dict_keys_to_numpy(dictionary): | |
""" | |
Converts each element in dictionary to numpy array | |
Parameters: | |
---------- | |
dictionary : dict | |
Dictionary where each element is a list that must be converted to array | |
Returns: |