creating a numpy vector using 3 components
I want to create a vector in numpy using 3 components Vx, Vy, Vz as sown below. Can anyone help? Thank you from numpy import cos, sin Vx = cos(alpha)* cos(beta) Vy = sin(alpha)*cos(beta) Vz = sin(beta) ...
I want to create a vector in numpy using 3 components Vx, Vy, Vz as sown below. Can anyone help? Thank you from numpy import cos, sin Vx = cos(alpha)* cos(beta) Vy = sin(alpha)*cos(beta) Vz = sin(beta) ...
I am trying to read a *.wav file using scipy. I do it in the following way: import scipy.io x = scipy.io.wavfile.read('/usr/share/sounds/purple/receive.wav') As a result I get the following error message: Traceback (most recent call last): File "test3.py", line 1, in <module> import scipy.io File "/usr/lib/python2.5/site-pack...
Many array methods return a single index despite the fact that the array is multidimensional. For example: a = rand(2,3) z = a.argmax() For two dimensions, it is easy to find the matrix indices of the maximum element: a[z/3, z%3] But for more dimensions, it can become annoying. Does Numpy/Scipy have a simple way of returning the in...
I write scientific software in Numpy/Scipy/Matplotlib. Having developed applications on my home computer, I am now interested in writing simple web applications. Example: user uploads image or audio file, my program processes it using Numpy/Scipy, and output is displayed on the browser using Matplotlib, or perhaps the user can download a...
Let's say I have a 2D Numpy array: >>> a = np.random.random((4,6)) and I want to add a 1D array to each row: >>> c = np.random.random((6,)) >>> a + c This works. Now if I try adding a 1D array to each column, I get an error: >>> b = np.random.random((4,)) >>> a + b Traceback (most recent call last): File "<stdin>", line 1, in <m...
Hello, I generate a list of one dimensional numpy arrays in a loop and later convert this list to a 2d numpy array. I would've preallocated a 2d numpy array if i knew the number of items ahead of time, but I don't, therefore I put everything in a list. The mock up is below: >>> list_of_arrays = map(lambda x: x*ones(2), range(5)) >>> l...
I am trying to select specific column elements for each row of a numpy array. For example, in the following example: In [1]: a = np.random.random((3,2)) Out[1]: array([[ 0.75670668, 0.1283942 ], [ 0.51326555, 0.59378083], [ 0.03219789, 0.53612603]]) I would like to select the first element of the first row, the secon...
I have about a 100 csv files each 100,000 x 40 rows columns. I'd like to do some statistical analysis on it, pull out some sample data, plot general trends, do variance and R-square analysis, and plot some spectra diagrams. For now, I'm considering numpy for the analysis. I was wondering what issues should I expect with such large files...
What is a good way to bin numerical values into a certain range? For example, suppose I have a list of values and I want to bin them into N bins by their range. Right now, I do something like this: from scipy import * num_bins = 3 # number of bins to use values = # some array of integers... min_val = min(values) - 1 max_val = max(value...
I am looking for the optimal (fastest) way to find the exact overlap between two arrays in numpy. Given two arrays x and y x = array([1,0,3,0,5,0,7,4],dtype=int) y = array([1,4,0,0,5,0,6,4],dtype=int) What I want to get is, an array of the same length that contains only the numbers from both vectors that are equal: array([1,0,0,0,5,0...
This might be extremely trivial, and if so I apologise, but I'm getting really confused with the outputs I'm getting: hex? decimal? what? Here's an example, and what it returns: >>> print 'Rx State: ADC Clk=', ADC_Clock_MHz,'MHz DDC Clk=', DDC_Clock_kHz,'kHz Temperature=', Temperature,'C' Rx State: ADC Clk= [1079246848L, 0L] MHz DDC Cl...
I'm using numpy to initialize a pixel array to a gray checkerboard (the classic representation for "no pixels", or transparent). It seems like there ought to be a whizzy way to do it with numpy's amazing array assignment/slicing/dicing operations, but this is the best I've come up with: w, h = 600, 800 sq = 15 # width of each checke...
I'm using numpy to build pixel arrays. An 800x600 image is an 3-dimensional array of uint8, 800x600x3. I also have a similar array with a fixed pattern (a checkerboard, see here). I have another array, 800x600 of mask values. Where the mask is zero, I want to copy the pattern pixel to the image pixel. Where the mask is not zero, I wa...
NumPy installer can't find python path in the registry. Cannot install Python version 2.5 required, which was not found in the registry. OK I have to modify the registry? I already modified %PATH% to point to the Python25 installation directory. ...
Hello, i am trying to subistute a small bit of Python Code with Cython for a speed up. While Cython itself dosen't complain, but gcc does. from __future__ import division import numpy cimport numpy cimport cython def calc_shg(numpy.ndarray[numpy.complex128_t, ndim = 1] par, numpy.ndarray[numpy.complex128_t, ndim = 1]...
I had a working installation of NLTK (py26-nltk) on my Mac (OS X 10.6.2). Then I installed numpy. Now when I try to import nltk, I get this: >>> import nltk Traceback (most recent call last): File "<stdin>", line 1, in <module> File "nltk/__init__.py", line 83, in <module> from collocations import * File "nltk/collocations.py"...
hello everyone, I have a file of lines and this in turn saves information, speed, timing and type of surfaces for each line. I want to do is sort this information in a np.array in the order shown below where the id is the number of the line. (id) 0 1 2 3 4 5 6 7 8 9 0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 1 t1 t2 t3 ...
Given this 3D bar graph sample code, how would you convert the numerical data in the x-axis to formatted date/time strings? I've attempted using the ax.xaxis_date() function without success. I also tried using plot_date(), which doesn't appear to work for 3D bar graphs. Here is a modified version of the sample code to illustrate what I a...
I'd like to improve the performance of convolution using python, and was hoping for some insight on how to best go about improving performance. I am currently using scipy to perform the convolution, using code somewhat like the snippet below: import numpy import scipy import scipy.signal import timeit a=numpy.array ( [ range(1000000)...
I have a conjunctive probability mass function array, with shape, for example (1,2,3,4,5,6) and I want to calculate the probability table, conditional to a value for some of the dimensions (export the cpts), for decision-making purposes. The code I came up with at the moment is the following (the input is the dictionary "vdict" of the f...