stockwelltransform / stockwell / __init__.py

"""
modules:
st  - link to C implementation
smt - multitaper stockwell transform 
get from st module:

hilbert(x) returns the complex Hilbert transform of the real array x.

st(x[, lo, hi]) returns the 2d, complex Stockwell transform of the real\n\
array x. If lo and hi are specified, only those frequencies (rows) are\n\
returned; lo and hi default to 0 and n/2, resp., where n is the length of x.

ist(y[, lo, hi]) returns the inverse Stockwell transform of the 2d, complex\n\
array y.

"""
from __future__ import division

def stfreq(f,length, srate):
	"""
        [int] = stfreq(f,length, srate)
        Convert frequencies f in Hz into rows of the stockwell transform
	given sampling rate srate and length of original array

        note: length * (1.0/srate)
      	# in C this would be:  return floor(f * len / srate + .5);
        
        """
        # return int( f*(length//srate)+0.5)
	return int(round(f*length/srate))

# row = int(f*length)/srate)
# row*srate = f*length
# f = row*srate/length

def st_rowfreq(row,srate,length):
	"""
	for a row in a stockwell transform, give what frequency (Hz)
	it corresponds to, given the sampling rate srate and the length of the original
	array
	"""
	return row*srate/length
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.