コード例 #1
0
ファイル: galaxy_bios.py プロジェクト: tomczak724/mypy
def restore_logaxes_labels(subplot, xaxis=True, yaxis=True):
	'''
	This script reformats the default labeling scheme
	for logarithmic axis labels to the "regular" format.
	e.g. axis labels of "10**-1" and "10**3" will be
	changed to "0.1" and "1000" respectively.
	'''
	xticks = subplot.get_xticks() 
	yticks = subplot.get_yticks() 

	if xaxis:
		xticks_new = []
		for xi in xticks:
			base = pylab.log10(xi)
			if base >= 0:
				xi_new = '%i' % xi
			else:
				formatter = '%.' + str(int(abs(base))) + 'f'
				xi_new = formatter % xi
			xticks_new.append(xi_new)
		subplot.xaxis.set_ticklabels(xticks_new)

	if yaxis:
		yticks_new = []
		for yi in yticks:
			base = pylab.log10(yi)
			if base >= 0:
				yi_new = '%i' % yi
			else:
				formatter = '%.' + str(int(abs(base))) + 'f'
				yi_new = formatter % yi
			yticks_new.append(yi_new)
		subplot.yaxis.set_ticklabels(yticks_new)

	return subplot
コード例 #2
0
ファイル: fields.py プロジェクト: california43/gattini
    def value(self, data, image=None):        
        cam = data['name']
        if type(cam) == N.recarray:
            cam = cam[0]
        pix_size = {"sky": N.sqrt(202000/4), "sbc": 11.3}[cam]        
        ex = data['exposure']
        sky = data['sky'].clip(0.0001, data['sky'].max())
        mean = data['mean'] 
        pix_mag = 2.5*log10(pix_size**2) 


        temp = data['temp'].copy()
        if type(cam) == N.recarray:
            temp[temp < -35] = -40
            temp[temp >= -35] = -30
            
            offset = ex.copy()
            offset[temp == -30] = 2.25*ex[temp == -30]
            offset[temp == -40] = 0.59*ex[temp == -40]
        else:
            offset = 0
        if cam == "sbc":
            offset = 68
        else:
            offset += 77.1
        return -2.5*log10(sky - offset) + data['zmag']  + pix_mag
コード例 #3
0
ファイル: foo.py プロジェクト: california43/gattini
def main():
    Z = 17.4
    pix_size = 11.3
    pix_mag = 2.5*log10(pix_size**2) 
    sky = 148
    offset = 68        
    print -2.5*log10(sky - offset) + Z  + pix_mag
コード例 #4
0
def get_Kmag_true(jflux_instr, kflux_instr):
	a = 1.
	b = -0.0257698323
	c = 29.4494709
	if jflux_instr < 0 or kflux_instr < 0:
		return -99.
	else:
		jmag_instr = -2.5 * pylab.log10(jflux_instr)
		kmag_instr = -2.5 * pylab.log10(kflux_instr)
		return a * kmag_instr + b * (jmag_instr - kmag_instr) + c
コード例 #5
0
def get_Iplusmag_true(rflux_instr, iflux_instr):
	a = 1.
	b = 0.00013198858
	c = 27.3378864
	if rflux_instr < 0 or iflux_instr < 0:
		return -99.
	else:
		rmag_instr = -2.5 * pylab.log10(rflux_instr)
		imag_instr = -2.5 * pylab.log10(iflux_instr)
		return a * imag_instr + b * (rmag_instr - imag_instr) + c
コード例 #6
0
def get_rmag_true(rflux_instr, iflux_instr):
	a = 1.
	b = 0.05033836
	c = 26.52083003
	if rflux_instr < 0 or iflux_instr < 0:
		return -99.
	else:
		rmag_instr = -2.5 * pylab.log10(rflux_instr)
		imag_instr = -2.5 * pylab.log10(iflux_instr)
		return a * rmag_instr + b * (rmag_instr - imag_instr) + c
コード例 #7
0
def get_imag_true(rflux_instr, iflux_instr):
	a = 1.
	b = 0.021948947
	c = 26.2291181
	if rflux_instr < 0 or iflux_instr < 0:
		return -99.
	else:
		rmag_instr = -2.5 * pylab.log10(rflux_instr)
		imag_instr = -2.5 * pylab.log10(iflux_instr)
		return a * imag_instr + b * (rmag_instr - imag_instr) + c
コード例 #8
0
def get_Jmag_true(jflux_instr, kflux_instr):
	a = 1.
	b = -0.04157139
	c = 29.07118567
	if jflux_instr < 0 or kflux_instr < 0:
		return -99.
	else:
		jmag_instr = -2.5 * pylab.log10(jflux_instr)
		kmag_instr = -2.5 * pylab.log10(kflux_instr)
		return a * jmag_instr + b * (jmag_instr - kmag_instr) + c
コード例 #9
0
def get_zmag_true(iflux_instr, zflux_instr):
	a = 1.
	b = -0.03321189
	c = 25.02113495
	if iflux_instr < 0 or zflux_instr < 0:
		return -99.
	else:
		imag_instr = -2.5 * pylab.log10(iflux_instr)
		zmag_instr = -2.5 * pylab.log10(zflux_instr)
		return a * zmag_instr + b * (imag_instr - zmag_instr) + c
コード例 #10
0
def get_Rplusmag_true(rflux_instr, iflux_instr):
	a = 1.
	b = 0.03185165
	c = 27.45145076
	if rflux_instr < 0 or iflux_instr < 0:
		return -99.
	else:
		rmag_instr = -2.5 * pylab.log10(rflux_instr)
		imag_instr = -2.5 * pylab.log10(iflux_instr)
		return a * rmag_instr + b * (rmag_instr - imag_instr) + c
コード例 #11
0
ファイル: test_eigenfre.py プロジェクト: anielsen001/spectrum
def create_figure():
    psd = test_eigenfre_music()
    f = linspace(-0.5, 0.5, len(psd))
    plot(f, 10 * log10(psd/max(psd)), '--',label='MUSIC 15')
    savefig('psd_eigenfre_music.png')

    psd = test_eigenfre_ev()
    f = linspace(-0.5, 0.5, len(psd))
    plot(f, 10 * log10(psd/max(psd)), '--',label='EV 15')
    savefig('psd_eigenfre_ev.png')
コード例 #12
0
ファイル: filterexplore.py プロジェクト: kghose/neurapy
  def on_release(self, event):
    """When we release the mouse, if we were dragging the line, recompute the filter and draw it."""
    if self.being_dragged is None: return

    self.being_dragged = None
    xy = self.design_line.get_data()
    self.wp = [xy[0][2], xy[0][3]]
    self.ws = [xy[0][1], xy[0][4]]
    self.gpass = -20*pylab.log10(xy[1][2])
    self.gstop = -20*pylab.log10(xy[1][1])
    self.update_design()
コード例 #13
0
ファイル: TeraData.py プロジェクト: DavidJahn86/terapy
 def getDR(self):
     #this function should return the dynamic range
     #this should be the noiselevel of the fft
     noiselevel=py.sqrt(py.mean(abs(py.fft(self._tdData.getAllPrecNoise()[0]))**2))
     #apply a moving average filter on log
     window_size=5
     window=py.ones(int(window_size))/float(window_size)
     hlog=py.convolve(20*py.log10(self.getFAbs()), window, 'valid')
     one=py.ones((2,))
     hlog=py.concatenate((hlog[0]*one,hlog,hlog[-1]*one))
     return hlog-20*py.log10(noiselevel)         
コード例 #14
0
ファイル: test_correlog.py プロジェクト: anielsen001/spectrum
def create_figure():
    psd = test_correlog()
    f = linspace(-0.5, 0.5, len(psd))

    psd = cshift(psd, len(psd)/2)
    plot(f, 10*log10(psd/max(psd)))
    savefig('psd_corr.png')
コード例 #15
0
def plotsvd(in_filename, out_filename=None):
    """Plot heatmap of orthogonal template components."""
    from gstlal.gstlal_svd_bank import read_bank
    bank = read_bank(in_filename)
    ntemplates = 0
    for bf in bank.bank_fragments:
        next_ntemplates = ntemplates + bf.orthogonal_template_bank.shape[0]
        pylab.imshow(pylab.log10(abs(bf.orthogonal_template_bank[::-1, :])),
                     extent=(bf.end, bf.start, ntemplates, next_ntemplates),
                     hold=True,
                     aspect='auto')
        pylab.text(bf.end + bank.filter_length / 30,
                   ntemplates + 0.5 * bf.orthogonal_template_bank.shape[0],
                   '%d Hz' % bf.rate,
                   size='x-small')
        ntemplates = next_ntemplates

    pylab.xlim(0, 1.15 * bank.filter_length)
    pylab.ylim(0, 1.05 * ntemplates)
    pylab.colorbar().set_label('$\mathrm{log}_{10} |u_{i}(t)|$')
    pylab.xlabel(r"Time $t$ until coalescence (seconds)")
    pylab.ylabel(r"Basis index $i$")
    pylab.title(r"Orthonormal basis templates $u_{i}(t)$")
    if out_filename is None:
        pylab.show()
    else:
        pylab.savefig(out_filename)
    pylab.close()
コード例 #16
0
ファイル: window.py プロジェクト: carlkl/spectrum
    def compute_response(self, **kargs):
        """Compute the window data frequency response

        :param norm: True by default. normalised the frequency data.
        :param int NFFT:       total length of the final data sets( 2048 by default. if less than data length, then
            NFFT is set to the data length*2).

        The response is stored in :attr:`response`.

        .. note:: Units are dB (20 log10) since we plot the frequency response)


        """
        from pylab import fft, fftshift, log10

        norm = kargs.get('norm', self.norm)

        # do some padding. Default is max(2048, data.len*2)
        NFFT = kargs.get('NFFT', 2048)
        if NFFT < len(self.data):
            NFFT = self.data.size * 2

        # compute the fft modulus
        A = fft(self.data, NFFT)
        mag = abs(fftshift(A))

        # do we want to normalise the data
        if norm is True:
            mag = mag / max(mag)
        response = 20. * log10(mag) # factor 20 we are looking at the response
                                    # not the powe
        #response = clip(response,mindB,100)
        self.__response = response
コード例 #17
0
ファイル: test_correlog.py プロジェクト: junayed/spectrum-1
def create_figure():
    psd = test_correlog()
    f = linspace(-0.5, 0.5, len(psd))

    psd = cshift(psd, len(psd) / 2)
    plot(f, 10 * log10(psd / max(psd)))
    savefig('psd_corr.png')
コード例 #18
0
    def _fetch_normalisation(self):
        # x is training
        # y is gold
        filename = self._pj([self._path2data, 'data', 'common_training.csv'])
        training = pd.read_csv(filename)

        filename = self._pj([self._path2data, 'data', 'common_gold.csv'])
        goldfile = pd.read_csv(filename)

        #"""function [m b rho] = fetch_normalization(jj)
        #%% jj is the index of the molecule (1-7)

        colnames = self.species

        self.norm_training = pylab.log10(training[colnames] + 1)
        self.norm_gold = pylab.log10(goldfile[colnames] + 1)
コード例 #19
0
ファイル: fastq.py プロジェクト: WMGoBuffs/biokit
    def quality_from_error_probability(pe):
        """

        A quality value Q is an integer mapping of :math:`pe` (i.e., the probability 
        that the corresponding base call is incorrect). Two different equations have 
        been in use but we will only use the standard Sanger variant 
        otherwise known as Phred quality score:

        The PHRED software assigns a non-negative quality value 
        to each base using a logged transformation of the error probability:
        
        :math:`Q = -10 \log_{10}( P_e )`
        
        ::

            >>> Pe = 1e-9
            >>> Q = quality_from_error_probability(Pe)
            >>> Q
            90
            >>> quality_from_error_probability(0.1)
            0.1
            >>> quality_from_error_probability(0)
            1
            

        """
        assert pe >=0 and pe <= 1, "probability expected to be between 0 and 1"
        return -10 * pylab.log10(pe)
コード例 #20
0
ファイル: sc1a_tools.py プロジェクト: nagyistoce/dreamtools
    def pcolor(self, mode="mean", vmin=None, vmax=None):
        """

        If you loaded the pickle data sets with only mean and sigma, the D and
        pvalue mode cannot be used.

        """
        from pylab import clf, xticks, yticks, pcolor, colorbar, flipud, log10
        if mode == "mean":
            data = self.get_mean()
        elif mode == "sigma":
            data = self.get_sigma()
        elif mode == "D":
            data = self.get_ks()[0]
        elif mode == "pvalue":
            data = self.get_ks()[1]
        clf();

        if mode == "pvalue":
            pcolor(log10(flipud(data)), vmin=vmin, vmax=vmax);
        else:
            pcolor(flipud(data), vmin=vmin,vmax=vmax);

        colorbar()
        xticks([x+0.5 for x in range(0,8)], self.ligands, rotation=90)
        cellLines = self.cellLines[:]
        cellLines.reverse()
        yticks([x+0.5 for x in range(0,4)], cellLines, rotation=0)
コード例 #21
0
ファイル: test_modcovar.py プロジェクト: carlkl/spectrum
def create_figure():
    newpsd = test_modcovar()

    pylab.plot(pylab.linspace(-0.5, 0.5, 4096),
               10 * pylab.log10(newpsd/max(newpsd)))
    pylab.axis([-0.5,0.5,-60,0])
    pylab.savefig('psd_modcovar.png')
コード例 #22
0
def create_figure():
    psd = test_yule()
    psd = cshift(psd, len(psd) / 2)  # switch positive and negative freq

    plot(linspace(-0.5, 0.5, 4096), 10 * log10(psd / max(psd)))
    axis([-0.5, 0.5, -60, 0])
    savefig('psd_yulewalker.png')
コード例 #23
0
def clim_fun(CO2,S): #CO2 in bar, S relative to S0
    coeff=np.array([ -12004.26119591,   -5991.89177414,   57658.4976358 ,   9530.78716653,  -44418.02337535,   77509.34762597, -101088.63476418,  -51352.32727931,   28881.81475008, 5933.93289355,  -37758.42567241,   78609.89563769,         48737.04765816,  -59869.92585153,  -27824.46745061, 40288.32796231,     832.50331297,    1538.94623985,  -22839.47675961,   -3910.4065741 ,    6857.37036956,  -5317.5699878 ,  -11783.38289392,   17273.58930254, 10919.9212031 ])
    x=pylab.log10(CO2)
    y=S
    inputs=[x*0+1, x, y, x**2, x**2*y, x**2*y**2, y**2, x*y**2, x*y,x**3,x**3*y**3,y**3,x**3*y**2,x**2*y**3,x**3*y,x*y**3,  x**4,x**4*y**4,y**4,x**4*y,x**4*y**2,x**4*y**3,y**4*x,y**4*x**2,y**4*x**3]
    return np.sum(coeff*inputs)
        
コード例 #24
0
ファイル: filterexplore.py プロジェクト: kghose/neurapy
  def update_design(self):
    ax = self.ax
    ax.cla()
    ax2 = self.ax2
    ax2.cla()

    wp = self.wp
    ws = self.ws
    gpass = self.gpass
    gstop = self.gstop
    b, a = ss.iirdesign(wp, ws, gpass, gstop, ftype=self.ftype, output='ba')
    self.a = a
    self.b = b
    #b = [1,2]; a = [1,2]
    #Print this on command line so we can use it in our programs
    print 'b = ', pylab.array_repr(b)
    print 'a = ', pylab.array_repr(a)

    my_w = pylab.logspace(pylab.log10(.1*self.ws[0]), 0.0, num=512)
    #import pdb;pdb.set_trace()
    w, h = freqz(b, a, worN=my_w*pylab.pi)
    gp = 10**(-gpass/20.)#Go from db to regular
    gs = 10**(-gstop/20.)
    self.design_line, = ax.plot([.1*self.ws[0], self.ws[0], wp[0], wp[1], ws[1], 1.0], [gs, gs, gp, gp, gs, gs], 'ko:', lw=2, picker=5)
    ax.semilogx(w/pylab.pi, pylab.absolute(h),lw=2)
    ax.text(.5,1.0, '{:d}/{:d}'.format(len(b), len(a)))
    pylab.setp(ax, 'xlim', [.1*self.ws[0], 1.2], 'ylim', [-.1, max(1.1,1.1*pylab.absolute(h).max())], 'xticklabels', [])

    ax2.semilogx(w/pylab.pi, pylab.unwrap(pylab.angle(h)),lw=2)
    pylab.setp(ax2, 'xlim', [.1*self.ws[0], 1.2])
    ax2.set_xlabel('Normalized frequency')

    pylab.draw()
コード例 #25
0
ファイル: makemask.py プロジェクト: pawel-kw/pyxsvs
 def toggle_logscale(self,label):
     self.log_flag = not self.log_flag
     if self.log_flag:
         self.data = log10(self.data+1e-9)
     else:
         self.data = self.raw_data
     self.update_img()
コード例 #26
0
def hacerfft(channel):
    tamanho = len(channel)

    fdata = fft(channel)

    print('> FFT realizada')
        
    nUniquePts = int(ceil((tamanho)/2))
    fdata = fdata[0:nUniquePts]
    fdata = abs(fdata)

    fdata = fdata/float(leng)
    fdata = fdata**2

    if leng % 2 > 0:
        fdata[1:int(ceil(len(fdata)))] = fdata[1:int(ceil(len(fdata)))] * 2
    else:
        fdata[1:int(ceil(len(fdata)))-1] = fdata[1:int(ceil(len(fdata)))-1] * 2

    freqArray = arange(0, nUniquePts, 1.0)*(fs/tamanho)
    plot(freqArray/1000, 10*log10(fdata[0:tamanho:1]))

    xlabel('Frequency (kHz)')
    ylabel('Power (dB)')
    plt.show()

    print('> FFT graficada')

    return fdata
コード例 #27
0
ファイル: base.py プロジェクト: AllanRamsay/COMP34411
def hz2mel(hz):
    """Convert a value in Hertz to Mels

    :param hz: a value in Hz. This can also be a numpy array, conversion proceeds element-wise.
    :returns: a value in Mels. If an array was passed in, an identical sized array is returned.
    """
    return 2595 * pylab.log10(1+hz/700.0)
コード例 #28
0
ファイル: test_yulewalker.py プロジェクト: strawlab/spectrum
def create_figure():
    psd = test_yule()
    psd = cshift(psd, len(psd)/2) # switch positive and negative freq

    plot(linspace(-0.5, 0.5, 4096),
               10 * log10(psd/max(psd)))
    axis([-0.5,0.5,-60,0])
    savefig('psd_yulewalker.png')
コード例 #29
0
ファイル: test_filtering.py プロジェクト: schevalier/pyspace
def plot_freqz_response(b,a=1):
    w,h = scipy.signal.freqz(b,a)
    h_dB = 20 * pylab.log10 (abs(h))
    pylab.plot(w/max(w),h_dB)
    pylab.ylim(-150, 5)
    pylab.ylabel('Magnitude (db)')
    pylab.xlabel(r'Normalized Frequency (x$\pi$rad/sample)')
    pylab.title(r'Frequency response')
コード例 #30
0
    def _fetch_normalisation(self):
        # x is training
        # y is gold
        filename = self._pj([self.classpath, 'data', 'common_training.csv'])
        training = pd.read_csv(filename)

        #filename = self._pj([self.classpath, 'data', 'common_gold.csv'])
        self.download_goldstandard()
        goldfile = pd.read_csv(filename)

        #"""function [m b rho] = fetch_normalization(jj)
        #%% jj is the index of the molecule (1-7)

        colnames = self.species

        self.norm_training = pylab.log10(training[colnames] + 1)
        self.norm_gold = pylab.log10(goldfile[colnames] + 1)
コード例 #31
0
def plot_freqz_response(b, a=1):
    w, h = scipy.signal.freqz(b, a)
    h_dB = 20 * pylab.log10(abs(h))
    pylab.plot(w / max(w), h_dB)
    pylab.ylim(-150, 5)
    pylab.ylabel('Magnitude (db)')
    pylab.xlabel(r'Normalized Frequency (x$\pi$rad/sample)')
    pylab.title(r'Frequency response')
コード例 #32
0
    def process(self):
        """rearranges the ping data into a matrix of max amplitude of
        dimensions corrisponding to the power, gain and beam sections."""
        MINSAMPLES = 5
        datadim = self.pingdata.shape
        self.pingmax = pl.zeros((len(self.settings['power']), len(self.settings['gain']), datadim[2]))

        for i, power in enumerate(self.settings['power']):
            for j, gain in enumerate(self.settings['gain']):
                for k in xrange(datadim[2]):
                    sampleindx = pl.find((self.pingdata[:, 1, k]  == power) & (self.pingdata[:, 2, k] == gain))
                    if len(sampleindx)  >  MINSAMPLES:
                        temp = self.pingdata[sampleindx[-MINSAMPLES:], 0, k]
                        tempmax = temp.max()
                        if tempmax == 0:
                            self.pingmax[i, j, k] = pl.NaN
                        else:
                            self.pingmax[i, j, k] = temp.max()
                    else:
                        self.pingmax[i, j, k] = pl.NaN

        #The following section removes settings that were collected erroniously.
        #gain settings first
        null = pl.zeros((len(self.settings['gain']), datadim[2]))
        powershortlist = []
        self.havedata = True  # this is an ugly workaround...
        for i, power in enumerate(self.settings['power']):
            test = pl.isnan(self.pingmax[i, :, :] )
            if test.all():
                powershortlist.append(i)
                print 'removing ' + str(power) + ' power setting.'
        for i in powershortlist:
            try:
                self.settings['power'].pop(i)
            except IndexError:
                self.havedata = False
        if self.havedata:
            self.pingmax = pl.delete(self.pingmax, powershortlist, 0)
            #then power settings
            null = pl.zeros((len(self.settings['power']), datadim[2]))
            gainshortlist = []
            for i, gain in enumerate(self.settings['gain']):
                test = pl.isnan(self.pingmax[:, i, :])
                if test.all():
                    gainshortlist.append(i)
                    print 'removing ' + str(gain) + ' gain setting.'
            for i in gainshortlist:
                try:
                    self.settings['gain'].pop(i)
                except IndexError:
                    self.havedata = False
            if self.havedata:
                self.pingmax = pl.delete(self.pingmax, gainshortlist, 1)
                #remove the power and gain to normalize
                self.pingmax = 20*pl.log10(self.pingmax)
                for i, power in enumerate(self.settings['power']):
                    for j, gain in enumerate(self.settings['gain']):
                        self.pingmax[i, j, :] = self.pingmax[i, j, :] - power - gain
コード例 #33
0
    def __init__(self, name, version, zclust, sigmaz, alpha=50):
        self.name = name  # e.g. "NEP 200"
        self.version = version  # e.g. "nep200_v0.0.4"
        self.zclust = zclust  # cluster redshift
        self.sigmaz = sigmaz  # 1sigma scatter in (zphot-zspec)/(1+zspec)
        self.zspec_lo = 0  # lower redshift bound for specz
        self.zspec_hi = 0  # upper redshift bound for specz
        self.substructures = []

        self.cat = gunzip_read_gzip('%s/%s/%s.cat.gz' %
                                    (data_dir, version, version),
                                    readcat=1)
        #self.zout = gunzip_read_gzip('%s/%s/%s.zout.gz' % (data_dir, version, version), readzout=1)
        #self.fout = gunzip_read_gzip('%s/%s/%s.fout.gz' % (data_dir, version, version), readcat=1)

        xyrd1 = self.cat.x[0], self.cat.y[0], self.cat.ra[0], self.cat.dec[0]
        xyrd2 = self.cat.x[1], self.cat.y[1], self.cat.ra[1], self.cat.dec[1]
        d_arcsec = mypy.radec_sep(xyrd1[2], xyrd1[3], xyrd2[2], xyrd2[3])
        d_pixel = ((xyrd1[0] - xyrd2[0])**2 + (xyrd1[1] - xyrd2[1])**2)**0.5
        self.px_scale = d_arcsec / d_pixel

        ### getting z band magnitude
        try:
            self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_z)
        except:
            pass
        try:
            self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_Zplus)
        except:
            pass

        ###  setting spatial flag based on Convex Hull method
        #zspecinds = pylab.find(self.cat.z_spec > 0)
        #self.spatial_flag = checkPoint(self.cat.ra[zspecinds], self.cat.dec[zspecinds], self.cat.ra, self.cat.dec)
        #self.inds_spatial = pylab.find(self.spatial_flag == 1)

        ###  setting spatial flag based on Concave Hull method (creates a "tighter" spatial selection than Cnvex Hull)
        zspecinds = pylab.find(self.cat.z_spec > 0)
        points = pylab.array(zip(self.cat.x[zspecinds], self.cat.y[zspecinds]))
        self.concave_hull, self.edge_points = alpha_shape(points, alpha)
        self.inds_spatial = CheckPoints(self.concave_hull.buffer(10),
                                        self.cat.x, self.cat.y)
        self.area_pix2 = self.concave_hull.buffer(10).area
        self.area_arcmin2 = self.area_pix2 * (self.px_scale / 60.)**2
        print ''
コード例 #34
0
ファイル: on_key.py プロジェクト: nbigaouette/libpotentials
def on_key(event):
    #print 'you pressed', event.key, event.xdata, event.ydata
    if   (event.key == 'q'):
        sys.exit(0)
    #
    elif (event.key == 'w'):
        pylab.close(event.canvas.figure)
    #
    elif (event.key == 'd'):
        print "##############################################################"
        print "Please click two points to get the distance and slope."
        from matplotlib.widgets import Cursor
        cursor = Cursor(event.inaxes, useblit=False, color='red', linewidth=1)
        points = pylab.ginput(n=2, show_clicks=True, timeout=0)
        xs  = pylab.array([points[0][0], points[1][0]])
        ys  = pylab.array([points[0][1], points[1][1]])
        dx = xs[1] - xs[0]
        dy = ys[1] - ys[0]
        dy_log = pylab.log10(ys[0]) - pylab.log10(ys[1])
        dy_ln = pylab.log(ys[0]) - pylab.log(ys[1])
        angle = pylab.arctan2(dy, dx)
        print "points = ", points
        print "distance (x) =", dx
        print "distance (y) =", dy
        print "distance =", pylab.sqrt( dx**2 + dy**2 )
        print "Ratio: x0/x1 =", xs[0] / xs[1], "   x1/x0 =", xs[1] / xs[0], "  y0/y1 =", ys[0] / ys[1], "  y1/y0 =", ys[1] / ys[0]
        print "dy/y0 = ", dy/ys[0]
        print "dx/x0 = ", dx/xs[0]
        print "Angle: theta = atan2(y/x) =", angle, "rad =", angle*180.0/pylab.pi, "deg"
        print "Slope: ", dy/dx, "  1/slope =", dx/dy
        print "Slope (log10 scale):", dy_log/dx
        print "Slope (ln scale):",    dy_ln/dx
        event.inaxes.plot([points[0][0], points[1][0]], [points[0][1], points[1][1]], '--r', lw=1.0)
        event.inaxes.plot([points[0][0], points[1][0]], [points[0][1], points[1][1]],  '+r', lw=1.0)
        pylab.draw()
    #
    elif (event.key == 'a'):
        print "##############################################################"
        print "Please click a point to get the position."
        from matplotlib.widgets import Cursor
        cursor = Cursor(event.inaxes, useblit=False, color='red', linewidth=1)
        point = pylab.ginput(n=1, show_clicks=False, timeout=0)
        print "point = ", point
        event.inaxes.plot(point[0][0], point[0][1],  '+r', lw=1.0)
        pylab.draw()
コード例 #35
0
 def _set_scatter(self):
     filename = self.caller.prefix + "results.csv"
     df = pd.read_csv(filename)
     df["log_ttest"] = -pylab.log10(df["ttest"])
     df["markersize"] = 20
     js = ScatterJS(df, x="Rp", y="log_ttest", color="bayes", size="markersize" )
     js.xlabel = "Regression coefficient"
     js.ylabel = "log10(ttest pvalue)"
     self.jinja['volcano_jsdata'] = js.get_html()
コード例 #36
0
ファイル: TeraData.py プロジェクト: DavidJahn86/terapy
    def getBandwidth(self,dbDistancetoNoise=15):
        #this function should return the lowest trustable and highest trustable
        #frequency, along with the resulting bandwidth
        
        absdata=-20*py.log10(self.getFAbs()/max(self.getFAbs()))
        ix=self.maxDR-dbDistancetoNoise>absdata #dangerous, due to sidelobes, there might be some high freq component!
        tfr=self.getfreqs()[ix]

        return min(tfr),max(tfr)
コード例 #37
0
def error_label(norm, maxnorm, xpos, ypos):
    vexp =  pylab.floor( pylab.log10( norm ) )
    if norm == 0: vexp = 0
    vmant = norm / 10**vexp
    thistext = r'$\Vert$E$\Vert_1 = \, %4.2f' % vmant
    if vexp != 0:
        thistext += r' \times \, 10^{%2d}' % vexp
    thistext += '$\n'

    vexp =  pylab.floor( pylab.log10( maxnorm ) )
    if maxnorm == 0: vexp = 0
    vmant = maxnorm / 10**vexp
    thistext += r'$\Vert$E$\Vert_\infty \! = \, %4.2f' % vmant
    if vexp != 0:
        thistext += r' \times \, 10^{%2d}' % vexp
    thistext += '$'

    pylab.text(xpos, ypos, thistext, va='top')
コード例 #38
0
def mu_ev(t):
    """
    Remaining mass fraction due to stellar evolution 
    (equations 2 & 3 and Table 1 in L05)
    """
    a_ev, b_ev, c_ev = 7, 0.255, -1.805
    q_ev = 0 if t < 12.5e6 else 10**((log10(t) - a_ev)**b_ev + c_ev)
    mu_ev = 1 - q_ev
    return mu_ev
コード例 #39
0
def plotFrequency(series, sampRate):
    """ Plot a frequency to a graph """
    s = series / (2.**15)
    p, freqArray = _fastFourier(s, sampRate)
    np.plot(freqArray / 1000, 10 * pl.log10(p), color='k')
    np.xlabel('Frequency (kHz)')
    np.ylabel('Power (dB)')
    np.plt.show()
    return
コード例 #40
0
ファイル: pt.py プロジェクト: jizhi/project_TL
    def deltac(self, z):
        """
        calculate delta_collapse (the number that's ~1.686 for E-dS)
        Taken from Nakamura and Suto, 1997
        """
        deltac0 = 3.0 * (12.0 * M.pi) ** (2.0 / 3.0) / 20.0 * (1.0 + 0.0123 * M.log10(self.om0z(z)))
        deltac = deltac0 * self.d1(0) / self.d1(z)

        return deltac
コード例 #41
0
def plot_fit(pop1, pop2):
    pop_fraction_selected = [ [pop,fraction] for pop,fraction in zip(bins,n) if pop > pop1 and pop < pop2]
    pop_selected = [ p for p,f in pop_fraction_selected ]
    fraction_selected = [ f for p,f in pop_fraction_selected ]

    pop_selected = pop_selected[1:]
    fraction_selected = fraction_selected[1:]

    x = P.log10(pop_selected)
    y = P.log10(fraction_selected)

    a,b = np.polyfit(x,y,1)
    print a,b

    x = pop_selected
    y = [10**b*xx**a for xx in x]

    P.loglog(x,y)
コード例 #42
0
ファイル: mls.py プロジェクト: goiosunsw/absorption
def main(nbits):
    """Main Program"""
    import pylab
    nbits = int(nbits)
    m = mls(nbits)
    fm = pylab.fft(m)
    fig, ax = pylab.subplots(2, sharex=True)
    ax[0].plot(20 * pylab.log10(numpy.abs(fm)))
    ax[1].plot(numpy.angle(fm))
コード例 #43
0
def flux_density(source='3C147', f=1.4):
    '''
	This returns the flux density for the calibrator sources listed below. 3C147 is a default. 
	source='3C147', f=frequency in GHz.
	The flux density of 3C147 and 3C286 is taken from the VLA calibrators manual 
	( http://www.vla.nrao.edu/astro/calib/manual/baars.html ):
		  Source       A 	B 	  C 	    D
        	  3C48         1.31752  -0.74090  -0.16708  +0.01525
        	  3C138        1.00761  -0.55629  -0.11134  -0.01460
	          3C147        1.44856  -0.67252  -0.21124  +0.04077
	          3C286        1.23734  -0.43276  -0.14223  +0.00345
        	  3C295        1.46744  -0.77350  -0.25912  +0.00752
	'''
    if source.upper() == '3C147':
        A = 1.44856
        B = -0.67252
        C = -0.21124
        D = +0.04077
    logs = A + B * pl.log10(f) + C * pl.log10(f)**2 + D * pl.log10(f)**3
    return 10**logs
コード例 #44
0
def Sol_prod(T):
    bo = -.77712
    b1 = 0.0028426
    b2 = 178.34
    co = -.07711
    do = .0041249
    S = 35
    (bo + b1 * T + b2 / T) * S**0.5 + co * S + do * S**1.5
    logK0 = -171.9065 - 0.077993 * T + 2839.319 / T + 71.595 * pylab.log10(T)
    logK = logK0 + (bo + b1 * T + b2 / T) * S**0.5 + co * S + do * S**1.5
    return 10**logK
コード例 #45
0
def zipf(file, length):
    words = word_count(file, length)
    x = [x + 1 for x in range(length)]
    y1 = [math.log10(word[1]) for word in words]
    pylab.plot(x, y1, 'b-', label='Actual Frrequency')

    y2 = y1[0] - pylab.log10(x)
    pylab.plot(x, y2, 'r--', label='Theoretical Frequency')

    pylab.legend()
    pylab.show
コード例 #46
0
	def __init__(self, name, version, zclust, sigmaz):
		self.name = name          # e.g. "NEP 200"
		self.version = version    # e.g. "nep200_v0.0.4"
		self.zclust = zclust      # cluster redshift
		self.sigmaz = sigmaz      # 1sigma scatter in (zphot-zspec)/(1+zspec)
		self.zspec_lo = 0         # lower redshift bound for specz
		self.zspec_hi = 0         # upper redshift bound for specz
		self.substructures = []

		self.cat = gunzip_read_gzip('%s/%s/%s.cat.gz' % (data_dir, version, version), readcat=1)
		self.zout = gunzip_read_gzip('%s/%s/%s.zout.gz' % (data_dir, version, version), readzout=1)
		self.fout = gunzip_read_gzip('%s/%s/%s.fout.gz' % (data_dir, version, version), readcat=1)

		### getting z band magnitude
		try: self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_z)
		except: pass
		try: self.zmagnitude = 25 - 2.5 * pylab.log10(self.cat.fluxauto_Zplus)
		except: pass

		print ''
コード例 #47
0
def save_2D_movie(frame_list, filename, frame_duration):
    """
    Saves a list of 2D numpy arrays of gray shades between 0 and 1 to a zipped tree of PNG files.
    
    Inputs:
        frame_list     - a list of 2D numpy arrays of floats between 0 and 1
        filename       - string specifying the filename where to save the data, has to end on '.zip'
        frame_duration - specifier for the duration per frame, will be stored as additional meta-data
        
    Example:
        >> import numpy
        >> framelist = []
        >> for i in range(100): framelist.append(numpy.random.random([100,100])) # creates a list of 2D numpy arrays with random values between 0. and 1.
        >> save_2D_movie(framelist, 'randommovie100x100x100.zip', 0.1)
    """
    try:
        import zipfile
    except ImportError:
        raise ImportError(
            "ERROR: Python module zipfile not found! Needed by NeuroTools.plotting.save_2D_movie(...)!"
        )
    try:
        import StringIO
    except ImportError:
        raise ImportError(
            "ERROR: Python module StringIO not found! Needed by NeuroTools.plotting.save_2D_movie(...)!"
        )
    assert PILIMAGEUSE, "ERROR: Since PIL has not been detected, the function NeuroTools.plotting.save_2D_movie(...) is not supported!"
    filenameConditionStr = "ERROR: Second argument of function NeuroTools.plotting.save_2D_movie(...) must be a string ending on \".zip\"!"
    assert (type(filename) == str) and (len(filename) > 4) and (
        filename[-4:].lower() == '.zip'), filenameConditionStr
    zf = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED)
    container = filename[:-4]  # remove .zip
    frame_name_format = "frame%s.%dd.png" % (
        "%", pylab.ceil(pylab.log10(len(frame_list))))
    for frame_num, frame in enumerate(frame_list):
        frame_data = [(p, p, p) for p in frame.flat]
        im = Image.new('RGB', frame.shape, 'white')
        im.putdata(frame_data)
        io = StringIO.StringIO()
        im.save(io, format='png')
        pngname = frame_name_format % frame_num
        arcname = "%s/%s" % (container, pngname)
        io.seek(0)
        zf.writestr(arcname, io.read())
        progress_bar(float(frame_num) / len(frame_list))

    # add 'parameters' and 'frames' files to the zip archive
    zf.writestr("%s/parameters" % container,
                'frame_duration = %s' % frame_duration)
    zf.writestr(
        "%s/frames" % container,
        '\n'.join(["frame%.3d.png" % i for i in range(len(frame_list))]))
    zf.close()
コード例 #48
0
ファイル: toolbox_ctrl.py プロジェクト: YannicLight/m3meka
def plot_bode_simple(freq, p2p, amp, ptitle='Bode'):
    gain = nu.array(p2p) / amp
    cutoff = nu.array([-3] *
                      len(gain))  #70.7% : 10^-.15 : 20*log10(10^-.15)=-3
    semilogx(freq, 20 * pylab.log10(gain))
    semilogx(freq, cutoff, 'r-')
    ylabel('Mag. Ratio (dB)')
    xlabel('Freq. (Hz)')
    title(ptitle)
    grid(True)
    show()
コード例 #49
0
 def make_histogram(self):
     edges = []
     # Set up evenly spaced bins and determine their centers
     if (self.binstyle == "log"):
         edges = 10.0**N.linspace(P.log10(self.lowedge),
                                  P.log10(self.highedge), self.bincount + 1)
         self.centers = N.sqrt(edges[1:] * edges[:-1])
     else:
         edges = N.linspace(self.lowedge, self.highedge, self.bincount + 1)
         self.centers = 0.5 * (edges[1:] + edges[:-1])
     self.widths = (edges[1:] - edges[:-1])
     # Make the histogram and error histogram
     self.ndata, temp = N.histogram(self.data,
                                    bins=edges,
                                    weights=self.weights)
     sqweights = [i * i for i in self.weights]
     self.nweights, temp = N.histogram(self.data,
                                       bins=edges,
                                       weights=sqweights)
     self.errors = N.sqrt(self.nweights)
コード例 #50
0
ファイル: methanol.py プロジェクト: SDRAST/Physics
def plot_A_transitions(A_transitions, Amin, Amax, color=True, logA=True):
    """
  Plot the radiative decays in the list A_transitions. Amin and Amax are the
  rates for the bottom and top of the color bar. By default the logarithm of
  the rates are printed as colors.  If color is false, the rate or logarithm
  of the rate is plotted as a black line with the linewidth proportional to
  the rate.
  """
    for trans in A_transitions:
        Elo = float(trans['E lower'])
        f = float(trans['freq'])
        Eup = Elo + f * MHz2invCm
        A = koln.einstein_a(f, float(trans['str']), int(trans['g upper']))
        if logA == True:
            rate = py.log10(A)
        else:
            rate = A
        lineColor = C.strRgb(rate, Amin, Amax)
        # Plot separated lines for A+ and A- states
        # lower level
        if trans['q lower'][1] == '0':
            # for K=0 there is no distinction. Plot from/to level centers
            klo = int(trans['q lower'][1])
        elif trans['q lower'][3] == '+0':
            # A+ on the left
            klo = int(trans['q lower'][1]) - 0.2
        elif trans['q lower'][3] == '-0':
            # A- on the right
            klo = int(trans['q lower'][1]) + 0.2
        # upper level
        if trans['q upper'][1] == '0':
            # K=0, plot between line centers
            kup = int(trans['q upper'][1])
        elif trans['q upper'][3] == '+0':
            # A- on the left
            kup = int(trans['q upper'][1]) - 0.2
        elif trans['q upper'][3] == '-0':
            # A+ on the right
            kup = int(trans['q upper'][1]) + 0.2
        if color == True:
            if rate > Amin:
                # double width lines above the minimum value
                py.plot([kup, klo], [Eup, Elo], '-', lw=2, c=lineColor)
            else:
                # single width lines below the minimum value
                py.plot([kup, klo], [Eup, Elo],
                        '-',
                        lw=1,
                        c=C.strRgb(Amin, Amin, Amax))
        else:
            if rate > Amin:
                linew = 3 * (rate - Amin) / (Amax - Amin)
                py.plot([kup, klo], [Eup, Elo], '-', lw=linew, c='k')
コード例 #51
0
ファイル: fircalc.py プロジェクト: ivanovev/alt
 def plot_upd_mfreqz(self, fig, taps, a=1):
     if not signal:
         return
     self.plot_init_mfreqz(fig)
     ax1, ax2 = fig.get_axes()
     w, h = signal.freqz(taps, a)
     if sum(abs(h)) == 0:
         return
     h_dB = 20 * pylab.log10(abs(h))
     ax1.plot(w / max(w), h_dB)
     h_Phase = pylab.unwrap(pylab.arctan2(pylab.imag(h), pylab.real(h)))
     ax2.plot(w / max(w), h_Phase)
コード例 #52
0
 def plot_scores(self, filename=None, savefig=False):
     # scores
     from pylab import log10
     pylab.clf()
     pylab.plot(log10(self.df.query('score>540')['rep1_signal']),
                log10(self.df.query('score>540')['rep2_signal']),
                'ko',
                alpha=0.5,
                label='<0.05 IDR')
     pylab.plot(log10(self.df.query('score<540')['rep1_signal']),
                log10(self.df.query('score<540')['rep2_signal']),
                'ro',
                alpha=0.5,
                label='>=0.05 IDR')
     N = pylab.ylim()[1]
     pylab.plot([0, N], [0, N], color='blue', alpha=0.5, ls='--')
     pylab.xlabel("Rep1 log10 score")
     pylab.ylabel("Rep2 log10 score")
     pylab.legend(loc='lower right')
     if savefig:
         pylab.savefig(filename)
コード例 #53
0
 def save_sonogram(self, replace=False, n_fft=settings.N_FFT, \
     min_freq=settings.MIN_FREQ, \
     max_freq=settings.MAX_FREQ, \
     dpi=100,
     width=1000,
     height=350,
     max_framerate=settings.MAX_FRAMERATE):
     filename = self.get_sonogram_name()
     name = os.path.join(settings.SONOGRAM_DIR, filename)
     path = os.path.join(settings.MEDIA_ROOT, name)
     try:
         if not os.path.exists(path):
             replace = True
     except (ValueError, SuspiciousOperation, AttributeError):
         replace = True
     if replace:
         audio, framerate = self.get_audio(max_framerate=max_framerate)
         Pxx, freqs, bins, im = specgram(audio, NFFT=n_fft, Fs=framerate)
         f = where(logical_and(freqs > min_freq, freqs <= max_freq))[0]
         Pxx[where(Pxx > percentile(Pxx[f].flatten(), 99.99))] = percentile(
             Pxx[f].flatten(), 99.99)
         Pxx[where(Pxx < percentile(Pxx[f].flatten(), 0.01))] = percentile(
             Pxx[f].flatten(), 0.01)
         clf()
         fig = figure(figsize=(float(width) / dpi, float(height) / dpi),
                      dpi=dpi)
         imshow(flipud(10 * log10(Pxx[f, ])),
                extent=(bins[0], bins[-1], freqs[f][0], freqs[f][-1]),
                aspect='auto',
                cmap=cm.gray)
         gca().set_ylabel('Frequency (Hz)')
         gca().set_xlabel('Time (s)')
         axis_pixels = gca().transData.transform(
             np.array((gca().get_xlim(), gca().get_ylim())).T)
         st, created = SonogramTransform.objects.get_or_create(
             n_fft=n_fft,
             framerate=framerate,
             min_freq=min_freq,
             max_freq=max_freq,
             duration=self.duration,
             width=width,
             height=height,
             dpi=dpi,
             top_px=max(axis_pixels[:, 1]),
             bottom_px=min(axis_pixels[:, 1]),
             left_px=min(axis_pixels[:, 0]),
             right_px=max(axis_pixels[:, 0]),
         )
         savefig(open(path, 'wb'), format='jpg', dpi=dpi)
         sonogram, created = Sonogram.objects.get_or_create(snippet=self,
                                                            transform=st,
                                                            path=name)
         close()
コード例 #54
0
def Sol_prod(
        T
):  # from appendix G Pilson book, reproduces table G.1 for salinity=35
    bo = -.77712
    b1 = 0.0028426
    b2 = 178.34
    co = -.07711
    do = .0041249
    S = 35
    (bo + b1 * T + b2 / T) * S**0.5 + co * S + do * S**1.5
    logK0 = -171.9065 - 0.077993 * T + 2839.319 / T + 71.595 * pylab.log10(T)

    logK = logK0 + (bo + b1 * T + b2 / T) * S**0.5 + co * S + do * S**1.5
    return 10**logK
コード例 #55
0
def test_periodogram_real_vs_octave():
    # the periodogram is tested against the octave output that is "identical"
    # for the following real example
    import numpy as np
    PSDs = []
    for this in range(100):
        xx = data_two_freqs()
        p = Periodogram(xx, 4, window="hanning")
        p()
        PSDs.append(p.psd)
    M = 10 * log10(np.mean(PSDs, axis=0))
    assert max(M) > 10  # 10.939020375396096

    assert np.mean(M[M < -35]) > -50
    assert np.mean(M[M < -35]) < -40
コード例 #56
0
ファイル: hole_post.py プロジェクト: vahidzrad/git_hf
def EllipticSlope():

    rho_list = [0.5]
    Roell_list = pl.logspace(pl.log10(0.1), pl.log10(50), 20)
    markers = ["bo-", "gv-", "r>-"]

    for i, rho in enumerate(rho_list):
        tf_list = []
        te_list = []
        for Roell in Roell_list:
            ell = 1 / Roell
            te, tf = find_data(
                ["material.ell", "problem.rho", "problem.hsize"],
                [ell, rho, 1e-3])
            te_list.append(te)
            tf_list.append(tf)

        pl.figure(i)
        pl.loglog(Roell_list, tf_list, markers[i], label=r"$\rho=%g$" % (rho))

        ind1 = 8
        ind2 = 5
        coeff = pl.polyfit(pl.log(Roell_list[ind1:-ind2]),
                           pl.log(tf_list[ind1:-ind2]), 1)
        poly = pl.poly1d(coeff)
        fit = pl.exp(poly(pl.log(Roell_list[ind1:-ind2])))
        print("The slope = %.2e" % (coeff[0]))
        pl.loglog(Roell_list[ind1:-ind2], fit, "k-", linewidth=3.0, alpha=0.2)

        pl.xlabel(r"Relative defect size $a/\ell$")
        pl.ylabel("$\sigma/\sigma_0$ at fracture")
        pl.legend(loc="best")
        pl.xlim([9e-2, 1e2])
        pl.grid(True)
        pl.savefig("elliptic_rho_" + str(rho).replace(".", "x") + ".pdf",
                   bbox_inches='tight')
コード例 #57
0
def schechter_mf_log(xaxis, alpha, mstar, phistar):
    """
    #  DESCRIPTION:
    #    Returns the values for a Schechter mass function
    #    from a given mass-axis and Schechter parameters.
    #
    #  INPUTS:
    #    xaxis = input mass value(s)
    #    alpha = Schechter parameters
    #    mstar = Schechter parameters
    #    phistar = Schechter parameters    
    """
    return pylab.log10(
        pylab.log(10) * phistar * 10**((xaxis - mstar) * (1 + alpha)) *
        pylab.exp(-10**(xaxis - mstar)))
コード例 #58
0
    def imshow(self, log=True, **kwargs):
        """show the detector science frame as an image"""

        v = self.sci.copy()
        v[v == 0] = 1.0

        if log is True:
            v = log10(v)

        pylab.imshow(v,
                     cmap=cm.gray,
                     origin='lower',
                     interpolation='nearest',
                     **kwargs)
        pylab.colorbar()
コード例 #59
0
def clim_fun_highCH4(CO2, S):
    # polynomial coefficients from fit to 1-D climate model:
    coeff = np.array([
        -7.54993474e+00, -1.56537857e+02, 1.09569449e+03, -4.23166796e+01,
        3.33328419e+02, -5.36250637e+02, -1.24044934e+03, -1.54156844e+03,
        1.04071399e+03, -1.46500650e+00, 2.45480651e+01, 5.13587132e+02,
        -4.87777690e+01, 2.51789370e+02, 2.63929259e+01, 6.86937462e+02
    ])
    x = pylab.log10(CO2)  # polynomial fit done in log space
    y = S
    inputs = [
        x * 0 + 1, x, y, x**2, x**2 * y, x**2 * y**2, y**2, x * y**2, x * y,
        x**3, x**3 * y**3, y**3, x**3 * y**2, x**2 * y**3, x**3 * y, x * y**3
    ]
    return np.sum(coeff * inputs)
コード例 #60
0
def main():

    path = "../../example/"
    #samplingRate, s1 = wavfile.read(path + '440_sine.wav')
    samplingRate, s1 = wavfile.read(path + '12000hz.wav')
    
    if len(s1.shape) == 2:
        s1 = s1[:,0]
    
    if len(s1) > 8192:
        s1 = s1[:256]
    
    n = float(len(s1))
    
    print "DType %s" % s1.dtype
    print "Sound File Shape " + str(s1.shape)
    print "Sample Frequency / Entries: %.2f / %.2f" % (samplingRate, n)
    print "Duration %.2f ms" % ((n / samplingRate)*1000)
    
    s1 = s1 / (2.**15)
    # Plotting the Tone
    timeArray = arange(0, n, 1)
    timeArray = timeArray / samplingRate
    timeArray = timeArray * 1000  #scale to milliseconds
    
    _, (axTone, axFreq, axLogFreq) = subplots(3)
    axTone.plot(timeArray, s1, color='k')
    ylabel('Amplitude')
    xlabel('Time (ms)')
    
    
    #Plotting the Frequency Content
    nUniquePts, p = getFFT(s1, n)
    #nUniquePts, p = getFFTUtil(s1, n)
    
    freqArray = arange(0, nUniquePts, 1.0) * (samplingRate / n);
    
    print "FreqMax %fHz" % freqArray[np.argmax(p)]
    
    axFreq.plot(freqArray/1000, p, color='k')
    axLogFreq.plot(freqArray/1000, 10*log10(p), color='k')
    
    
    xlabel('Frequency (kHz)')
    ylabel('Power (dB)')
    show()