partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
wait
Decorator for adding wait animation to long running functions. Args: animation (str, tuple): String reference to animation or tuple with custom animation. speed (float): Number of seconds each cycle of animation. Examples: >>> @animation.wait('bar') >>> def long...
animation/decorators.py
def wait(animation='elipses', text='', speed=0.2): """ Decorator for adding wait animation to long running functions. Args: animation (str, tuple): String reference to animation or tuple with custom animation. speed (float): Number of seconds each cycle of animation. Ex...
def wait(animation='elipses', text='', speed=0.2): """ Decorator for adding wait animation to long running functions. Args: animation (str, tuple): String reference to animation or tuple with custom animation. speed (float): Number of seconds each cycle of animation. Ex...
[ "Decorator", "for", "adding", "wait", "animation", "to", "long", "running", "functions", "." ]
bprinty/animation
python
https://github.com/bprinty/animation/blob/e5c87bf593de1f04e5ce341496b8dff7ce5296ee/animation/decorators.py#L105-L143
[ "def", "wait", "(", "animation", "=", "'elipses'", ",", "text", "=", "''", ",", "speed", "=", "0.2", ")", ":", "def", "decorator", "(", "func", ")", ":", "func", ".", "animation", "=", "animation", "func", ".", "speed", "=", "speed", "func", ".", "...
e5c87bf593de1f04e5ce341496b8dff7ce5296ee
train
simple_wait
Decorator for adding simple text wait animation to long running functions. Examples: >>> @animation.simple_wait >>> def long_running_function(): >>> ... 5 seconds later ... >>> return
animation/decorators.py
def simple_wait(func): """ Decorator for adding simple text wait animation to long running functions. Examples: >>> @animation.simple_wait >>> def long_running_function(): >>> ... 5 seconds later ... >>> return """ @wraps(func) def wrapper(*args, **kw...
def simple_wait(func): """ Decorator for adding simple text wait animation to long running functions. Examples: >>> @animation.simple_wait >>> def long_running_function(): >>> ... 5 seconds later ... >>> return """ @wraps(func) def wrapper(*args, **kw...
[ "Decorator", "for", "adding", "simple", "text", "wait", "animation", "to", "long", "running", "functions", "." ]
bprinty/animation
python
https://github.com/bprinty/animation/blob/e5c87bf593de1f04e5ce341496b8dff7ce5296ee/animation/decorators.py#L146-L167
[ "def", "simple_wait", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "wait", "=", "Wait", "(", ")", "wait", ".", "start", "(", ")", "try", ":", "ret", "=", "func", ...
e5c87bf593de1f04e5ce341496b8dff7ce5296ee
train
Wait.start
Start animation thread.
animation/decorators.py
def start(self): """ Start animation thread. """ self.thread = threading.Thread(target=self._animate) self.thread.start() return
def start(self): """ Start animation thread. """ self.thread = threading.Thread(target=self._animate) self.thread.start() return
[ "Start", "animation", "thread", "." ]
bprinty/animation
python
https://github.com/bprinty/animation/blob/e5c87bf593de1f04e5ce341496b8dff7ce5296ee/animation/decorators.py#L84-L90
[ "def", "start", "(", "self", ")", ":", "self", ".", "thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_animate", ")", "self", ".", "thread", ".", "start", "(", ")", "return" ]
e5c87bf593de1f04e5ce341496b8dff7ce5296ee
train
Wait.stop
Stop animation thread.
animation/decorators.py
def stop(self): """ Stop animation thread. """ time.sleep(self.speed) self._count = -9999 sys.stdout.write(self.reverser + '\r\033[K\033[A') sys.stdout.flush() return
def stop(self): """ Stop animation thread. """ time.sleep(self.speed) self._count = -9999 sys.stdout.write(self.reverser + '\r\033[K\033[A') sys.stdout.flush() return
[ "Stop", "animation", "thread", "." ]
bprinty/animation
python
https://github.com/bprinty/animation/blob/e5c87bf593de1f04e5ce341496b8dff7ce5296ee/animation/decorators.py#L92-L100
[ "def", "stop", "(", "self", ")", ":", "time", ".", "sleep", "(", "self", ".", "speed", ")", "self", ".", "_count", "=", "-", "9999", "sys", ".", "stdout", ".", "write", "(", "self", ".", "reverser", "+", "'\\r\\033[K\\033[A'", ")", "sys", ".", "std...
e5c87bf593de1f04e5ce341496b8dff7ce5296ee
train
merge
Merge several timeseries Arguments: tup: sequence of Timeseries, with the same shape except for axis 0 Returns: Resulting merged timeseries which can have duplicate time points.
nsim/timeseries.py
def merge(tup): """Merge several timeseries Arguments: tup: sequence of Timeseries, with the same shape except for axis 0 Returns: Resulting merged timeseries which can have duplicate time points. """ if not all(tuple(ts.shape[1:] == tup[0].shape[1:] for ts in tup[1:])): raise V...
def merge(tup): """Merge several timeseries Arguments: tup: sequence of Timeseries, with the same shape except for axis 0 Returns: Resulting merged timeseries which can have duplicate time points. """ if not all(tuple(ts.shape[1:] == tup[0].shape[1:] for ts in tup[1:])): raise V...
[ "Merge", "several", "timeseries", "Arguments", ":", "tup", ":", "sequence", "of", "Timeseries", "with", "the", "same", "shape", "except", "for", "axis", "0", "Returns", ":", "Resulting", "merged", "timeseries", "which", "can", "have", "duplicate", "time", "poi...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L865-L875
[ "def", "merge", "(", "tup", ")", ":", "if", "not", "all", "(", "tuple", "(", "ts", ".", "shape", "[", "1", ":", "]", "==", "tup", "[", "0", "]", ".", "shape", "[", "1", ":", "]", "for", "ts", "in", "tup", "[", "1", ":", "]", ")", ")", "...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.add_analyses
Dynamically add new analysis methods to the Timeseries class. Args: source: Can be a function, module or the filename of a python file. If a filename or a module is given, then all functions defined inside not starting with _ will be added as methods. The only restric...
nsim/timeseries.py
def add_analyses(cls, source): """Dynamically add new analysis methods to the Timeseries class. Args: source: Can be a function, module or the filename of a python file. If a filename or a module is given, then all functions defined inside not starting with _ will be a...
def add_analyses(cls, source): """Dynamically add new analysis methods to the Timeseries class. Args: source: Can be a function, module or the filename of a python file. If a filename or a module is given, then all functions defined inside not starting with _ will be a...
[ "Dynamically", "add", "new", "analysis", "methods", "to", "the", "Timeseries", "class", ".", "Args", ":", "source", ":", "Can", "be", "a", "function", "module", "or", "the", "filename", "of", "a", "python", "file", ".", "If", "a", "filename", "or", "a", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L119-L155
[ "def", "add_analyses", "(", "cls", ",", "source", ")", ":", "if", "isinstance", "(", "source", ",", "types", ".", "FunctionType", ")", ":", "_add_single_method", "(", "source", ".", "__name__", ",", "source", ")", "else", ":", "if", "isinstance", "(", "s...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.absolute
Calculate the absolute value element-wise. Returns: absolute (Timeseries): Absolute value. For complex input (a + b*j) gives sqrt(a**a + b**2)
nsim/timeseries.py
def absolute(self): """Calculate the absolute value element-wise. Returns: absolute (Timeseries): Absolute value. For complex input (a + b*j) gives sqrt(a**a + b**2) """ return Timeseries(np.absolute(self), self.tspan, self.labels)
def absolute(self): """Calculate the absolute value element-wise. Returns: absolute (Timeseries): Absolute value. For complex input (a + b*j) gives sqrt(a**a + b**2) """ return Timeseries(np.absolute(self), self.tspan, self.labels)
[ "Calculate", "the", "absolute", "value", "element", "-", "wise", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L448-L455
[ "def", "absolute", "(", "self", ")", ":", "return", "Timeseries", "(", "np", ".", "absolute", "(", "self", ")", ",", "self", ".", "tspan", ",", "self", ".", "labels", ")" ]
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.angle
Return the angle of the complex argument. Args: deg (bool, optional): Return angle in degrees if True, radians if False (default). Returns: angle (Timeseries): The counterclockwise angle from the positive real axis on the complex plane, with dtyp...
nsim/timeseries.py
def angle(self, deg=False): """Return the angle of the complex argument. Args: deg (bool, optional): Return angle in degrees if True, radians if False (default). Returns: angle (Timeseries): The counterclockwise angle from the positive real axis on ...
def angle(self, deg=False): """Return the angle of the complex argument. Args: deg (bool, optional): Return angle in degrees if True, radians if False (default). Returns: angle (Timeseries): The counterclockwise angle from the positive real axis on ...
[ "Return", "the", "angle", "of", "the", "complex", "argument", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L461-L476
[ "def", "angle", "(", "self", ",", "deg", "=", "False", ")", ":", "if", "self", ".", "dtype", ".", "str", "[", "1", "]", "!=", "'c'", ":", "warnings", ".", "warn", "(", "'angle() is intended for complex-valued timeseries'", ",", "RuntimeWarning", ",", "1", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.swapaxes
Interchange two axes of a Timeseries.
nsim/timeseries.py
def swapaxes(self, axis1, axis2): """Interchange two axes of a Timeseries.""" if self.ndim <=1 or axis1 == axis2: return self ar = np.asarray(self).swapaxes(axis1, axis2) if axis1 != 0 and axis2 != 0: # then axis 0 is unaffected by the swap labels = se...
def swapaxes(self, axis1, axis2): """Interchange two axes of a Timeseries.""" if self.ndim <=1 or axis1 == axis2: return self ar = np.asarray(self).swapaxes(axis1, axis2) if axis1 != 0 and axis2 != 0: # then axis 0 is unaffected by the swap labels = se...
[ "Interchange", "two", "axes", "of", "a", "Timeseries", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L487-L497
[ "def", "swapaxes", "(", "self", ",", "axis1", ",", "axis2", ")", ":", "if", "self", ".", "ndim", "<=", "1", "or", "axis1", "==", "axis2", ":", "return", "self", "ar", "=", "np", ".", "asarray", "(", "self", ")", ".", "swapaxes", "(", "axis1", ","...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.transpose
Permute the dimensions of a Timeseries.
nsim/timeseries.py
def transpose(self, *axes): """Permute the dimensions of a Timeseries.""" if self.ndim <= 1: return self ar = np.asarray(self).transpose(*axes) if axes[0] != 0: # then axis 0 is unaffected by the transposition newlabels = [self.labels[ax] for ax in axe...
def transpose(self, *axes): """Permute the dimensions of a Timeseries.""" if self.ndim <= 1: return self ar = np.asarray(self).transpose(*axes) if axes[0] != 0: # then axis 0 is unaffected by the transposition newlabels = [self.labels[ax] for ax in axe...
[ "Permute", "the", "dimensions", "of", "a", "Timeseries", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L499-L509
[ "def", "transpose", "(", "self", ",", "*", "axes", ")", ":", "if", "self", ".", "ndim", "<=", "1", ":", "return", "self", "ar", "=", "np", ".", "asarray", "(", "self", ")", ".", "transpose", "(", "*", "axes", ")", "if", "axes", "[", "0", "]", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.reshape
If axis 0 is unaffected by the reshape, then returns a Timeseries, otherwise returns an ndarray. Preserves labels of axis j only if all axes<=j are unaffected by the reshape. See ``numpy.ndarray.reshape()`` for more information
nsim/timeseries.py
def reshape(self, newshape, order='C'): """If axis 0 is unaffected by the reshape, then returns a Timeseries, otherwise returns an ndarray. Preserves labels of axis j only if all axes<=j are unaffected by the reshape. See ``numpy.ndarray.reshape()`` for more information """ ...
def reshape(self, newshape, order='C'): """If axis 0 is unaffected by the reshape, then returns a Timeseries, otherwise returns an ndarray. Preserves labels of axis j only if all axes<=j are unaffected by the reshape. See ``numpy.ndarray.reshape()`` for more information """ ...
[ "If", "axis", "0", "is", "unaffected", "by", "the", "reshape", "then", "returns", "a", "Timeseries", "otherwise", "returns", "an", "ndarray", ".", "Preserves", "labels", "of", "axis", "j", "only", "if", "all", "axes<", "=", "j", "are", "unaffected", "by", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L517-L540
[ "def", "reshape", "(", "self", ",", "newshape", ",", "order", "=", "'C'", ")", ":", "oldshape", "=", "self", ".", "shape", "ar", "=", "np", ".", "asarray", "(", "self", ")", ".", "reshape", "(", "newshape", ",", "order", "=", "order", ")", "if", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.merge
Merge another timeseries with this one Arguments: ts (Timeseries): The two timeseries being merged must have the same shape except for axis 0. Returns: Resulting merged timeseries which can have duplicate time points.
nsim/timeseries.py
def merge(self, ts): """Merge another timeseries with this one Arguments: ts (Timeseries): The two timeseries being merged must have the same shape except for axis 0. Returns: Resulting merged timeseries which can have duplicate time points. """ i...
def merge(self, ts): """Merge another timeseries with this one Arguments: ts (Timeseries): The two timeseries being merged must have the same shape except for axis 0. Returns: Resulting merged timeseries which can have duplicate time points. """ i...
[ "Merge", "another", "timeseries", "with", "this", "one", "Arguments", ":", "ts", "(", "Timeseries", ")", ":", "The", "two", "timeseries", "being", "merged", "must", "have", "the", "same", "shape", "except", "for", "axis", "0", ".", "Returns", ":", "Resulti...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L651-L662
[ "def", "merge", "(", "self", ",", "ts", ")", ":", "if", "ts", ".", "shape", "[", "1", ":", "]", "!=", "self", ".", "shape", "[", "1", ":", "]", ":", "raise", "ValueError", "(", "'Timeseries to merge must have compatible shapes'", ")", "indices", "=", "...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.expand_dims
Insert a new axis, at a given position in the array shape Args: axis (int): Position (amongst axes) where new axis is to be inserted.
nsim/timeseries.py
def expand_dims(self, axis): """Insert a new axis, at a given position in the array shape Args: axis (int): Position (amongst axes) where new axis is to be inserted. """ if axis == -1: axis = self.ndim array = np.expand_dims(self, axis) if axis == 0:...
def expand_dims(self, axis): """Insert a new axis, at a given position in the array shape Args: axis (int): Position (amongst axes) where new axis is to be inserted. """ if axis == -1: axis = self.ndim array = np.expand_dims(self, axis) if axis == 0:...
[ "Insert", "a", "new", "axis", "at", "a", "given", "position", "in", "the", "array", "shape", "Args", ":", "axis", "(", "int", ")", ":", "Position", "(", "amongst", "axes", ")", "where", "new", "axis", "is", "to", "be", "inserted", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L664-L677
[ "def", "expand_dims", "(", "self", ",", "axis", ")", ":", "if", "axis", "==", "-", "1", ":", "axis", "=", "self", ".", "ndim", "array", "=", "np", ".", "expand_dims", "(", "self", ",", "axis", ")", "if", "axis", "==", "0", ":", "# prepended an axis...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.concatenate
Join a sequence of Timeseries to this one Args: tup (sequence of Timeseries): timeseries to be joined with this one. They must have the same shape as this Timeseries, except in the dimension corresponding to `axis`. axis (int, optional): The axis along which timeseri...
nsim/timeseries.py
def concatenate(self, tup, axis=0): """Join a sequence of Timeseries to this one Args: tup (sequence of Timeseries): timeseries to be joined with this one. They must have the same shape as this Timeseries, except in the dimension corresponding to `axis`. axis...
def concatenate(self, tup, axis=0): """Join a sequence of Timeseries to this one Args: tup (sequence of Timeseries): timeseries to be joined with this one. They must have the same shape as this Timeseries, except in the dimension corresponding to `axis`. axis...
[ "Join", "a", "sequence", "of", "Timeseries", "to", "this", "one", "Args", ":", "tup", "(", "sequence", "of", "Timeseries", ")", ":", "timeseries", "to", "be", "joined", "with", "this", "one", ".", "They", "must", "have", "the", "same", "shape", "as", "...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L679-L728
[ "def", "concatenate", "(", "self", ",", "tup", ",", "axis", "=", "0", ")", ":", "if", "not", "isinstance", "(", "tup", ",", "Sequence", ")", ":", "tup", "=", "(", "tup", ",", ")", "if", "tup", "is", "(", "None", ",", ")", "or", "len", "(", "t...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Timeseries.split
Split a timeseries into multiple sub-timeseries
nsim/timeseries.py
def split(self, indices_or_sections, axis=0): """Split a timeseries into multiple sub-timeseries""" if not isinstance(indices_or_sections, numbers.Integral): raise Error('splitting by array of indices is not yet implemented') n = indices_or_sections if self.shape[axis] % n !=...
def split(self, indices_or_sections, axis=0): """Split a timeseries into multiple sub-timeseries""" if not isinstance(indices_or_sections, numbers.Integral): raise Error('splitting by array of indices is not yet implemented') n = indices_or_sections if self.shape[axis] % n !=...
[ "Split", "a", "timeseries", "into", "multiple", "sub", "-", "timeseries" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L730-L747
[ "def", "split", "(", "self", ",", "indices_or_sections", ",", "axis", "=", "0", ")", ":", "if", "not", "isinstance", "(", "indices_or_sections", ",", "numbers", ".", "Integral", ")", ":", "raise", "Error", "(", "'splitting by array of indices is not yet implemente...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
plot
Plot a distributed timeseries Args: dts (DistTimeseries) title (str, optional) points (int, optional): Limit the number of time points plotted. If specified, will downsample to use this total number of time points, and only fetch back the necessary points to the client for plott...
nsim/analysesN/plots.py
def plot(dts, title=None, points=None, show=True): """Plot a distributed timeseries Args: dts (DistTimeseries) title (str, optional) points (int, optional): Limit the number of time points plotted. If specified, will downsample to use this total number of time points, and on...
def plot(dts, title=None, points=None, show=True): """Plot a distributed timeseries Args: dts (DistTimeseries) title (str, optional) points (int, optional): Limit the number of time points plotted. If specified, will downsample to use this total number of time points, and on...
[ "Plot", "a", "distributed", "timeseries", "Args", ":", "dts", "(", "DistTimeseries", ")", "title", "(", "str", "optional", ")", "points", "(", "int", "optional", ")", ":", "Limit", "the", "number", "of", "time", "points", "plotted", ".", "If", "specified",...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/plots.py#L20-L36
[ "def", "plot", "(", "dts", ",", "title", "=", "None", ",", "points", "=", "None", ",", "show", "=", "True", ")", ":", "if", "points", "is", "not", "None", "and", "len", "(", "dts", ".", "tspan", ")", ">", "points", ":", "# then downsample (TODO: use...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
phase_histogram
Plot a polar histogram of a phase variable's probability distribution Args: dts: DistTimeseries with axis 2 ranging over separate instances of an oscillator (time series values are assumed to represent an angle) times (float or sequence of floats): The target times at which to plot the ...
nsim/analysesN/plots.py
def phase_histogram(dts, times=None, nbins=30, colormap=mpl.cm.Blues): """Plot a polar histogram of a phase variable's probability distribution Args: dts: DistTimeseries with axis 2 ranging over separate instances of an oscillator (time series values are assumed to represent an angle) times ...
def phase_histogram(dts, times=None, nbins=30, colormap=mpl.cm.Blues): """Plot a polar histogram of a phase variable's probability distribution Args: dts: DistTimeseries with axis 2 ranging over separate instances of an oscillator (time series values are assumed to represent an angle) times ...
[ "Plot", "a", "polar", "histogram", "of", "a", "phase", "variable", "s", "probability", "distribution", "Args", ":", "dts", ":", "DistTimeseries", "with", "axis", "2", "ranging", "over", "separate", "instances", "of", "an", "oscillator", "(", "time", "series", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/plots.py#L39-L81
[ "def", "phase_histogram", "(", "dts", ",", "times", "=", "None", ",", "nbins", "=", "30", ",", "colormap", "=", "mpl", ".", "cm", ".", "Blues", ")", ":", "if", "times", "is", "None", ":", "times", "=", "np", ".", "linspace", "(", "dts", ".", "tsp...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
psd
plot Welch estimate of power spectral density, using nperseg samples per segment, with noverlap samples overlap and Hamming window.
nsim/analyses1/freq.py
def psd(ts, nperseg=1500, noverlap=1200, plot=True): """plot Welch estimate of power spectral density, using nperseg samples per segment, with noverlap samples overlap and Hamming window.""" ts = ts.squeeze() if ts.ndim is 1: ts = ts.reshape((-1, 1)) fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts...
def psd(ts, nperseg=1500, noverlap=1200, plot=True): """plot Welch estimate of power spectral density, using nperseg samples per segment, with noverlap samples overlap and Hamming window.""" ts = ts.squeeze() if ts.ndim is 1: ts = ts.reshape((-1, 1)) fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts...
[ "plot", "Welch", "estimate", "of", "power", "spectral", "density", "using", "nperseg", "samples", "per", "segment", "with", "noverlap", "samples", "overlap", "and", "Hamming", "window", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L31-L53
[ "def", "psd", "(", "ts", ",", "nperseg", "=", "1500", ",", "noverlap", "=", "1200", ",", "plot", "=", "True", ")", ":", "ts", "=", "ts", ".", "squeeze", "(", ")", "if", "ts", ".", "ndim", "is", "1", ":", "ts", "=", "ts", ".", "reshape", "(", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
lowpass
forward-backward butterworth low-pass filter
nsim/analyses1/freq.py
def lowpass(ts, cutoff_hz, order=3): """forward-backward butterworth low-pass filter""" orig_ndim = ts.ndim if ts.ndim is 1: ts = ts[:, np.newaxis] channels = ts.shape[1] fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0]) nyq = 0.5 * fs cutoff = cutoff_hz/nyq b, a = signal.butte...
def lowpass(ts, cutoff_hz, order=3): """forward-backward butterworth low-pass filter""" orig_ndim = ts.ndim if ts.ndim is 1: ts = ts[:, np.newaxis] channels = ts.shape[1] fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0]) nyq = 0.5 * fs cutoff = cutoff_hz/nyq b, a = signal.butte...
[ "forward", "-", "backward", "butterworth", "low", "-", "pass", "filter" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L98-L116
[ "def", "lowpass", "(", "ts", ",", "cutoff_hz", ",", "order", "=", "3", ")", ":", "orig_ndim", "=", "ts", ".", "ndim", "if", "ts", ".", "ndim", "is", "1", ":", "ts", "=", "ts", "[", ":", ",", "np", ".", "newaxis", "]", "channels", "=", "ts", "...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
bandpass
forward-backward butterworth band-pass filter
nsim/analyses1/freq.py
def bandpass(ts, low_hz, high_hz, order=3): """forward-backward butterworth band-pass filter""" orig_ndim = ts.ndim if ts.ndim is 1: ts = ts[:, np.newaxis] channels = ts.shape[1] fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0]) nyq = 0.5 * fs low = low_hz/nyq high = high_hz/ny...
def bandpass(ts, low_hz, high_hz, order=3): """forward-backward butterworth band-pass filter""" orig_ndim = ts.ndim if ts.ndim is 1: ts = ts[:, np.newaxis] channels = ts.shape[1] fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0]) nyq = 0.5 * fs low = low_hz/nyq high = high_hz/ny...
[ "forward", "-", "backward", "butterworth", "band", "-", "pass", "filter" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L140-L159
[ "def", "bandpass", "(", "ts", ",", "low_hz", ",", "high_hz", ",", "order", "=", "3", ")", ":", "orig_ndim", "=", "ts", ".", "ndim", "if", "ts", ".", "ndim", "is", "1", ":", "ts", "=", "ts", "[", ":", ",", "np", ".", "newaxis", "]", "channels", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
notch
notch filter to remove remove a particular frequency Adapted from code by Sturla Molden
nsim/analyses1/freq.py
def notch(ts, freq_hz, bandwidth_hz=1.0): """notch filter to remove remove a particular frequency Adapted from code by Sturla Molden """ orig_ndim = ts.ndim if ts.ndim is 1: ts = ts[:, np.newaxis] channels = ts.shape[1] fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0]) nyq = 0....
def notch(ts, freq_hz, bandwidth_hz=1.0): """notch filter to remove remove a particular frequency Adapted from code by Sturla Molden """ orig_ndim = ts.ndim if ts.ndim is 1: ts = ts[:, np.newaxis] channels = ts.shape[1] fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0]) nyq = 0....
[ "notch", "filter", "to", "remove", "remove", "a", "particular", "frequency", "Adapted", "from", "code", "by", "Sturla", "Molden" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L162-L192
[ "def", "notch", "(", "ts", ",", "freq_hz", ",", "bandwidth_hz", "=", "1.0", ")", ":", "orig_ndim", "=", "ts", ".", "ndim", "if", "ts", ".", "ndim", "is", "1", ":", "ts", "=", "ts", "[", ":", ",", "np", ".", "newaxis", "]", "channels", "=", "ts"...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
hilbert
Analytic signal, using the Hilbert transform
nsim/analyses1/freq.py
def hilbert(ts): """Analytic signal, using the Hilbert transform""" output = signal.hilbert(signal.detrend(ts, axis=0), axis=0) return Timeseries(output, ts.tspan, labels=ts.labels)
def hilbert(ts): """Analytic signal, using the Hilbert transform""" output = signal.hilbert(signal.detrend(ts, axis=0), axis=0) return Timeseries(output, ts.tspan, labels=ts.labels)
[ "Analytic", "signal", "using", "the", "Hilbert", "transform" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L195-L198
[ "def", "hilbert", "(", "ts", ")", ":", "output", "=", "signal", ".", "hilbert", "(", "signal", ".", "detrend", "(", "ts", ",", "axis", "=", "0", ")", ",", "axis", "=", "0", ")", "return", "Timeseries", "(", "output", ",", "ts", ".", "tspan", ",",...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
hilbert_amplitude
Amplitude of the analytic signal, using the Hilbert transform
nsim/analyses1/freq.py
def hilbert_amplitude(ts): """Amplitude of the analytic signal, using the Hilbert transform""" output = np.abs(signal.hilbert(signal.detrend(ts, axis=0), axis=0)) return Timeseries(output, ts.tspan, labels=ts.labels)
def hilbert_amplitude(ts): """Amplitude of the analytic signal, using the Hilbert transform""" output = np.abs(signal.hilbert(signal.detrend(ts, axis=0), axis=0)) return Timeseries(output, ts.tspan, labels=ts.labels)
[ "Amplitude", "of", "the", "analytic", "signal", "using", "the", "Hilbert", "transform" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L201-L204
[ "def", "hilbert_amplitude", "(", "ts", ")", ":", "output", "=", "np", ".", "abs", "(", "signal", ".", "hilbert", "(", "signal", ".", "detrend", "(", "ts", ",", "axis", "=", "0", ")", ",", "axis", "=", "0", ")", ")", "return", "Timeseries", "(", "...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
hilbert_phase
Phase of the analytic signal, using the Hilbert transform
nsim/analyses1/freq.py
def hilbert_phase(ts): """Phase of the analytic signal, using the Hilbert transform""" output = np.angle(signal.hilbert(signal.detrend(ts, axis=0), axis=0)) return Timeseries(output, ts.tspan, labels=ts.labels)
def hilbert_phase(ts): """Phase of the analytic signal, using the Hilbert transform""" output = np.angle(signal.hilbert(signal.detrend(ts, axis=0), axis=0)) return Timeseries(output, ts.tspan, labels=ts.labels)
[ "Phase", "of", "the", "analytic", "signal", "using", "the", "Hilbert", "transform" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L207-L210
[ "def", "hilbert_phase", "(", "ts", ")", ":", "output", "=", "np", ".", "angle", "(", "signal", ".", "hilbert", "(", "signal", ".", "detrend", "(", "ts", ",", "axis", "=", "0", ")", ",", "axis", "=", "0", ")", ")", "return", "Timeseries", "(", "ou...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
cwt
Continuous wavelet transform Note the full results can use a huge amount of memory at 64-bit precision Args: ts: Timeseries of m variables, shape (n, m). Assumed constant timestep. freqs: list of frequencies (in Hz) to use for the tranform. (default is 50 frequency bins logarithmic from 1H...
nsim/analyses1/freq.py
def cwt(ts, freqs=np.logspace(0, 2), wavelet=cwtmorlet, plot=True): """Continuous wavelet transform Note the full results can use a huge amount of memory at 64-bit precision Args: ts: Timeseries of m variables, shape (n, m). Assumed constant timestep. freqs: list of frequencies (in Hz) to use f...
def cwt(ts, freqs=np.logspace(0, 2), wavelet=cwtmorlet, plot=True): """Continuous wavelet transform Note the full results can use a huge amount of memory at 64-bit precision Args: ts: Timeseries of m variables, shape (n, m). Assumed constant timestep. freqs: list of frequencies (in Hz) to use f...
[ "Continuous", "wavelet", "transform", "Note", "the", "full", "results", "can", "use", "a", "huge", "amount", "of", "memory", "at", "64", "-", "bit", "precision" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L213-L241
[ "def", "cwt", "(", "ts", ",", "freqs", "=", "np", ".", "logspace", "(", "0", ",", "2", ")", ",", "wavelet", "=", "cwtmorlet", ",", "plot", "=", "True", ")", ":", "orig_ndim", "=", "ts", ".", "ndim", "if", "ts", ".", "ndim", "is", "1", ":", "t...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
cwt_distributed
Continuous wavelet transform using distributed computation. (Currently just splits the data by channel. TODO split it further.) Note: this function requires an IPython cluster to be started first. Args: ts: Timeseries of m variables, shape (n, m). Assumed constant timestep. freqs: list of frequ...
nsim/analyses1/freq.py
def cwt_distributed(ts, freqs=np.logspace(0, 2), wavelet=cwtmorlet, plot=True): """Continuous wavelet transform using distributed computation. (Currently just splits the data by channel. TODO split it further.) Note: this function requires an IPython cluster to be started first. Args: ts: Timeser...
def cwt_distributed(ts, freqs=np.logspace(0, 2), wavelet=cwtmorlet, plot=True): """Continuous wavelet transform using distributed computation. (Currently just splits the data by channel. TODO split it further.) Note: this function requires an IPython cluster to be started first. Args: ts: Timeser...
[ "Continuous", "wavelet", "transform", "using", "distributed", "computation", ".", "(", "Currently", "just", "splits", "the", "data", "by", "channel", ".", "TODO", "split", "it", "further", ".", ")", "Note", ":", "this", "function", "requires", "an", "IPython",...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L244-L266
[ "def", "cwt_distributed", "(", "ts", ",", "freqs", "=", "np", ".", "logspace", "(", "0", ",", "2", ")", ",", "wavelet", "=", "cwtmorlet", ",", "plot", "=", "True", ")", ":", "if", "ts", ".", "ndim", "is", "1", "or", "ts", ".", "shape", "[", "1"...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
_plot_cwt
Plot time resolved power spectral density from cwt results Args: ts: the original Timeseries coefs: continuous wavelet transform coefficients as calculated by cwt() freqs: list of frequencies (in Hz) corresponding to coefs. tsize, fsize: size of the plot (time axis and frequency axis, in pi...
nsim/analyses1/freq.py
def _plot_cwt(ts, coefs, freqs, tsize=1024, fsize=512): """Plot time resolved power spectral density from cwt results Args: ts: the original Timeseries coefs: continuous wavelet transform coefficients as calculated by cwt() freqs: list of frequencies (in Hz) corresponding to coefs. tsiz...
def _plot_cwt(ts, coefs, freqs, tsize=1024, fsize=512): """Plot time resolved power spectral density from cwt results Args: ts: the original Timeseries coefs: continuous wavelet transform coefficients as calculated by cwt() freqs: list of frequencies (in Hz) corresponding to coefs. tsiz...
[ "Plot", "time", "resolved", "power", "spectral", "density", "from", "cwt", "results", "Args", ":", "ts", ":", "the", "original", "Timeseries", "coefs", ":", "continuous", "wavelet", "transform", "coefficients", "as", "calculated", "by", "cwt", "()", "freqs", "...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L269-L299
[ "def", "_plot_cwt", "(", "ts", ",", "coefs", ",", "freqs", ",", "tsize", "=", "1024", ",", "fsize", "=", "512", ")", ":", "import", "matplotlib", ".", "style", "import", "matplotlib", "as", "mpl", "mpl", ".", "style", ".", "use", "(", "'classic'", ")...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
first_return_times
For an ensemble of time series, return the set of all time intervals between successive returns to value c for all instances in the ensemble. If c is not given, the default is the mean across all times and across all time series in the ensemble. Args: dts (DistTimeseries) c (float): Option...
nsim/analysesN/misc.py
def first_return_times(dts, c=None, d=0.0): """For an ensemble of time series, return the set of all time intervals between successive returns to value c for all instances in the ensemble. If c is not given, the default is the mean across all times and across all time series in the ensemble. Args: ...
def first_return_times(dts, c=None, d=0.0): """For an ensemble of time series, return the set of all time intervals between successive returns to value c for all instances in the ensemble. If c is not given, the default is the mean across all times and across all time series in the ensemble. Args: ...
[ "For", "an", "ensemble", "of", "time", "series", "return", "the", "set", "of", "all", "time", "intervals", "between", "successive", "returns", "to", "value", "c", "for", "all", "instances", "in", "the", "ensemble", ".", "If", "c", "is", "not", "given", "...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/misc.py#L16-L40
[ "def", "first_return_times", "(", "dts", ",", "c", "=", "None", ",", "d", "=", "0.0", ")", ":", "if", "c", "is", "None", ":", "c", "=", "dts", ".", "mean", "(", ")", "vmrt", "=", "distob", ".", "vectorize", "(", "analyses1", ".", "first_return_time...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
variability_fp
Example variability function. Gives two continuous, time-resolved measures of the variability of a time series, ranging between -1 and 1. The two measures are based on variance of the centroid frequency and variance of the height of the spectral peak, respectively. (Centroid frequency meaning the ...
nsim/analysesN/epochs.py
def variability_fp(ts, freqs=None, ncycles=6, plot=True): """Example variability function. Gives two continuous, time-resolved measures of the variability of a time series, ranging between -1 and 1. The two measures are based on variance of the centroid frequency and variance of the height of the ...
def variability_fp(ts, freqs=None, ncycles=6, plot=True): """Example variability function. Gives two continuous, time-resolved measures of the variability of a time series, ranging between -1 and 1. The two measures are based on variance of the centroid frequency and variance of the height of the ...
[ "Example", "variability", "function", ".", "Gives", "two", "continuous", "time", "-", "resolved", "measures", "of", "the", "variability", "of", "a", "time", "series", "ranging", "between", "-", "1", "and", "1", ".", "The", "two", "measures", "are", "based", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/epochs.py#L29-L57
[ "def", "variability_fp", "(", "ts", ",", "freqs", "=", "None", ",", "ncycles", "=", "6", ",", "plot", "=", "True", ")", ":", "if", "ts", ".", "ndim", "<=", "2", ":", "return", "analyses1", ".", "variability_fp", "(", "ts", ",", "freqs", ",", "ncycl...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
epochs
Identify "stationary" epochs within a time series, based on a continuous measure of variability. Epochs are defined to contain the points of minimal variability, and to extend as wide as possible with variability not exceeding the threshold. Args: ts Timeseries of m variables, shape (n, m). ...
nsim/analysesN/epochs.py
def epochs(ts, variability=None, threshold=0.0, minlength=1.0, plot=True): """Identify "stationary" epochs within a time series, based on a continuous measure of variability. Epochs are defined to contain the points of minimal variability, and to extend as wide as possible with variability not exceedi...
def epochs(ts, variability=None, threshold=0.0, minlength=1.0, plot=True): """Identify "stationary" epochs within a time series, based on a continuous measure of variability. Epochs are defined to contain the points of minimal variability, and to extend as wide as possible with variability not exceedi...
[ "Identify", "stationary", "epochs", "within", "a", "time", "series", "based", "on", "a", "continuous", "measure", "of", "variability", ".", "Epochs", "are", "defined", "to", "contain", "the", "points", "of", "minimal", "variability", "and", "to", "extend", "as...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/epochs.py#L60-L88
[ "def", "epochs", "(", "ts", ",", "variability", "=", "None", ",", "threshold", "=", "0.0", ",", "minlength", "=", "1.0", ",", "plot", "=", "True", ")", ":", "if", "ts", ".", "ndim", "<=", "2", ":", "return", "analyses1", ".", "epochs_distributed", "(...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
epochs_joint
Identify epochs within a multivariate time series where at least a certain proportion of channels are "stationary", based on a previously computed variability measure. (Note: This requires an IPython cluster to be started first, e.g. on a workstation type 'ipcluster start') Args: ts Tim...
nsim/analysesN/epochs.py
def epochs_joint(ts, variability=None, threshold=0.0, minlength=1.0, proportion=0.75, plot=True): """Identify epochs within a multivariate time series where at least a certain proportion of channels are "stationary", based on a previously computed variability measure. (Note: This req...
def epochs_joint(ts, variability=None, threshold=0.0, minlength=1.0, proportion=0.75, plot=True): """Identify epochs within a multivariate time series where at least a certain proportion of channels are "stationary", based on a previously computed variability measure. (Note: This req...
[ "Identify", "epochs", "within", "a", "multivariate", "time", "series", "where", "at", "least", "a", "certain", "proportion", "of", "channels", "are", "stationary", "based", "on", "a", "previously", "computed", "variability", "measure", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/epochs.py#L128-L158
[ "def", "epochs_joint", "(", "ts", ",", "variability", "=", "None", ",", "threshold", "=", "0.0", ",", "minlength", "=", "1.0", ",", "proportion", "=", "0.75", ",", "plot", "=", "True", ")", ":", "if", "ts", ".", "ndim", "<=", "2", ":", "return", "a...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
periods
For an ensemble of oscillators, return the set of periods lengths of all successive oscillations of all oscillators. An individual oscillation is defined to start and end when the phase passes phi (by default zero) after completing a full cycle. If the timeseries of an oscillator phase begins (or en...
nsim/analysesN/phase.py
def periods(dts, phi=0.0): """For an ensemble of oscillators, return the set of periods lengths of all successive oscillations of all oscillators. An individual oscillation is defined to start and end when the phase passes phi (by default zero) after completing a full cycle. If the timeseries of...
def periods(dts, phi=0.0): """For an ensemble of oscillators, return the set of periods lengths of all successive oscillations of all oscillators. An individual oscillation is defined to start and end when the phase passes phi (by default zero) after completing a full cycle. If the timeseries of...
[ "For", "an", "ensemble", "of", "oscillators", "return", "the", "set", "of", "periods", "lengths", "of", "all", "successive", "oscillations", "of", "all", "oscillators", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/phase.py#L16-L39
[ "def", "periods", "(", "dts", ",", "phi", "=", "0.0", ")", ":", "vperiods", "=", "distob", ".", "vectorize", "(", "analyses1", ".", "periods", ")", "all_periods", "=", "vperiods", "(", "dts", ",", "phi", ")", "if", "hasattr", "(", "type", "(", "all_p...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
circmean
Circular mean phase
nsim/analysesN/phase.py
def circmean(dts, axis=2): """Circular mean phase""" return np.exp(1.0j * dts).mean(axis=axis).angle()
def circmean(dts, axis=2): """Circular mean phase""" return np.exp(1.0j * dts).mean(axis=axis).angle()
[ "Circular", "mean", "phase" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/phase.py#L42-L44
[ "def", "circmean", "(", "dts", ",", "axis", "=", "2", ")", ":", "return", "np", ".", "exp", "(", "1.0j", "*", "dts", ")", ".", "mean", "(", "axis", "=", "axis", ")", ".", "angle", "(", ")" ]
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
order_param
Order parameter of phase synchronization
nsim/analysesN/phase.py
def order_param(dts, axis=2): """Order parameter of phase synchronization""" return np.abs(np.exp(1.0j * dts).mean(axis=axis))
def order_param(dts, axis=2): """Order parameter of phase synchronization""" return np.abs(np.exp(1.0j * dts).mean(axis=axis))
[ "Order", "parameter", "of", "phase", "synchronization" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/phase.py#L47-L49
[ "def", "order_param", "(", "dts", ",", "axis", "=", "2", ")", ":", "return", "np", ".", "abs", "(", "np", ".", "exp", "(", "1.0j", "*", "dts", ")", ".", "mean", "(", "axis", "=", "axis", ")", ")" ]
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
circstd
Circular standard deviation
nsim/analysesN/phase.py
def circstd(dts, axis=2): """Circular standard deviation""" R = np.abs(np.exp(1.0j * dts).mean(axis=axis)) return np.sqrt(-2.0 * np.log(R))
def circstd(dts, axis=2): """Circular standard deviation""" R = np.abs(np.exp(1.0j * dts).mean(axis=axis)) return np.sqrt(-2.0 * np.log(R))
[ "Circular", "standard", "deviation" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/phase.py#L52-L55
[ "def", "circstd", "(", "dts", ",", "axis", "=", "2", ")", ":", "R", "=", "np", ".", "abs", "(", "np", ".", "exp", "(", "1.0j", "*", "dts", ")", ".", "mean", "(", "axis", "=", "axis", ")", ")", "return", "np", ".", "sqrt", "(", "-", "2.0", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
JansenRit.f
Aburn2012 equations right hand side, noise free term Args: v: (8,) array state vector t: number scalar time Returns: (8,) array
nsim/models/neural_mass.py
def f(self, v, t): """Aburn2012 equations right hand side, noise free term Args: v: (8,) array state vector t: number scalar time Returns: (8,) array """ ret = np.zeros(8) ret[0] = v[4] ret[4] = (self.He1*s...
def f(self, v, t): """Aburn2012 equations right hand side, noise free term Args: v: (8,) array state vector t: number scalar time Returns: (8,) array """ ret = np.zeros(8) ret[0] = v[4] ret[4] = (self.He1*s...
[ "Aburn2012", "equations", "right", "hand", "side", "noise", "free", "term", "Args", ":", "v", ":", "(", "8", ")", "array", "state", "vector", "t", ":", "number", "scalar", "time", "Returns", ":", "(", "8", ")", "array" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/models/neural_mass.py#L79-L105
[ "def", "f", "(", "self", ",", "v", ",", "t", ")", ":", "ret", "=", "np", ".", "zeros", "(", "8", ")", "ret", "[", "0", "]", "=", "v", "[", "4", "]", "ret", "[", "4", "]", "=", "(", "self", ".", "He1", "*", "self", ".", "ke1", "*", "("...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
JansenRit.G
Aburn2012 equations right hand side, noise term Args: v: (8,) array state vector t: number scalar time Returns: (8,1) array Only one matrix column, meaning that in this example we are modelling the noise input to pyramidal and...
nsim/models/neural_mass.py
def G(self, v, t): """Aburn2012 equations right hand side, noise term Args: v: (8,) array state vector t: number scalar time Returns: (8,1) array Only one matrix column, meaning that in this example we are modelling th...
def G(self, v, t): """Aburn2012 equations right hand side, noise term Args: v: (8,) array state vector t: number scalar time Returns: (8,1) array Only one matrix column, meaning that in this example we are modelling th...
[ "Aburn2012", "equations", "right", "hand", "side", "noise", "term", "Args", ":", "v", ":", "(", "8", ")", "array", "state", "vector", "t", ":", "number", "scalar", "time", "Returns", ":", "(", "8", "1", ")", "array", "Only", "one", "matrix", "column", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/models/neural_mass.py#L107-L124
[ "def", "G", "(", "self", ",", "v", ",", "t", ")", ":", "ret", "=", "np", ".", "zeros", "(", "(", "8", ",", "1", ")", ")", "ret", "[", "4", ",", "0", "]", "=", "self", ".", "ke1", "*", "self", ".", "He1", "*", "self", ".", "u_sdev", "ret...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
JansenRit.coupling
How to couple the output of one node to the input of another. Args: source_y (array of shape (8,)): state of the source node target_y (array of shape (8,)): state of the target node weight (float): the connection strength Returns: input (array of shape (8,)): valu...
nsim/models/neural_mass.py
def coupling(self, source_y, target_y, weight): """How to couple the output of one node to the input of another. Args: source_y (array of shape (8,)): state of the source node target_y (array of shape (8,)): state of the target node weight (float): the connection strength ...
def coupling(self, source_y, target_y, weight): """How to couple the output of one node to the input of another. Args: source_y (array of shape (8,)): state of the source node target_y (array of shape (8,)): state of the target node weight (float): the connection strength ...
[ "How", "to", "couple", "the", "output", "of", "one", "node", "to", "the", "input", "of", "another", ".", "Args", ":", "source_y", "(", "array", "of", "shape", "(", "8", "))", ":", "state", "of", "the", "source", "node", "target_y", "(", "array", "of"...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/models/neural_mass.py#L126-L138
[ "def", "coupling", "(", "self", ",", "source_y", ",", "target_y", ",", "weight", ")", ":", "v_pyramidal", "=", "source_y", "[", "1", "]", "-", "source_y", "[", "2", "]", "return", "(", "np", ".", "array", "(", "[", "0", ",", "0", ",", "0", ",", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
hurst
Compute the Hurst exponent of X. If the output H=0.5,the behavior of the time-series is similar to random walk. If H<0.5, the time-series cover less "distance" than a random walk, vice verse. Parameters ---------- X list a time series Returns ------- H float...
nsim/analyses1/pyeeg.py
def hurst(X): """ Compute the Hurst exponent of X. If the output H=0.5,the behavior of the time-series is similar to random walk. If H<0.5, the time-series cover less "distance" than a random walk, vice verse. Parameters ---------- X list a time series Returns ------...
def hurst(X): """ Compute the Hurst exponent of X. If the output H=0.5,the behavior of the time-series is similar to random walk. If H<0.5, the time-series cover less "distance" than a random walk, vice verse. Parameters ---------- X list a time series Returns ------...
[ "Compute", "the", "Hurst", "exponent", "of", "X", ".", "If", "the", "output", "H", "=", "0", ".", "5", "the", "behavior", "of", "the", "time", "-", "series", "is", "similar", "to", "random", "walk", ".", "If", "H<0", ".", "5", "the", "time", "-", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L40-L96
[ "def", "hurst", "(", "X", ")", ":", "X", "=", "numpy", ".", "array", "(", "X", ")", "N", "=", "X", ".", "size", "T", "=", "numpy", ".", "arange", "(", "1", ",", "N", "+", "1", ")", "Y", "=", "numpy", ".", "cumsum", "(", "X", ")", "Ave_T",...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
embed_seq
Build a set of embedding sequences from given time series X with lag Tau and embedding dimension DE. Let X = [x(1), x(2), ... , x(N)], then for each i such that 1 < i < N - (D - 1) * Tau, we build an embedding sequence, Y(i) = [x(i), x(i + Tau), ... , x(i + (D - 1) * Tau)]. All embedding sequence are p...
nsim/analyses1/pyeeg.py
def embed_seq(X, Tau, D): """Build a set of embedding sequences from given time series X with lag Tau and embedding dimension DE. Let X = [x(1), x(2), ... , x(N)], then for each i such that 1 < i < N - (D - 1) * Tau, we build an embedding sequence, Y(i) = [x(i), x(i + Tau), ... , x(i + (D - 1) * Tau)]....
def embed_seq(X, Tau, D): """Build a set of embedding sequences from given time series X with lag Tau and embedding dimension DE. Let X = [x(1), x(2), ... , x(N)], then for each i such that 1 < i < N - (D - 1) * Tau, we build an embedding sequence, Y(i) = [x(i), x(i + Tau), ... , x(i + (D - 1) * Tau)]....
[ "Build", "a", "set", "of", "embedding", "sequences", "from", "given", "time", "series", "X", "with", "lag", "Tau", "and", "embedding", "dimension", "DE", ".", "Let", "X", "=", "[", "x", "(", "1", ")", "x", "(", "2", ")", "...", "x", "(", "N", ")"...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L99-L163
[ "def", "embed_seq", "(", "X", ",", "Tau", ",", "D", ")", ":", "shape", "=", "(", "X", ".", "size", "-", "Tau", "*", "(", "D", "-", "1", ")", ",", "D", ")", "strides", "=", "(", "X", ".", "itemsize", ",", "Tau", "*", "X", ".", "itemsize", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
bin_power
Compute power in each frequency bin specified by Band from FFT result of X. By default, X is a real signal. Note ----- A real signal can be synthesized, thus not real. Parameters ----------- Band list boundary frequencies (in Hz) of bins. They can be unequal bins, e.g. ...
nsim/analyses1/pyeeg.py
def bin_power(X, Band, Fs): """Compute power in each frequency bin specified by Band from FFT result of X. By default, X is a real signal. Note ----- A real signal can be synthesized, thus not real. Parameters ----------- Band list boundary frequencies (in Hz) of bins...
def bin_power(X, Band, Fs): """Compute power in each frequency bin specified by Band from FFT result of X. By default, X is a real signal. Note ----- A real signal can be synthesized, thus not real. Parameters ----------- Band list boundary frequencies (in Hz) of bins...
[ "Compute", "power", "in", "each", "frequency", "bin", "specified", "by", "Band", "from", "FFT", "result", "of", "X", ".", "By", "default", "X", "is", "a", "real", "signal", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L166-L226
[ "def", "bin_power", "(", "X", ",", "Band", ",", "Fs", ")", ":", "C", "=", "numpy", ".", "fft", ".", "fft", "(", "X", ")", "C", "=", "abs", "(", "C", ")", "Power", "=", "numpy", ".", "zeros", "(", "len", "(", "Band", ")", "-", "1", ")", "f...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
pfd
Compute Petrosian Fractal Dimension of a time series from either two cases below: 1. X, the time series of type list (default) 2. D, the first order differential sequence of X (if D is provided, recommended to speed up) In case 1, D is computed using Numpy's difference function. ...
nsim/analyses1/pyeeg.py
def pfd(X, D=None): """Compute Petrosian Fractal Dimension of a time series from either two cases below: 1. X, the time series of type list (default) 2. D, the first order differential sequence of X (if D is provided, recommended to speed up) In case 1, D is computed using Numpy'...
def pfd(X, D=None): """Compute Petrosian Fractal Dimension of a time series from either two cases below: 1. X, the time series of type list (default) 2. D, the first order differential sequence of X (if D is provided, recommended to speed up) In case 1, D is computed using Numpy'...
[ "Compute", "Petrosian", "Fractal", "Dimension", "of", "a", "time", "series", "from", "either", "two", "cases", "below", ":", "1", ".", "X", "the", "time", "series", "of", "type", "list", "(", "default", ")", "2", ".", "D", "the", "first", "order", "dif...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L229-L252
[ "def", "pfd", "(", "X", ",", "D", "=", "None", ")", ":", "if", "D", "is", "None", ":", "D", "=", "numpy", ".", "diff", "(", "X", ")", "D", "=", "D", ".", "tolist", "(", ")", "N_delta", "=", "0", "# number of sign changes in derivative of the signal",...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
hfd
Compute Hjorth Fractal Dimension of a time series X, kmax is an HFD parameter
nsim/analyses1/pyeeg.py
def hfd(X, Kmax): """ Compute Hjorth Fractal Dimension of a time series X, kmax is an HFD parameter """ L = [] x = [] N = len(X) for k in range(1, Kmax): Lk = [] for m in range(0, k): Lmk = 0 for i in range(1, int(numpy.floor((N - m) / k))): ...
def hfd(X, Kmax): """ Compute Hjorth Fractal Dimension of a time series X, kmax is an HFD parameter """ L = [] x = [] N = len(X) for k in range(1, Kmax): Lk = [] for m in range(0, k): Lmk = 0 for i in range(1, int(numpy.floor((N - m) / k))): ...
[ "Compute", "Hjorth", "Fractal", "Dimension", "of", "a", "time", "series", "X", "kmax", "is", "an", "HFD", "parameter" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L255-L274
[ "def", "hfd", "(", "X", ",", "Kmax", ")", ":", "L", "=", "[", "]", "x", "=", "[", "]", "N", "=", "len", "(", "X", ")", "for", "k", "in", "range", "(", "1", ",", "Kmax", ")", ":", "Lk", "=", "[", "]", "for", "m", "in", "range", "(", "0...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
hjorth
Compute Hjorth mobility and complexity of a time series from either two cases below: 1. X, the time series of type list (default) 2. D, a first order differential sequence of X (if D is provided, recommended to speed up) In case 1, D is computed using Numpy's Difference function. ...
nsim/analyses1/pyeeg.py
def hjorth(X, D=None): """ Compute Hjorth mobility and complexity of a time series from either two cases below: 1. X, the time series of type list (default) 2. D, a first order differential sequence of X (if D is provided, recommended to speed up) In case 1, D is computed using N...
def hjorth(X, D=None): """ Compute Hjorth mobility and complexity of a time series from either two cases below: 1. X, the time series of type list (default) 2. D, a first order differential sequence of X (if D is provided, recommended to speed up) In case 1, D is computed using N...
[ "Compute", "Hjorth", "mobility", "and", "complexity", "of", "a", "time", "series", "from", "either", "two", "cases", "below", ":", "1", ".", "X", "the", "time", "series", "of", "type", "list", "(", "default", ")", "2", ".", "D", "a", "first", "order", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L277-L332
[ "def", "hjorth", "(", "X", ",", "D", "=", "None", ")", ":", "if", "D", "is", "None", ":", "D", "=", "numpy", ".", "diff", "(", "X", ")", "D", "=", "D", ".", "tolist", "(", ")", "D", ".", "insert", "(", "0", ",", "X", "[", "0", "]", ")",...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
spectral_entropy
Compute spectral entropy of a time series from either two cases below: 1. X, the time series (default) 2. Power_Ratio, a list of normalized signal power in a set of frequency bins defined in Band (if Power_Ratio is provided, recommended to speed up) In case 1, Power_Ratio is computed by bin_power() fun...
nsim/analyses1/pyeeg.py
def spectral_entropy(X, Band, Fs, Power_Ratio=None): """Compute spectral entropy of a time series from either two cases below: 1. X, the time series (default) 2. Power_Ratio, a list of normalized signal power in a set of frequency bins defined in Band (if Power_Ratio is provided, recommended to speed up...
def spectral_entropy(X, Band, Fs, Power_Ratio=None): """Compute spectral entropy of a time series from either two cases below: 1. X, the time series (default) 2. Power_Ratio, a list of normalized signal power in a set of frequency bins defined in Band (if Power_Ratio is provided, recommended to speed up...
[ "Compute", "spectral", "entropy", "of", "a", "time", "series", "from", "either", "two", "cases", "below", ":", "1", ".", "X", "the", "time", "series", "(", "default", ")", "2", ".", "Power_Ratio", "a", "list", "of", "normalized", "signal", "power", "in",...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L335-L393
[ "def", "spectral_entropy", "(", "X", ",", "Band", ",", "Fs", ",", "Power_Ratio", "=", "None", ")", ":", "if", "Power_Ratio", "is", "None", ":", "Power", ",", "Power_Ratio", "=", "bin_power", "(", "X", ",", "Band", ",", "Fs", ")", "Spectral_Entropy", "=...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
svd_entropy
Compute SVD Entropy from either two cases below: 1. a time series X, with lag tau and embedding dimension dE (default) 2. a list, W, of normalized singular values of a matrix (if W is provided, recommend to speed up.) If W is None, the function will do as follows to prepare singular spectrum: ...
nsim/analyses1/pyeeg.py
def svd_entropy(X, Tau, DE, W=None): """Compute SVD Entropy from either two cases below: 1. a time series X, with lag tau and embedding dimension dE (default) 2. a list, W, of normalized singular values of a matrix (if W is provided, recommend to speed up.) If W is None, the function will do as fol...
def svd_entropy(X, Tau, DE, W=None): """Compute SVD Entropy from either two cases below: 1. a time series X, with lag tau and embedding dimension dE (default) 2. a list, W, of normalized singular values of a matrix (if W is provided, recommend to speed up.) If W is None, the function will do as fol...
[ "Compute", "SVD", "Entropy", "from", "either", "two", "cases", "below", ":", "1", ".", "a", "time", "series", "X", "with", "lag", "tau", "and", "embedding", "dimension", "dE", "(", "default", ")", "2", ".", "a", "list", "W", "of", "normalized", "singul...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L396-L428
[ "def", "svd_entropy", "(", "X", ",", "Tau", ",", "DE", ",", "W", "=", "None", ")", ":", "if", "W", "is", "None", ":", "Y", "=", "embed_seq", "(", "X", ",", "Tau", ",", "DE", ")", "W", "=", "numpy", ".", "linalg", ".", "svd", "(", "Y", ",", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
ap_entropy
Computer approximate entropy (ApEN) of series X, specified by M and R. Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of Em is x(i),x(i+1), ... , x(i+M-1). Hence, the embedding lag and dimension are 1 and ...
nsim/analyses1/pyeeg.py
def ap_entropy(X, M, R): """Computer approximate entropy (ApEN) of series X, specified by M and R. Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of Em is x(i),x(i+1), ... , x(i+M-1). Hence, the embedding ...
def ap_entropy(X, M, R): """Computer approximate entropy (ApEN) of series X, specified by M and R. Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of Em is x(i),x(i+1), ... , x(i+M-1). Hence, the embedding ...
[ "Computer", "approximate", "entropy", "(", "ApEN", ")", "of", "series", "X", "specified", "by", "M", "and", "R", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L466-L536
[ "def", "ap_entropy", "(", "X", ",", "M", ",", "R", ")", ":", "N", "=", "len", "(", "X", ")", "Em", "=", "embed_seq", "(", "X", ",", "1", ",", "M", ")", "A", "=", "numpy", ".", "tile", "(", "Em", ",", "(", "len", "(", "Em", ")", ",", "1"...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
samp_entropy
Computer sample entropy (SampEn) of series X, specified by M and R. SampEn is very close to ApEn. Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of Em is x(i),x(i+1), ... , x(i+M-1). Hence, the embedding ...
nsim/analyses1/pyeeg.py
def samp_entropy(X, M, R): """Computer sample entropy (SampEn) of series X, specified by M and R. SampEn is very close to ApEn. Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of Em is x(i),x(i+1), ......
def samp_entropy(X, M, R): """Computer sample entropy (SampEn) of series X, specified by M and R. SampEn is very close to ApEn. Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of Em is x(i),x(i+1), ......
[ "Computer", "sample", "entropy", "(", "SampEn", ")", "of", "series", "X", "specified", "by", "M", "and", "R", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L539-L603
[ "def", "samp_entropy", "(", "X", ",", "M", ",", "R", ")", ":", "N", "=", "len", "(", "X", ")", "Em", "=", "embed_seq", "(", "X", ",", "1", ",", "M", ")", "A", "=", "numpy", ".", "tile", "(", "Em", ",", "(", "len", "(", "Em", ")", ",", "...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
dfa
Compute Detrended Fluctuation Analysis from a time series X and length of boxes L. The first step to compute DFA is to integrate the signal. Let original series be X= [x(1), x(2), ..., x(N)]. The integrated signal Y = [y(1), y(2), ..., y(N)] is obtained as follows y(k) = \sum_{i=1}^{k}{x(i)-Ave} w...
nsim/analyses1/pyeeg.py
def dfa(X, Ave=None, L=None): """Compute Detrended Fluctuation Analysis from a time series X and length of boxes L. The first step to compute DFA is to integrate the signal. Let original series be X= [x(1), x(2), ..., x(N)]. The integrated signal Y = [y(1), y(2), ..., y(N)] is obtained as follows ...
def dfa(X, Ave=None, L=None): """Compute Detrended Fluctuation Analysis from a time series X and length of boxes L. The first step to compute DFA is to integrate the signal. Let original series be X= [x(1), x(2), ..., x(N)]. The integrated signal Y = [y(1), y(2), ..., y(N)] is obtained as follows ...
[ "Compute", "Detrended", "Fluctuation", "Analysis", "from", "a", "time", "series", "X", "and", "length", "of", "boxes", "L", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L606-L733
[ "def", "dfa", "(", "X", ",", "Ave", "=", "None", ",", "L", "=", "None", ")", ":", "X", "=", "numpy", ".", "array", "(", "X", ")", "if", "Ave", "is", "None", ":", "Ave", "=", "numpy", ".", "mean", "(", "X", ")", "Y", "=", "numpy", ".", "cu...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
permutation_entropy
Compute Permutation Entropy of a given time series x, specified by permutation order n and embedding lag tau. Parameters ---------- x list a time series n integer Permutation order tau integer Embedding lag Returns ---------- P...
nsim/analyses1/pyeeg.py
def permutation_entropy(x, n, tau): """Compute Permutation Entropy of a given time series x, specified by permutation order n and embedding lag tau. Parameters ---------- x list a time series n integer Permutation order tau integer Embed...
def permutation_entropy(x, n, tau): """Compute Permutation Entropy of a given time series x, specified by permutation order n and embedding lag tau. Parameters ---------- x list a time series n integer Permutation order tau integer Embed...
[ "Compute", "Permutation", "Entropy", "of", "a", "given", "time", "series", "x", "specified", "by", "permutation", "order", "n", "and", "embedding", "lag", "tau", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L736-L834
[ "def", "permutation_entropy", "(", "x", ",", "n", ",", "tau", ")", ":", "PeSeq", "=", "[", "]", "Em", "=", "embed_seq", "(", "x", ",", "tau", ",", "n", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "Em", ")", ")", ":", "r", "="...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
information_based_similarity
Calculates the information based similarity of two time series x and y. Parameters ---------- x list a time series y list a time series n integer word order Returns ---------- IBS float Information based si...
nsim/analyses1/pyeeg.py
def information_based_similarity(x, y, n): """Calculates the information based similarity of two time series x and y. Parameters ---------- x list a time series y list a time series n integer word order Returns ---------- ...
def information_based_similarity(x, y, n): """Calculates the information based similarity of two time series x and y. Parameters ---------- x list a time series y list a time series n integer word order Returns ---------- ...
[ "Calculates", "the", "information", "based", "similarity", "of", "two", "time", "series", "x", "and", "y", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L837-L1004
[ "def", "information_based_similarity", "(", "x", ",", "y", ",", "n", ")", ":", "Wordlist", "=", "[", "]", "Space", "=", "[", "[", "0", ",", "0", "]", ",", "[", "0", ",", "1", "]", ",", "[", "1", ",", "0", "]", ",", "[", "1", ",", "1", "]"...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
LLE
Calculate largest Lyauponov exponent of a given time series x using Rosenstein algorithm. Parameters ---------- x list a time series n integer embedding dimension tau integer Embedding lag fs integer Sampling frequency ...
nsim/analyses1/pyeeg.py
def LLE(x, tau, n, T, fs): """Calculate largest Lyauponov exponent of a given time series x using Rosenstein algorithm. Parameters ---------- x list a time series n integer embedding dimension tau integer Embedding lag fs in...
def LLE(x, tau, n, T, fs): """Calculate largest Lyauponov exponent of a given time series x using Rosenstein algorithm. Parameters ---------- x list a time series n integer embedding dimension tau integer Embedding lag fs in...
[ "Calculate", "largest", "Lyauponov", "exponent", "of", "a", "given", "time", "series", "x", "using", "Rosenstein", "algorithm", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L1007-L1112
[ "def", "LLE", "(", "x", ",", "tau", ",", "n", ",", "T", ",", "fs", ")", ":", "Em", "=", "embed_seq", "(", "x", ",", "tau", ",", "n", ")", "M", "=", "len", "(", "Em", ")", "A", "=", "numpy", ".", "tile", "(", "Em", ",", "(", "len", "(", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
mod2pi
For a timeseries where all variables represent phases (in radians), return an equivalent timeseries where all values are in the range (-pi, pi]
nsim/analyses1/phase.py
def mod2pi(ts): """For a timeseries where all variables represent phases (in radians), return an equivalent timeseries where all values are in the range (-pi, pi] """ return np.pi - np.mod(np.pi - ts, 2*np.pi)
def mod2pi(ts): """For a timeseries where all variables represent phases (in radians), return an equivalent timeseries where all values are in the range (-pi, pi] """ return np.pi - np.mod(np.pi - ts, 2*np.pi)
[ "For", "a", "timeseries", "where", "all", "variables", "represent", "phases", "(", "in", "radians", ")", "return", "an", "equivalent", "timeseries", "where", "all", "values", "are", "in", "the", "range", "(", "-", "pi", "pi", "]" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/phase.py#L17-L21
[ "def", "mod2pi", "(", "ts", ")", ":", "return", "np", ".", "pi", "-", "np", ".", "mod", "(", "np", ".", "pi", "-", "ts", ",", "2", "*", "np", ".", "pi", ")" ]
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
phase_crossings
For a single variable timeseries representing the phase of an oscillator, find the times at which the phase crosses angle phi, with the condition that the phase must visit phi+pi between crossings. (Thus if noise causes the phase to wander back and forth across angle phi without the oscillator doing a...
nsim/analyses1/phase.py
def phase_crossings(ts, phi=0.0): """For a single variable timeseries representing the phase of an oscillator, find the times at which the phase crosses angle phi, with the condition that the phase must visit phi+pi between crossings. (Thus if noise causes the phase to wander back and forth across angl...
def phase_crossings(ts, phi=0.0): """For a single variable timeseries representing the phase of an oscillator, find the times at which the phase crosses angle phi, with the condition that the phase must visit phi+pi between crossings. (Thus if noise causes the phase to wander back and forth across angl...
[ "For", "a", "single", "variable", "timeseries", "representing", "the", "phase", "of", "an", "oscillator", "find", "the", "times", "at", "which", "the", "phase", "crosses", "angle", "phi", "with", "the", "condition", "that", "the", "phase", "must", "visit", "...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/phase.py#L24-L82
[ "def", "phase_crossings", "(", "ts", ",", "phi", "=", "0.0", ")", ":", "#TODO support multivariate time series", "ts", "=", "ts", ".", "squeeze", "(", ")", "if", "ts", ".", "ndim", "is", "not", "1", ":", "raise", "ValueError", "(", "'Currently can only use o...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
periods
For a single variable timeseries representing the phase of an oscillator, measure the period of each successive oscillation. An individual oscillation is defined to start and end when the phase passes phi (by default zero) after completing a full cycle. If the timeseries begins (or ends) exactly at p...
nsim/analyses1/phase.py
def periods(ts, phi=0.0): """For a single variable timeseries representing the phase of an oscillator, measure the period of each successive oscillation. An individual oscillation is defined to start and end when the phase passes phi (by default zero) after completing a full cycle. If the timeser...
def periods(ts, phi=0.0): """For a single variable timeseries representing the phase of an oscillator, measure the period of each successive oscillation. An individual oscillation is defined to start and end when the phase passes phi (by default zero) after completing a full cycle. If the timeser...
[ "For", "a", "single", "variable", "timeseries", "representing", "the", "phase", "of", "an", "oscillator", "measure", "the", "period", "of", "each", "successive", "oscillation", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/phase.py#L85-L106
[ "def", "periods", "(", "ts", ",", "phi", "=", "0.0", ")", ":", "ts", "=", "np", ".", "squeeze", "(", "ts", ")", "if", "ts", ".", "ndim", "<=", "1", ":", "return", "np", ".", "diff", "(", "phase_crossings", "(", "ts", ",", "phi", ")", ")", "el...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
circmean
Circular mean phase
nsim/analyses1/phase.py
def circmean(ts, axis=2): """Circular mean phase""" return np.exp(1.0j * ts).mean(axis=axis).angle()
def circmean(ts, axis=2): """Circular mean phase""" return np.exp(1.0j * ts).mean(axis=axis).angle()
[ "Circular", "mean", "phase" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/phase.py#L109-L111
[ "def", "circmean", "(", "ts", ",", "axis", "=", "2", ")", ":", "return", "np", ".", "exp", "(", "1.0j", "*", "ts", ")", ".", "mean", "(", "axis", "=", "axis", ")", ".", "angle", "(", ")" ]
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
order_param
Order parameter of phase synchronization
nsim/analyses1/phase.py
def order_param(ts, axis=2): """Order parameter of phase synchronization""" return np.abs(np.exp(1.0j * ts).mean(axis=axis))
def order_param(ts, axis=2): """Order parameter of phase synchronization""" return np.abs(np.exp(1.0j * ts).mean(axis=axis))
[ "Order", "parameter", "of", "phase", "synchronization" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/phase.py#L114-L116
[ "def", "order_param", "(", "ts", ",", "axis", "=", "2", ")", ":", "return", "np", ".", "abs", "(", "np", ".", "exp", "(", "1.0j", "*", "ts", ")", ".", "mean", "(", "axis", "=", "axis", ")", ")" ]
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
cwtmorlet
complex morlet wavelet function compatible with scipy.signal.cwt Parameters: points: int Number of points in `vector`. width: scalar Width parameter of wavelet. Equals (sample rate / fundamental frequency of wavelet) Returns: `vector`: ...
nsim/analyses1/_cwtmorlet.py
def cwtmorlet(points, width): """complex morlet wavelet function compatible with scipy.signal.cwt Parameters: points: int Number of points in `vector`. width: scalar Width parameter of wavelet. Equals (sample rate / fundamental frequenc...
def cwtmorlet(points, width): """complex morlet wavelet function compatible with scipy.signal.cwt Parameters: points: int Number of points in `vector`. width: scalar Width parameter of wavelet. Equals (sample rate / fundamental frequenc...
[ "complex", "morlet", "wavelet", "function", "compatible", "with", "scipy", ".", "signal", ".", "cwt", "Parameters", ":", "points", ":", "int", "Number", "of", "points", "in", "vector", ".", "width", ":", "scalar", "Width", "parameter", "of", "wavelet", ".", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/_cwtmorlet.py#L5-L16
[ "def", "cwtmorlet", "(", "points", ",", "width", ")", ":", "omega", "=", "5.0", "s", "=", "points", "/", "(", "2.0", "*", "omega", "*", "width", ")", "return", "wavelets", ".", "morlet", "(", "points", ",", "omega", ",", "s", ",", "complete", "=", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
roughcwt
Continuous wavelet transform. Performs a continuous wavelet transform on `data`, using the `wavelet` function. A CWT performs a convolution with `data` using the `wavelet` function, which is characterized by a width parameter and length parameter. Parameters ---------- data : (N,) ndarray ...
nsim/analyses1/_cwtmorlet.py
def roughcwt(data, wavelet, widths): """ Continuous wavelet transform. Performs a continuous wavelet transform on `data`, using the `wavelet` function. A CWT performs a convolution with `data` using the `wavelet` function, which is characterized by a width parameter and length parameter. P...
def roughcwt(data, wavelet, widths): """ Continuous wavelet transform. Performs a continuous wavelet transform on `data`, using the `wavelet` function. A CWT performs a convolution with `data` using the `wavelet` function, which is characterized by a width parameter and length parameter. P...
[ "Continuous", "wavelet", "transform", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/_cwtmorlet.py#L20-L69
[ "def", "roughcwt", "(", "data", ",", "wavelet", ",", "widths", ")", ":", "out_dtype", "=", "wavelet", "(", "widths", "[", "0", "]", ",", "widths", "[", "0", "]", ")", ".", "dtype", "output", "=", "np", ".", "zeros", "(", "[", "len", "(", "widths"...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
variability_fp
Example variability function. Gives two continuous, time-resolved measures of the variability of a time series, ranging between -1 and 1. The two measures are based on variance of the centroid frequency and variance of the height of the spectral peak, respectively. (Centroid frequency meaning the ...
nsim/analyses1/epochs.py
def variability_fp(ts, freqs=None, ncycles=6, plot=True): """Example variability function. Gives two continuous, time-resolved measures of the variability of a time series, ranging between -1 and 1. The two measures are based on variance of the centroid frequency and variance of the height of the ...
def variability_fp(ts, freqs=None, ncycles=6, plot=True): """Example variability function. Gives two continuous, time-resolved measures of the variability of a time series, ranging between -1 and 1. The two measures are based on variance of the centroid frequency and variance of the height of the ...
[ "Example", "variability", "function", ".", "Gives", "two", "continuous", "time", "-", "resolved", "measures", "of", "the", "variability", "of", "a", "time", "series", "ranging", "between", "-", "1", "and", "1", ".", "The", "two", "measures", "are", "based", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/epochs.py#L31-L102
[ "def", "variability_fp", "(", "ts", ",", "freqs", "=", "None", ",", "ncycles", "=", "6", ",", "plot", "=", "True", ")", ":", "if", "freqs", "is", "None", ":", "freqs", "=", "np", ".", "logspace", "(", "np", ".", "log10", "(", "1.0", ")", ",", "...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
_rescale
Shift and rescale array ar to the interval [-1, 1]
nsim/analyses1/epochs.py
def _rescale(ar): """Shift and rescale array ar to the interval [-1, 1]""" max = np.nanmax(ar) min = np.nanmin(ar) midpoint = (max + min) / 2.0 return 2.0 * (ar - midpoint) / (max - min)
def _rescale(ar): """Shift and rescale array ar to the interval [-1, 1]""" max = np.nanmax(ar) min = np.nanmin(ar) midpoint = (max + min) / 2.0 return 2.0 * (ar - midpoint) / (max - min)
[ "Shift", "and", "rescale", "array", "ar", "to", "the", "interval", "[", "-", "1", "1", "]" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/epochs.py#L105-L110
[ "def", "_rescale", "(", "ar", ")", ":", "max", "=", "np", ".", "nanmax", "(", "ar", ")", "min", "=", "np", ".", "nanmin", "(", "ar", ")", "midpoint", "=", "(", "max", "+", "min", ")", "/", "2.0", "return", "2.0", "*", "(", "ar", "-", "midpoin...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
_get_color_list
Get cycle of colors in a way compatible with all matplotlib versions
nsim/analyses1/epochs.py
def _get_color_list(): """Get cycle of colors in a way compatible with all matplotlib versions""" if 'axes.prop_cycle' in plt.rcParams: return [p['color'] for p in list(plt.rcParams['axes.prop_cycle'])] else: return plt.rcParams['axes.color_cycle']
def _get_color_list(): """Get cycle of colors in a way compatible with all matplotlib versions""" if 'axes.prop_cycle' in plt.rcParams: return [p['color'] for p in list(plt.rcParams['axes.prop_cycle'])] else: return plt.rcParams['axes.color_cycle']
[ "Get", "cycle", "of", "colors", "in", "a", "way", "compatible", "with", "all", "matplotlib", "versions" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/epochs.py#L113-L118
[ "def", "_get_color_list", "(", ")", ":", "if", "'axes.prop_cycle'", "in", "plt", ".", "rcParams", ":", "return", "[", "p", "[", "'color'", "]", "for", "p", "in", "list", "(", "plt", ".", "rcParams", "[", "'axes.prop_cycle'", "]", ")", "]", "else", ":",...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
_plot_variability
Plot the timeseries and variability. Optionally plot epochs.
nsim/analyses1/epochs.py
def _plot_variability(ts, variability, threshold=None, epochs=None): """Plot the timeseries and variability. Optionally plot epochs.""" import matplotlib.style import matplotlib as mpl mpl.style.use('classic') import matplotlib.pyplot as plt if variability.ndim is 1: variability = variab...
def _plot_variability(ts, variability, threshold=None, epochs=None): """Plot the timeseries and variability. Optionally plot epochs.""" import matplotlib.style import matplotlib as mpl mpl.style.use('classic') import matplotlib.pyplot as plt if variability.ndim is 1: variability = variab...
[ "Plot", "the", "timeseries", "and", "variability", ".", "Optionally", "plot", "epochs", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/epochs.py#L121-L184
[ "def", "_plot_variability", "(", "ts", ",", "variability", ",", "threshold", "=", "None", ",", "epochs", "=", "None", ")", ":", "import", "matplotlib", ".", "style", "import", "matplotlib", "as", "mpl", "mpl", ".", "style", ".", "use", "(", "'classic'", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
epochs
Identify "stationary" epochs within a time series, based on a continuous measure of variability. Epochs are defined to contain the points of minimal variability, and to extend as wide as possible with variability not exceeding the threshold. Args: ts Timeseries of m variables, shape (n, m). ...
nsim/analyses1/epochs.py
def epochs(ts, variability=None, threshold=0.0, minlength=1.0, plot=True): """Identify "stationary" epochs within a time series, based on a continuous measure of variability. Epochs are defined to contain the points of minimal variability, and to extend as wide as possible with variability not exceedi...
def epochs(ts, variability=None, threshold=0.0, minlength=1.0, plot=True): """Identify "stationary" epochs within a time series, based on a continuous measure of variability. Epochs are defined to contain the points of minimal variability, and to extend as wide as possible with variability not exceedi...
[ "Identify", "stationary", "epochs", "within", "a", "time", "series", "based", "on", "a", "continuous", "measure", "of", "variability", ".", "Epochs", "are", "defined", "to", "contain", "the", "points", "of", "minimal", "variability", "and", "to", "extend", "as...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/epochs.py#L187-L273
[ "def", "epochs", "(", "ts", ",", "variability", "=", "None", ",", "threshold", "=", "0.0", ",", "minlength", "=", "1.0", ",", "plot", "=", "True", ")", ":", "if", "variability", "is", "None", ":", "variability", "=", "ts", ".", "variability_fp", "(", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
epochs_distributed
Same as `epochs()`, but computes channels in parallel for speed. (Note: This requires an IPython cluster to be started first, e.g. on a workstation type 'ipcluster start') Identify "stationary" epochs within a time series, based on a continuous measure of variability. Epochs are defined t...
nsim/analyses1/epochs.py
def epochs_distributed(ts, variability=None, threshold=0.0, minlength=1.0, plot=True): """Same as `epochs()`, but computes channels in parallel for speed. (Note: This requires an IPython cluster to be started first, e.g. on a workstation type 'ipcluster start') Identify...
def epochs_distributed(ts, variability=None, threshold=0.0, minlength=1.0, plot=True): """Same as `epochs()`, but computes channels in parallel for speed. (Note: This requires an IPython cluster to be started first, e.g. on a workstation type 'ipcluster start') Identify...
[ "Same", "as", "epochs", "()", "but", "computes", "channels", "in", "parallel", "for", "speed", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/epochs.py#L276-L322
[ "def", "epochs_distributed", "(", "ts", ",", "variability", "=", "None", ",", "threshold", "=", "0.0", ",", "minlength", "=", "1.0", ",", "plot", "=", "True", ")", ":", "import", "distob", "if", "ts", ".", "ndim", "is", "1", ":", "ts", "=", "ts", "...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
epochs_joint
Identify epochs within a multivariate time series where at least a certain proportion of channels are "stationary", based on a previously computed variability measure. (Note: This requires an IPython cluster to be started first, e.g. on a workstation type 'ipcluster start') Args: ts Tim...
nsim/analyses1/epochs.py
def epochs_joint(ts, variability=None, threshold=0.0, minlength=1.0, proportion=0.75, plot=True): """Identify epochs within a multivariate time series where at least a certain proportion of channels are "stationary", based on a previously computed variability measure. (Note: This req...
def epochs_joint(ts, variability=None, threshold=0.0, minlength=1.0, proportion=0.75, plot=True): """Identify epochs within a multivariate time series where at least a certain proportion of channels are "stationary", based on a previously computed variability measure. (Note: This req...
[ "Identify", "epochs", "within", "a", "multivariate", "time", "series", "where", "at", "least", "a", "certain", "proportion", "of", "channels", "are", "stationary", "based", "on", "a", "previously", "computed", "variability", "measure", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/epochs.py#L325-L379
[ "def", "epochs_joint", "(", "ts", ",", "variability", "=", "None", ",", "threshold", "=", "0.0", ",", "minlength", "=", "1.0", ",", "proportion", "=", "0.75", ",", "plot", "=", "True", ")", ":", "variability", ",", "allchannels_epochs", "=", "ts", ".", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
plot
Plot a Timeseries Args: ts Timeseries title str show bool whether to display the figure or just return a figure object
nsim/analyses1/plots.py
def plot(ts, title=None, show=True): """Plot a Timeseries Args: ts Timeseries title str show bool whether to display the figure or just return a figure object """ ts = _remove_pi_crossings(ts) fig = plt.figure() ylabelprops = dict(rotation=0, hor...
def plot(ts, title=None, show=True): """Plot a Timeseries Args: ts Timeseries title str show bool whether to display the figure or just return a figure object """ ts = _remove_pi_crossings(ts) fig = plt.figure() ylabelprops = dict(rotation=0, hor...
[ "Plot", "a", "Timeseries", "Args", ":", "ts", "Timeseries", "title", "str", "show", "bool", "whether", "to", "display", "the", "figure", "or", "just", "return", "a", "figure", "object" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/plots.py#L31-L81
[ "def", "plot", "(", "ts", ",", "title", "=", "None", ",", "show", "=", "True", ")", ":", "ts", "=", "_remove_pi_crossings", "(", "ts", ")", "fig", "=", "plt", ".", "figure", "(", ")", "ylabelprops", "=", "dict", "(", "rotation", "=", "0", ",", "h...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
_remove_pi_crossings
For each variable in the Timeseries, checks whether it represents a phase variable ranging from -pi to pi. If so, set all points where the phase crosses pi to 'nan' so that spurious lines will not be plotted. If ts does not need adjustment, then return ts. Otherwise return a modified copy.
nsim/analyses1/plots.py
def _remove_pi_crossings(ts): """For each variable in the Timeseries, checks whether it represents a phase variable ranging from -pi to pi. If so, set all points where the phase crosses pi to 'nan' so that spurious lines will not be plotted. If ts does not need adjustment, then return ts. Otherwis...
def _remove_pi_crossings(ts): """For each variable in the Timeseries, checks whether it represents a phase variable ranging from -pi to pi. If so, set all points where the phase crosses pi to 'nan' so that spurious lines will not be plotted. If ts does not need adjustment, then return ts. Otherwis...
[ "For", "each", "variable", "in", "the", "Timeseries", "checks", "whether", "it", "represents", "a", "phase", "variable", "ranging", "from", "-", "pi", "to", "pi", ".", "If", "so", "set", "all", "points", "where", "the", "phase", "crosses", "pi", "to", "n...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/plots.py#L84-L116
[ "def", "_remove_pi_crossings", "(", "ts", ")", ":", "orig_ts", "=", "ts", "if", "ts", ".", "ndim", "is", "1", ":", "ts", "=", "ts", "[", ":", ",", "np", ".", "newaxis", ",", "np", ".", "newaxis", "]", "elif", "ts", ".", "ndim", "is", "2", ":", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
timeseries_from_mat
load a multi-channel Timeseries from a MATLAB .mat file Args: filename (str): .mat file to load varname (str): variable name. only needed if there is more than one variable saved in the .mat file fs (scalar): sample rate of timeseries in Hz. (constant timestep assumed) Returns: ...
nsim/readfile.py
def timeseries_from_mat(filename, varname=None, fs=1.0): """load a multi-channel Timeseries from a MATLAB .mat file Args: filename (str): .mat file to load varname (str): variable name. only needed if there is more than one variable saved in the .mat file fs (scalar): sample rate of t...
def timeseries_from_mat(filename, varname=None, fs=1.0): """load a multi-channel Timeseries from a MATLAB .mat file Args: filename (str): .mat file to load varname (str): variable name. only needed if there is more than one variable saved in the .mat file fs (scalar): sample rate of t...
[ "load", "a", "multi", "-", "channel", "Timeseries", "from", "a", "MATLAB", ".", "mat", "file" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/readfile.py#L21-L42
[ "def", "timeseries_from_mat", "(", "filename", ",", "varname", "=", "None", ",", "fs", "=", "1.0", ")", ":", "import", "scipy", ".", "io", "as", "sio", "if", "varname", "is", "None", ":", "mat_dict", "=", "sio", ".", "loadmat", "(", "filename", ")", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
save_mat
save a Timeseries to a MATLAB .mat file Args: ts (Timeseries): the timeseries to save filename (str): .mat filename to save to
nsim/readfile.py
def save_mat(ts, filename): """save a Timeseries to a MATLAB .mat file Args: ts (Timeseries): the timeseries to save filename (str): .mat filename to save to """ import scipy.io as sio tspan = ts.tspan fs = (1.0*len(tspan) - 1) / (tspan[-1] - tspan[0]) mat_dict = {'data': np.asar...
def save_mat(ts, filename): """save a Timeseries to a MATLAB .mat file Args: ts (Timeseries): the timeseries to save filename (str): .mat filename to save to """ import scipy.io as sio tspan = ts.tspan fs = (1.0*len(tspan) - 1) / (tspan[-1] - tspan[0]) mat_dict = {'data': np.asar...
[ "save", "a", "Timeseries", "to", "a", "MATLAB", ".", "mat", "file", "Args", ":", "ts", "(", "Timeseries", ")", ":", "the", "timeseries", "to", "save", "filename", "(", "str", ")", ":", ".", "mat", "filename", "to", "save", "to" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/readfile.py#L45-L58
[ "def", "save_mat", "(", "ts", ",", "filename", ")", ":", "import", "scipy", ".", "io", "as", "sio", "tspan", "=", "ts", ".", "tspan", "fs", "=", "(", "1.0", "*", "len", "(", "tspan", ")", "-", "1", ")", "/", "(", "tspan", "[", "-", "1", "]", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
timeseries_from_file
Load a multi-channel Timeseries from any file type supported by `biosig` Supported file formats include EDF/EDF+, BDF/BDF+, EEG, CNT and GDF. Full list is here: http://pub.ist.ac.at/~schloegl/biosig/TESTED For EDF, EDF+, BDF and BDF+ files, we will use python-edf if it is installed, otherwise will fa...
nsim/readfile.py
def timeseries_from_file(filename): """Load a multi-channel Timeseries from any file type supported by `biosig` Supported file formats include EDF/EDF+, BDF/BDF+, EEG, CNT and GDF. Full list is here: http://pub.ist.ac.at/~schloegl/biosig/TESTED For EDF, EDF+, BDF and BDF+ files, we will use python-edf...
def timeseries_from_file(filename): """Load a multi-channel Timeseries from any file type supported by `biosig` Supported file formats include EDF/EDF+, BDF/BDF+, EEG, CNT and GDF. Full list is here: http://pub.ist.ac.at/~schloegl/biosig/TESTED For EDF, EDF+, BDF and BDF+ files, we will use python-edf...
[ "Load", "a", "multi", "-", "channel", "Timeseries", "from", "any", "file", "type", "supported", "by", "biosig" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/readfile.py#L61-L96
[ "def", "timeseries_from_file", "(", "filename", ")", ":", "if", "not", "path", ".", "isfile", "(", "filename", ")", ":", "raise", "Error", "(", "\"file not found: '%s'\"", "%", "filename", ")", "is_edf_bdf", "=", "(", "filename", "[", "-", "4", ":", "]", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
_load_edflib
load a multi-channel Timeseries from an EDF (European Data Format) file or EDF+ file, using edflib. Args: filename: EDF+ file Returns: Timeseries
nsim/readfile.py
def _load_edflib(filename): """load a multi-channel Timeseries from an EDF (European Data Format) file or EDF+ file, using edflib. Args: filename: EDF+ file Returns: Timeseries """ import edflib e = edflib.EdfReader(filename, annotations_mode='all') if np.ptp(e.get_samples_...
def _load_edflib(filename): """load a multi-channel Timeseries from an EDF (European Data Format) file or EDF+ file, using edflib. Args: filename: EDF+ file Returns: Timeseries """ import edflib e = edflib.EdfReader(filename, annotations_mode='all') if np.ptp(e.get_samples_...
[ "load", "a", "multi", "-", "channel", "Timeseries", "from", "an", "EDF", "(", "European", "Data", "Format", ")", "file", "or", "EDF", "+", "file", "using", "edflib", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/readfile.py#L125-L154
[ "def", "_load_edflib", "(", "filename", ")", ":", "import", "edflib", "e", "=", "edflib", ".", "EdfReader", "(", "filename", ",", "annotations_mode", "=", "'all'", ")", "if", "np", ".", "ptp", "(", "e", ".", "get_samples_per_signal", "(", ")", ")", "!=",...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
annotations_from_file
Get a list of event annotations from an EDF (European Data Format file or EDF+ file, using edflib. Args: filename: EDF+ file Returns: list: annotation events, each in the form [start_time, duration, text]
nsim/readfile.py
def annotations_from_file(filename): """Get a list of event annotations from an EDF (European Data Format file or EDF+ file, using edflib. Args: filename: EDF+ file Returns: list: annotation events, each in the form [start_time, duration, text] """ import edflib e = edflib.EdfR...
def annotations_from_file(filename): """Get a list of event annotations from an EDF (European Data Format file or EDF+ file, using edflib. Args: filename: EDF+ file Returns: list: annotation events, each in the form [start_time, duration, text] """ import edflib e = edflib.EdfR...
[ "Get", "a", "list", "of", "event", "annotations", "from", "an", "EDF", "(", "European", "Data", "Format", "file", "or", "EDF", "+", "file", "using", "edflib", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/readfile.py#L157-L169
[ "def", "annotations_from_file", "(", "filename", ")", ":", "import", "edflib", "e", "=", "edflib", ".", "EdfReader", "(", "filename", ",", "annotations_mode", "=", "'all'", ")", "return", "e", ".", "read_annotations", "(", ")" ]
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
_ufunc_wrap
After using the superclass __numpy_ufunc__ to route ufunc computations on the array data, convert any resulting ndarray, RemoteArray and DistArray instances into Timeseries, RemoteTimeseries and DistTimeseries instances if appropriate
nsim/nsim.py
def _ufunc_wrap(out_arr, ufunc, method, i, inputs, **kwargs): """After using the superclass __numpy_ufunc__ to route ufunc computations on the array data, convert any resulting ndarray, RemoteArray and DistArray instances into Timeseries, RemoteTimeseries and DistTimeseries instances if appropriate""" ...
def _ufunc_wrap(out_arr, ufunc, method, i, inputs, **kwargs): """After using the superclass __numpy_ufunc__ to route ufunc computations on the array data, convert any resulting ndarray, RemoteArray and DistArray instances into Timeseries, RemoteTimeseries and DistTimeseries instances if appropriate""" ...
[ "After", "using", "the", "superclass", "__numpy_ufunc__", "to", "route", "ufunc", "computations", "on", "the", "array", "data", "convert", "any", "resulting", "ndarray", "RemoteArray", "and", "DistArray", "instances", "into", "Timeseries", "RemoteTimeseries", "and", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L660-L700
[ "def", "_ufunc_wrap", "(", "out_arr", ",", "ufunc", ",", "method", ",", "i", ",", "inputs", ",", "*", "*", "kwargs", ")", ":", "# Assigns tspan/labels to an axis only if inputs do not disagree on them.", "shape", "=", "out_arr", ".", "shape", "ndim", "=", "out_arr...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
_rts_from_ra
construct a RemoteTimeseries from a RemoteArray
nsim/nsim.py
def _rts_from_ra(ra, tspan, labels, block=True): """construct a RemoteTimeseries from a RemoteArray""" def _convert(a, tspan, labels): from nsim import Timeseries return Timeseries(a, tspan, labels) return distob.call( _convert, ra, tspan, labels, prefer_local=False, block=block)
def _rts_from_ra(ra, tspan, labels, block=True): """construct a RemoteTimeseries from a RemoteArray""" def _convert(a, tspan, labels): from nsim import Timeseries return Timeseries(a, tspan, labels) return distob.call( _convert, ra, tspan, labels, prefer_local=False, block=block)
[ "construct", "a", "RemoteTimeseries", "from", "a", "RemoteArray" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L703-L709
[ "def", "_rts_from_ra", "(", "ra", ",", "tspan", ",", "labels", ",", "block", "=", "True", ")", ":", "def", "_convert", "(", "a", ",", "tspan", ",", "labels", ")", ":", "from", "nsim", "import", "Timeseries", "return", "Timeseries", "(", "a", ",", "ts...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
_dts_from_da
construct a DistTimeseries from a DistArray
nsim/nsim.py
def _dts_from_da(da, tspan, labels): """construct a DistTimeseries from a DistArray""" sublabels = labels[:] new_subarrays = [] for i, ra in enumerate(da._subarrays): if isinstance(ra, RemoteTimeseries): new_subarrays.append(ra) else: if labels[da._distaxis]: ...
def _dts_from_da(da, tspan, labels): """construct a DistTimeseries from a DistArray""" sublabels = labels[:] new_subarrays = [] for i, ra in enumerate(da._subarrays): if isinstance(ra, RemoteTimeseries): new_subarrays.append(ra) else: if labels[da._distaxis]: ...
[ "construct", "a", "DistTimeseries", "from", "a", "DistArray" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L712-L730
[ "def", "_dts_from_da", "(", "da", ",", "tspan", ",", "labels", ")", ":", "sublabels", "=", "labels", "[", ":", "]", "new_subarrays", "=", "[", "]", "for", "i", ",", "ra", "in", "enumerate", "(", "da", ".", "_subarrays", ")", ":", "if", "isinstance", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
newsim
Make a simulation of the system defined by functions f and G. dy = f(y,t)dt + G(y,t).dW with initial condition y0 This helper function is for convenience, making it easy to define one-off simulations interactively in ipython. Args: f: callable(y, t) (defined in global scope) returning (n,) arra...
nsim/nsim.py
def newsim(f, G, y0, name='NewModel', modelType=ItoModel, T=60.0, dt=0.005, repeat=1, identical=True): """Make a simulation of the system defined by functions f and G. dy = f(y,t)dt + G(y,t).dW with initial condition y0 This helper function is for convenience, making it easy to define one-off simulati...
def newsim(f, G, y0, name='NewModel', modelType=ItoModel, T=60.0, dt=0.005, repeat=1, identical=True): """Make a simulation of the system defined by functions f and G. dy = f(y,t)dt + G(y,t).dW with initial condition y0 This helper function is for convenience, making it easy to define one-off simulati...
[ "Make", "a", "simulation", "of", "the", "system", "defined", "by", "functions", "f", "and", "G", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1758-L1791
[ "def", "newsim", "(", "f", ",", "G", ",", "y0", ",", "name", "=", "'NewModel'", ",", "modelType", "=", "ItoModel", ",", "T", "=", "60.0", ",", "dt", "=", "0.005", ",", "repeat", "=", "1", ",", "identical", "=", "True", ")", ":", "NewModel", "=", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
newmodel
Use the functions f and G to define a new Model class for simulations. It will take functions f and G from global scope and make a new Model class out of them. It will automatically gather any globals used in the definition of f and G and turn them into attributes of the new Model. Args: f: cal...
nsim/nsim.py
def newmodel(f, G, y0, name='NewModel', modelType=ItoModel): """Use the functions f and G to define a new Model class for simulations. It will take functions f and G from global scope and make a new Model class out of them. It will automatically gather any globals used in the definition of f and G and...
def newmodel(f, G, y0, name='NewModel', modelType=ItoModel): """Use the functions f and G to define a new Model class for simulations. It will take functions f and G from global scope and make a new Model class out of them. It will automatically gather any globals used in the definition of f and G and...
[ "Use", "the", "functions", "f", "and", "G", "to", "define", "a", "new", "Model", "class", "for", "simulations", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1794-L1851
[ "def", "newmodel", "(", "f", ",", "G", ",", "y0", ",", "name", "=", "'NewModel'", ",", "modelType", "=", "ItoModel", ")", ":", "if", "not", "issubclass", "(", "modelType", ",", "Model", ")", ":", "raise", "SimTypeError", "(", "'modelType must be a subclass...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
__clone_function
Make a new version of a function that has its own independent copy of any globals that it uses directly, and has its own name. All other attributes are assigned from the original function. Args: f: the function to clone name (str): the name for the new function (if None, keep the same name) ...
nsim/nsim.py
def __clone_function(f, name=None): """Make a new version of a function that has its own independent copy of any globals that it uses directly, and has its own name. All other attributes are assigned from the original function. Args: f: the function to clone name (str): the name for the ...
def __clone_function(f, name=None): """Make a new version of a function that has its own independent copy of any globals that it uses directly, and has its own name. All other attributes are assigned from the original function. Args: f: the function to clone name (str): the name for the ...
[ "Make", "a", "new", "version", "of", "a", "function", "that", "has", "its", "own", "independent", "copy", "of", "any", "globals", "that", "it", "uses", "directly", "and", "has", "its", "own", "name", ".", "All", "other", "attributes", "are", "assigned", ...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1884-L1917
[ "def", "__clone_function", "(", "f", ",", "name", "=", "None", ")", ":", "if", "not", "isinstance", "(", "f", ",", "types", ".", "FunctionType", ")", ":", "raise", "SimTypeError", "(", "'Given parameter is not a function.'", ")", "if", "name", "is", "None", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
DistTimeseries.expand_dims
Insert a new axis, at a given position in the array shape Args: axis (int): Position (amongst axes) where new axis is to be inserted.
nsim/nsim.py
def expand_dims(self, axis): """Insert a new axis, at a given position in the array shape Args: axis (int): Position (amongst axes) where new axis is to be inserted. """ if axis <= self._distaxis: subaxis = axis new_distaxis = self._distaxis + 1 ...
def expand_dims(self, axis): """Insert a new axis, at a given position in the array shape Args: axis (int): Position (amongst axes) where new axis is to be inserted. """ if axis <= self._distaxis: subaxis = axis new_distaxis = self._distaxis + 1 ...
[ "Insert", "a", "new", "axis", "at", "a", "given", "position", "in", "the", "array", "shape", "Args", ":", "axis", "(", "int", ")", ":", "Position", "(", "amongst", "axes", ")", "where", "new", "axis", "is", "to", "be", "inserted", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L608-L625
[ "def", "expand_dims", "(", "self", ",", "axis", ")", ":", "if", "axis", "<=", "self", ".", "_distaxis", ":", "subaxis", "=", "axis", "new_distaxis", "=", "self", ".", "_distaxis", "+", "1", "else", ":", "subaxis", "=", "axis", "-", "1", "new_distaxis",...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
DistTimeseries.absolute
Calculate the absolute value element-wise. Returns: absolute (Timeseries): Absolute value. For complex input (a + b*j) gives sqrt(a**a + b**2)
nsim/nsim.py
def absolute(self): """Calculate the absolute value element-wise. Returns: absolute (Timeseries): Absolute value. For complex input (a + b*j) gives sqrt(a**a + b**2) """ da = distob.vectorize(np.absolute)(self) return _dts_from_da(da, self.tspan, self.label...
def absolute(self): """Calculate the absolute value element-wise. Returns: absolute (Timeseries): Absolute value. For complex input (a + b*j) gives sqrt(a**a + b**2) """ da = distob.vectorize(np.absolute)(self) return _dts_from_da(da, self.tspan, self.label...
[ "Calculate", "the", "absolute", "value", "element", "-", "wise", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L627-L635
[ "def", "absolute", "(", "self", ")", ":", "da", "=", "distob", ".", "vectorize", "(", "np", ".", "absolute", ")", "(", "self", ")", "return", "_dts_from_da", "(", "da", ",", "self", ".", "tspan", ",", "self", ".", "labels", ")" ]
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
DistTimeseries.angle
Return the angle of a complex Timeseries Args: deg (bool, optional): Return angle in degrees if True, radians if False (default). Returns: angle (Timeseries): The counterclockwise angle from the positive real axis on the complex plane, with dtype...
nsim/nsim.py
def angle(self, deg=False): """Return the angle of a complex Timeseries Args: deg (bool, optional): Return angle in degrees if True, radians if False (default). Returns: angle (Timeseries): The counterclockwise angle from the positive real axis on ...
def angle(self, deg=False): """Return the angle of a complex Timeseries Args: deg (bool, optional): Return angle in degrees if True, radians if False (default). Returns: angle (Timeseries): The counterclockwise angle from the positive real axis on ...
[ "Return", "the", "angle", "of", "a", "complex", "Timeseries" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L641-L657
[ "def", "angle", "(", "self", ",", "deg", "=", "False", ")", ":", "if", "self", ".", "dtype", ".", "str", "[", "1", "]", "!=", "'c'", ":", "warnings", ".", "warn", "(", "'angle() is intended for complex-valued timeseries'", ",", "RuntimeWarning", ",", "1", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
NetworkModel.coupling
How to couple the output of one subsystem to the input of another. This is a fallback default coupling function that should usually be replaced with your own. This example coupling function takes the mean of all variables of the source subsystem and uses that value weighted by the conn...
nsim/nsim.py
def coupling(self, source_y, target_y, weight): """How to couple the output of one subsystem to the input of another. This is a fallback default coupling function that should usually be replaced with your own. This example coupling function takes the mean of all variables of the ...
def coupling(self, source_y, target_y, weight): """How to couple the output of one subsystem to the input of another. This is a fallback default coupling function that should usually be replaced with your own. This example coupling function takes the mean of all variables of the ...
[ "How", "to", "couple", "the", "output", "of", "one", "subsystem", "to", "the", "input", "of", "another", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1113-L1132
[ "def", "coupling", "(", "self", ",", "source_y", ",", "target_y", ",", "weight", ")", ":", "return", "np", ".", "ones_like", "(", "target_y", ")", "*", "np", ".", "mean", "(", "source_y", ")", "*", "weight" ]
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
NetworkModel.f
Deterministic term f of the complete network system dy = f(y, t)dt + G(y, t).dot(dW) (or for an ODE network system without noise, dy/dt = f(y, t)) Args: y (array of shape (d,)): where d is the dimension of the overall state space of the complete network system. ...
nsim/nsim.py
def f(self, y, t): """Deterministic term f of the complete network system dy = f(y, t)dt + G(y, t).dot(dW) (or for an ODE network system without noise, dy/dt = f(y, t)) Args: y (array of shape (d,)): where d is the dimension of the overall state space of the compl...
def f(self, y, t): """Deterministic term f of the complete network system dy = f(y, t)dt + G(y, t).dot(dW) (or for an ODE network system without noise, dy/dt = f(y, t)) Args: y (array of shape (d,)): where d is the dimension of the overall state space of the compl...
[ "Deterministic", "term", "f", "of", "the", "complete", "network", "system", "dy", "=", "f", "(", "y", "t", ")", "dt", "+", "G", "(", "y", "t", ")", ".", "dot", "(", "dW", ")" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1134-L1160
[ "def", "f", "(", "self", ",", "y", ",", "t", ")", ":", "coupling", "=", "self", ".", "coupling_function", "[", "0", "]", "res", "=", "np", ".", "empty_like", "(", "self", ".", "y0", ")", "for", "j", ",", "m", "in", "enumerate", "(", "self", "."...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
NetworkModel.G
Noise coefficient matrix G of the complete network system dy = f(y, t)dt + G(y, t).dot(dW) (for an ODE network system without noise this function is not used) Args: y (array of shape (d,)): where d is the dimension of the overall state space of the complete network system...
nsim/nsim.py
def G(self, y, t): """Noise coefficient matrix G of the complete network system dy = f(y, t)dt + G(y, t).dot(dW) (for an ODE network system without noise this function is not used) Args: y (array of shape (d,)): where d is the dimension of the overall state space ...
def G(self, y, t): """Noise coefficient matrix G of the complete network system dy = f(y, t)dt + G(y, t).dot(dW) (for an ODE network system without noise this function is not used) Args: y (array of shape (d,)): where d is the dimension of the overall state space ...
[ "Noise", "coefficient", "matrix", "G", "of", "the", "complete", "network", "system", "dy", "=", "f", "(", "y", "t", ")", "dt", "+", "G", "(", "y", "t", ")", ".", "dot", "(", "dW", ")" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1162-L1193
[ "def", "G", "(", "self", ",", "y", ",", "t", ")", ":", "if", "self", ".", "_independent_noise", ":", "# then G matrix consists of submodel Gs diagonally concatenated:", "res", "=", "np", ".", "zeros", "(", "(", "self", ".", "dimension", ",", "self", ".", "nn...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
NetworkModel._scalar_to_vector
Allow submodels with scalar equations. Convert to 1D vector systems. Args: m (Model)
nsim/nsim.py
def _scalar_to_vector(self, m): """Allow submodels with scalar equations. Convert to 1D vector systems. Args: m (Model) """ if not isinstance(m.y0, numbers.Number): return m else: m = copy.deepcopy(m) t0 = 0.0 if isinstanc...
def _scalar_to_vector(self, m): """Allow submodels with scalar equations. Convert to 1D vector systems. Args: m (Model) """ if not isinstance(m.y0, numbers.Number): return m else: m = copy.deepcopy(m) t0 = 0.0 if isinstanc...
[ "Allow", "submodels", "with", "scalar", "equations", ".", "Convert", "to", "1D", "vector", "systems", ".", "Args", ":", "m", "(", "Model", ")" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1228-L1267
[ "def", "_scalar_to_vector", "(", "self", ",", "m", ")", ":", "if", "not", "isinstance", "(", "m", ".", "y0", ",", "numbers", ".", "Number", ")", ":", "return", "m", "else", ":", "m", "=", "copy", ".", "deepcopy", "(", "m", ")", "t0", "=", "0.0", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
NetworkModel._reshape_timeseries
Introduce a new axis 2 that ranges across nodes of the network
nsim/nsim.py
def _reshape_timeseries(self, ts): """Introduce a new axis 2 that ranges across nodes of the network""" if np.count_nonzero(np.diff(self._sublengths)) == 0: # then all submodels have the same dimension, so can reshape array # in place without copying data: subdim = se...
def _reshape_timeseries(self, ts): """Introduce a new axis 2 that ranges across nodes of the network""" if np.count_nonzero(np.diff(self._sublengths)) == 0: # then all submodels have the same dimension, so can reshape array # in place without copying data: subdim = se...
[ "Introduce", "a", "new", "axis", "2", "that", "ranges", "across", "nodes", "of", "the", "network" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1272-L1301
[ "def", "_reshape_timeseries", "(", "self", ",", "ts", ")", ":", "if", "np", ".", "count_nonzero", "(", "np", ".", "diff", "(", "self", ".", "_sublengths", ")", ")", "==", "0", ":", "# then all submodels have the same dimension, so can reshape array", "# in place w...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
NetworkModel._reshape_output
Introduce a new axis 2 that ranges across nodes of the network
nsim/nsim.py
def _reshape_output(self, ts): """Introduce a new axis 2 that ranges across nodes of the network""" subodim = len(self.submodels[0].output_vars) shp = list(ts.shape) shp[1] = subodim shp.insert(2, self._n) ts = ts.reshape(tuple(shp)) ts.labels[2] = self._node_labe...
def _reshape_output(self, ts): """Introduce a new axis 2 that ranges across nodes of the network""" subodim = len(self.submodels[0].output_vars) shp = list(ts.shape) shp[1] = subodim shp.insert(2, self._n) ts = ts.reshape(tuple(shp)) ts.labels[2] = self._node_labe...
[ "Introduce", "a", "new", "axis", "2", "that", "ranges", "across", "nodes", "of", "the", "network" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1303-L1311
[ "def", "_reshape_output", "(", "self", ",", "ts", ")", ":", "subodim", "=", "len", "(", "self", ".", "submodels", "[", "0", "]", ".", "output_vars", ")", "shp", "=", "list", "(", "ts", ".", "shape", ")", "shp", "[", "1", "]", "=", "subodim", "shp...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Simulation.timeseries
Simulated time series
nsim/nsim.py
def timeseries(self): """Simulated time series""" if self._timeseries is None: self.compute() if isinstance(self.system, NetworkModel): return self.system._reshape_timeseries(self._timeseries) else: return self._timeseries
def timeseries(self): """Simulated time series""" if self._timeseries is None: self.compute() if isinstance(self.system, NetworkModel): return self.system._reshape_timeseries(self._timeseries) else: return self._timeseries
[ "Simulated", "time", "series" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1362-L1369
[ "def", "timeseries", "(", "self", ")", ":", "if", "self", ".", "_timeseries", "is", "None", ":", "self", ".", "compute", "(", ")", "if", "isinstance", "(", "self", ".", "system", ",", "NetworkModel", ")", ":", "return", "self", ".", "system", ".", "_...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
Simulation.output
Simulated model output
nsim/nsim.py
def output(self): """Simulated model output""" if self._timeseries is None: self.compute() output = self._timeseries[:, self.system.output_vars] if isinstance(self.system, NetworkModel): return self.system._reshape_output(output) else: return o...
def output(self): """Simulated model output""" if self._timeseries is None: self.compute() output = self._timeseries[:, self.system.output_vars] if isinstance(self.system, NetworkModel): return self.system._reshape_output(output) else: return o...
[ "Simulated", "model", "output" ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1372-L1380
[ "def", "output", "(", "self", ")", ":", "if", "self", ".", "_timeseries", "is", "None", ":", "self", ".", "compute", "(", ")", "output", "=", "self", ".", "_timeseries", "[", ":", ",", "self", ".", "system", ".", "output_vars", "]", "if", "isinstance...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
MultipleSim.output
Rank 3 array representing output time series. Axis 0 is time, axis 1 ranges across output variables of a single simulation, axis 2 ranges across different simulation instances.
nsim/nsim.py
def output(self): """Rank 3 array representing output time series. Axis 0 is time, axis 1 ranges across output variables of a single simulation, axis 2 ranges across different simulation instances.""" subts = [s.output for s in self.sims] sub_ndim = subts[0].ndim if sub...
def output(self): """Rank 3 array representing output time series. Axis 0 is time, axis 1 ranges across output variables of a single simulation, axis 2 ranges across different simulation instances.""" subts = [s.output for s in self.sims] sub_ndim = subts[0].ndim if sub...
[ "Rank", "3", "array", "representing", "output", "time", "series", ".", "Axis", "0", "is", "time", "axis", "1", "ranges", "across", "output", "variables", "of", "a", "single", "simulation", "axis", "2", "ranges", "across", "different", "simulation", "instances"...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1450-L1463
[ "def", "output", "(", "self", ")", ":", "subts", "=", "[", "s", ".", "output", "for", "s", "in", "self", ".", "sims", "]", "sub_ndim", "=", "subts", "[", "0", "]", ".", "ndim", "if", "sub_ndim", "is", "1", ":", "subts", "=", "[", "distob", ".",...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
DistSim._tosub
Given an integer index ix into the list of sims, returns the pair (s, m) where s is the relevant subsim and m is the subindex into s. So self[ix] == self._subsims[s][m]
nsim/nsim.py
def _tosub(self, ix): """Given an integer index ix into the list of sims, returns the pair (s, m) where s is the relevant subsim and m is the subindex into s. So self[ix] == self._subsims[s][m] """ N = self._n if ix >= N or ix < -N: raise IndexError( ...
def _tosub(self, ix): """Given an integer index ix into the list of sims, returns the pair (s, m) where s is the relevant subsim and m is the subindex into s. So self[ix] == self._subsims[s][m] """ N = self._n if ix >= N or ix < -N: raise IndexError( ...
[ "Given", "an", "integer", "index", "ix", "into", "the", "list", "of", "sims", "returns", "the", "pair", "(", "s", "m", ")", "where", "s", "is", "the", "relevant", "subsim", "and", "m", "is", "the", "subindex", "into", "s", ".", "So", "self", "[", "...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1577-L1592
[ "def", "_tosub", "(", "self", ",", "ix", ")", ":", "N", "=", "self", ".", "_n", "if", "ix", ">=", "N", "or", "ix", "<", "-", "N", ":", "raise", "IndexError", "(", "'index %d out of bounds for list of %d sims'", "%", "(", "ix", ",", "N", ")", ")", "...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
DistSim._tosubs
Maps a list of integer indices to sub-indices. ixlist can contain repeated indices and does not need to be sorted. Returns pair (ss, ms) where ss is a list of subsim numbers and ms is a list of lists of subindices m (one list for each subsim in ss).
nsim/nsim.py
def _tosubs(self, ixlist): """Maps a list of integer indices to sub-indices. ixlist can contain repeated indices and does not need to be sorted. Returns pair (ss, ms) where ss is a list of subsim numbers and ms is a list of lists of subindices m (one list for each subsim in ss). ...
def _tosubs(self, ixlist): """Maps a list of integer indices to sub-indices. ixlist can contain repeated indices and does not need to be sorted. Returns pair (ss, ms) where ss is a list of subsim numbers and ms is a list of lists of subindices m (one list for each subsim in ss). ...
[ "Maps", "a", "list", "of", "integer", "indices", "to", "sub", "-", "indices", ".", "ixlist", "can", "contain", "repeated", "indices", "and", "does", "not", "need", "to", "be", "sorted", ".", "Returns", "pair", "(", "ss", "ms", ")", "where", "ss", "is",...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1594-L1636
[ "def", "_tosubs", "(", "self", ",", "ixlist", ")", ":", "n", "=", "len", "(", "ixlist", ")", "N", "=", "self", ".", "_n", "ss", "=", "[", "]", "ms", "=", "[", "]", "if", "n", "==", "0", ":", "return", "ss", ",", "ms", "j", "=", "0", "# th...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
DistSim.output
Rank 3 array representing output time series. Axis 0 is time, axis 1 ranges across output variables of a single simulation, axis 2 ranges across different simulation instances.
nsim/nsim.py
def output(self): """Rank 3 array representing output time series. Axis 0 is time, axis 1 ranges across output variables of a single simulation, axis 2 ranges across different simulation instances.""" subts = [rms.output for rms in self._subsims] distaxis = subts[0].ndim - 1 ...
def output(self): """Rank 3 array representing output time series. Axis 0 is time, axis 1 ranges across output variables of a single simulation, axis 2 ranges across different simulation instances.""" subts = [rms.output for rms in self._subsims] distaxis = subts[0].ndim - 1 ...
[ "Rank", "3", "array", "representing", "output", "time", "series", ".", "Axis", "0", "is", "time", "axis", "1", "ranges", "across", "output", "variables", "of", "a", "single", "simulation", "axis", "2", "ranges", "across", "different", "simulation", "instances"...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/nsim.py#L1676-L1682
[ "def", "output", "(", "self", ")", ":", "subts", "=", "[", "rms", ".", "output", "for", "rms", "in", "self", ".", "_subsims", "]", "distaxis", "=", "subts", "[", "0", "]", ".", "ndim", "-", "1", "return", "DistTimeseries", "(", "subts", ",", "dista...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
crossing_times
For a single variable timeseries, find the times at which the value crosses ``c`` from above or below. Can optionally set a non-zero ``d`` to impose the condition that the value must wander at least ``d`` units away from ``c`` between crossings. If the timeseries begins (or ends) exactly at ``c``, the...
nsim/analyses1/misc.py
def crossing_times(ts, c=0.0, d=0.0): """For a single variable timeseries, find the times at which the value crosses ``c`` from above or below. Can optionally set a non-zero ``d`` to impose the condition that the value must wander at least ``d`` units away from ``c`` between crossings. If the time...
def crossing_times(ts, c=0.0, d=0.0): """For a single variable timeseries, find the times at which the value crosses ``c`` from above or below. Can optionally set a non-zero ``d`` to impose the condition that the value must wander at least ``d`` units away from ``c`` between crossings. If the time...
[ "For", "a", "single", "variable", "timeseries", "find", "the", "times", "at", "which", "the", "value", "crosses", "c", "from", "above", "or", "below", ".", "Can", "optionally", "set", "a", "non", "-", "zero", "d", "to", "impose", "the", "condition", "tha...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/misc.py#L18-L71
[ "def", "crossing_times", "(", "ts", ",", "c", "=", "0.0", ",", "d", "=", "0.0", ")", ":", "#TODO support multivariate time series", "ts", "=", "ts", ".", "squeeze", "(", ")", "if", "ts", ".", "ndim", "is", "not", "1", ":", "raise", "ValueError", "(", ...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
first_return_times
For a single variable time series, first wait until the time series attains the value c for the first time. Then record the time intervals between successive returns to c. If c is not given, the default is the mean of the time series. Args: ts: Timeseries (single variable) c (float): ...
nsim/analyses1/misc.py
def first_return_times(ts, c=None, d=0.0): """For a single variable time series, first wait until the time series attains the value c for the first time. Then record the time intervals between successive returns to c. If c is not given, the default is the mean of the time series. Args: t...
def first_return_times(ts, c=None, d=0.0): """For a single variable time series, first wait until the time series attains the value c for the first time. Then record the time intervals between successive returns to c. If c is not given, the default is the mean of the time series. Args: t...
[ "For", "a", "single", "variable", "time", "series", "first", "wait", "until", "the", "time", "series", "attains", "the", "value", "c", "for", "the", "first", "time", ".", "Then", "record", "the", "time", "intervals", "between", "successive", "returns", "to",...
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/misc.py#L74-L98
[ "def", "first_return_times", "(", "ts", ",", "c", "=", "None", ",", "d", "=", "0.0", ")", ":", "ts", "=", "np", ".", "squeeze", "(", "ts", ")", "if", "c", "is", "None", ":", "c", "=", "ts", ".", "mean", "(", ")", "if", "ts", ".", "ndim", "<...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
autocorrelation
Returns the discrete, linear convolution of a time series with itself, optionally using unbiased normalization. N.B. Autocorrelation estimates are necessarily inaccurate for longer lags, as there are less pairs of points to convolve separated by that lag. Therefore best to throw out the results excep...
nsim/analyses1/misc.py
def autocorrelation(ts, normalized=False, unbiased=False): """ Returns the discrete, linear convolution of a time series with itself, optionally using unbiased normalization. N.B. Autocorrelation estimates are necessarily inaccurate for longer lags, as there are less pairs of points to convolve s...
def autocorrelation(ts, normalized=False, unbiased=False): """ Returns the discrete, linear convolution of a time series with itself, optionally using unbiased normalization. N.B. Autocorrelation estimates are necessarily inaccurate for longer lags, as there are less pairs of points to convolve s...
[ "Returns", "the", "discrete", "linear", "convolution", "of", "a", "time", "series", "with", "itself", "optionally", "using", "unbiased", "normalization", "." ]
mattja/nsim
python
https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/misc.py#L101-L145
[ "def", "autocorrelation", "(", "ts", ",", "normalized", "=", "False", ",", "unbiased", "=", "False", ")", ":", "ts", "=", "np", ".", "squeeze", "(", "ts", ")", "if", "ts", ".", "ndim", "<=", "1", ":", "if", "normalized", ":", "ts", "=", "(", "ts"...
ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0
train
freshroastsr700.fan_speed
Verifies the value is between 1 and 9 inclusively.
freshroastsr700/__init__.py
def fan_speed(self, value): """Verifies the value is between 1 and 9 inclusively.""" if value not in range(1, 10): raise exceptions.RoasterValueError self._fan_speed.value = value
def fan_speed(self, value): """Verifies the value is between 1 and 9 inclusively.""" if value not in range(1, 10): raise exceptions.RoasterValueError self._fan_speed.value = value
[ "Verifies", "the", "value", "is", "between", "1", "and", "9", "inclusively", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L238-L243
[ "def", "fan_speed", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "range", "(", "1", ",", "10", ")", ":", "raise", "exceptions", ".", "RoasterValueError", "self", ".", "_fan_speed", ".", "value", "=", "value" ]
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700.heat_setting
Verifies that the heat setting is between 0 and 3.
freshroastsr700/__init__.py
def heat_setting(self, value): """Verifies that the heat setting is between 0 and 3.""" if value not in range(0, 4): raise exceptions.RoasterValueError self._heat_setting.value = value
def heat_setting(self, value): """Verifies that the heat setting is between 0 and 3.""" if value not in range(0, 4): raise exceptions.RoasterValueError self._heat_setting.value = value
[ "Verifies", "that", "the", "heat", "setting", "is", "between", "0", "and", "3", "." ]
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L259-L264
[ "def", "heat_setting", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "range", "(", "0", ",", "4", ")", ":", "raise", "exceptions", ".", "RoasterValueError", "self", ".", "_heat_setting", ".", "value", "=", "value" ]
49cf4961444c0f56d051d5ac5088ace480b54f02
train
freshroastsr700.heater_level
Verifies that the heater_level is between 0 and heater_segments. Can only be called when freshroastsr700 object is initialized with ext_sw_heater_drive=True. Will throw RoasterValueError otherwise.
freshroastsr700/__init__.py
def heater_level(self, value): """Verifies that the heater_level is between 0 and heater_segments. Can only be called when freshroastsr700 object is initialized with ext_sw_heater_drive=True. Will throw RoasterValueError otherwise.""" if self._ext_sw_heater_drive: ...
def heater_level(self, value): """Verifies that the heater_level is between 0 and heater_segments. Can only be called when freshroastsr700 object is initialized with ext_sw_heater_drive=True. Will throw RoasterValueError otherwise.""" if self._ext_sw_heater_drive: ...
[ "Verifies", "that", "the", "heater_level", "is", "between", "0", "and", "heater_segments", ".", "Can", "only", "be", "called", "when", "freshroastsr700", "object", "is", "initialized", "with", "ext_sw_heater_drive", "=", "True", ".", "Will", "throw", "RoasterValue...
Roastero/freshroastsr700
python
https://github.com/Roastero/freshroastsr700/blob/49cf4961444c0f56d051d5ac5088ace480b54f02/freshroastsr700/__init__.py#L352-L362
[ "def", "heater_level", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_ext_sw_heater_drive", ":", "if", "value", "not", "in", "range", "(", "0", ",", "self", ".", "_heater_bangbang_segments", "+", "1", ")", ":", "raise", "exceptions", ".", "Roa...
49cf4961444c0f56d051d5ac5088ace480b54f02