Skip to content

Instantly share code, notes, and snippets.

View daguiam's full-sized avatar

Diogo Aguiam daguiam

View GitHub Profile
@daguiam
daguiam / testgist.py
Created October 26, 2016 13:53
Test Gist!
print 'test gist'
import matplotlib.pyplot as plt
fig, axes = plt.subplots(3, 4, sharex=True, sharey=True)
# add a big axes, hide frame
fig.add_subplot(111, frameon=False)
# hide tick and tick label of the big axes
plt.tick_params(labelcolor='none', top='off', bottom='off', left='off', right='off')
plt.xlabel("common X")
plt.ylabel("common Y")
plt.show()
import matplotlib.pyplot as plt
fig, axes = plt.subplots(3, 4, sharex=True, sharey=True)
# add a big axes, hide frame
fig.add_subplot(111, frameon=False)
# hide tick and tick label of the big axes
plt.tick_params(labelcolor='none', top='off', bottom='off', left='off', right='off')
plt.xlabel("common X")
plt.ylabel("common Y")
plt.show()
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:
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
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)
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
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)
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
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