How to read wav file using scipylab in Python?
Hi folks... Can you please help me with this? ...
Hi folks... Can you please help me with this? ...
HI folks. I have difficulty in installing these items in Ubuntu.......plz help me as soon as possible.iam experiencing errors such as no module name found......sometimes certain libraries are not found.......plz folks can all of u state the basic libraries required for installing these items and where to find them ...
I need to create a numpy 2D array which represents a binary mask of a polygon, using standard Python packages. input: polygon vertices, image dimensions output: binary mask of polygon (numpy 2D array) (Larger context: I want to get the distance transform of this polygon using scipy.ndimage.morphology.distance_transform_edt.) Can any...
I am working with a 2D Numpy masked_array in Python. I need to change the data values in the masked area such that they equal the nearest unmasked value. NB. If there are more than one nearest unmasked values then it can take any of those nearest values (which ever one turns out to be easiest to code…) e.g. import numpy import numpy.m...
please help me with an example ...
The numpy documentation shows an example of masking existing values with ma.masked a posteriori (after array creation), or creating a masked array from an list of what seem to be valid data types (integer if dtype=int). I am trying to read in data from a file (and requires some text manipulation) but at some point I will have a list of l...
Hi, I have the following code in Python using Numpy: p = np.diag(1.0 / np.array(x) How can I transform it to get the sparse matrix p2 with the same values as p without creating p first? Thanks! ...
If I wanted to make a combined image like the one shown below (original source here), could you point me to the matplotlib objects do I need to assemble? I've been trying to work with AxesImage objects and I've also downloaded SciKits Timeseries - but do I need this, or can is it as easy to use strptime, mktime, and strftime from the t...
How do I invert a color mapped image? I have a 2D image which plots data on a colormap. I'd like to read the image in and 'reverse' the color map, that is, look up a specific RGB value, and turn it into a float. For example: using this image: http://matplotlib.sourceforge.net/_images/mri_demo.png I should be able to get a 440x360 ma...
Hi, I wonder if it is possible to exactly reproduce the whole sequence of randn() of MATLAB with NumPy. I coded my own routine with Python/Numpy, and it is giving me a little bit different results from the MATLAB code somebody else did, and I am having hard time finding out where it is coming from because of different random draws. I h...
This is a similar question using dtypes in a list The following snippet creates a "typical test array", the purpose of this array is to test an assortment of things in my program. Is there a way or is it even possible to change the type of elements in an array? import numpy as np import random from random import uniform, randrange, c...
I'm not sure if my post question makes lots of sense; however, I'm building an input array for a class/function that takes in a lot of user inputed data and outputs a numpy array. # I'm trying to build an input array that should include following information: ''' * zone_id - id from db - int * model size - int * type of analysis - o...
I have a real vector time series x of length T and a filter h of length t << T. h is a filter in fourier space, real and symmetric. It is approximately 1/f. I would like to filter x with h to get y. Suppose t == T and FFT's of length T could fit into memory (neither of which are true). To get my filtered x in python, I would do: impor...
Hi, I have a set of png images that I would like to process with Python and associated tools. Each image represents a physical object with known dimensions. In each image there is a specific feature of the object at a certain pixel/physical location. The location is different for each image. I would like to impose a polar coordinate s...
I am running Python 2.6.5 on Mac OS X 10.6.4 (this is not the native version, I installed it myself) with Scipy 0.8.0. If I do the following: >>> from scipy.stats import hypergeom >>> hypergeom.sf(5,10,2,5) I get an IndexError. Then I do: >>> hypergeom.sf(2,10,2,2) -4.44.... I suspect the negative value is due to bad floating point...
I'd like to plot a normalized histogram from a vector using matplotlib. I tried the following: plt.hist(myarray, normed=True) as well as: plt.hist(myarray, normed=1) but neither option produces a y-axis from [0, 1] such that the bar heights of the histogram sum to 1. I'd like to produce such a histogram -- how can I do it? thanks...
Hi all, I want to use scipy.spatial's KDTree to find nearest neighbor pairs in a two dimensional array (essentially a list of lists where the dimension of the nested list is 2). I generate my list of lists, pipe it into numpy's array and then create the KDTree instance. However, whenever I try to run "query" on it, I inevitably get weir...
I have been unable to find this function in any of the standard packages, so I wrote the one below. Before throwing it toward the Cheeseshop, however, does anyone know of an already published version? Alternatively, please suggest any improvements. Thanks. def fivenum(v): """Returns Tukey's five number summary (minimum, lower-hinge...
Hi! In my application, the data data is sampled on a distorted grid, and I would like to resample it to a nondistorted grid. In order to test this, I wrote this program with examplary distortions and a simple function as data: from __future__ import division import numpy as np import scipy.interpolate as intp import pylab as plt # De...
Hi, I'm trying to use numpy.optimize.curve_fit to estimate the frequency and phase of an on/off sequence. This is the code I'm using: from numpy import * from scipy import optimize row = array([0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0...