I must use a commercial Java library, and would like to do it from Python. Jython is robust and I am fine with it being a few dot releases behind. However, I would like to use NumPy as well, which obviously does not work with Jython. Options like CPype and Java numeric libraries are unappealing. The former is essentially dead. The latter...
When running
sphinx-build . html/
in my doc/ directory, I get the following output:
$ sphinx-build . html/
Running Sphinx v0.6.4
No builder selected, using default: html
loading pickled environment... done
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sour...
The Question:
What is the best way to calculate inverse distance weighted (IDW) interpolation in Python, for point locations?
Some Background:
Currently I'm using RPy2 to interface with R and it's gstat module. Unfortunately, the gstat module conflicts with arcgisscripting which I got around by running RPy2 based analysis in a separate...
for example, there is a matrix:
import numpy as np
A = np.array([[ 8. , -6. , 2. ],
[-0.5, 8. , -6. ],
[ 0.5, -0.5, 2. ]])
It's a LU Decomposition (Doolittle’s decomposition) result.(A = [L\U])
I want to get L and U from A.
U should be:
U = np.array([[ 8., -6., 2.],
[ 0., 8., -6.],
...
I have a MacBook Pro with Snow Leopard, and the Python 2.6 distribution that comes standard. Numpy does not work properly on it. Loadtxt gives errors of the filename being too long, and getfromtxt does not work at all (no object in module error). So then I tried downloading the py26-numpy port on MacPorts. Of course when I use python...
I have an implicit function, for example:
f(x,y) = x**y + y**y - 3*x
I want to solve the root on a meshgrid. So f(x,y) = 0
Drawing the solution is easy:
x = linspace(-2,2,11)
y = linspace(-2,2,11)
(X,Y) = meshgrid(x,y)
A = X**Y + Y**Y - 3*X
contour(X,Y,A,0)
This works great, I have a drawing of the curve I need, however I would l...
The following program loads two images with PyGame, converts them to Numpy arrays, and then performs some other Numpy operations (such as FFT) to emit a final result (of a few numbers). The inputs can be large, but at any moment only one or two large objects should be live.
A test image is about 10M pixels, which translates to 10MB onc...
I'm trying out scipy.weave to build a fast minimal spanning tree program in Python. Unfortunately, using scipy.weave with a C++ library that I found, STANN, is more difficult that I had assumed. Here's the link to the STANN library: http://sites.google.com/a/compgeom.com/stann/
Below is the Python with scipy.weave script that I wrote.
...
I have a Numpy array that looks like
>>> a
array([[ 3. , 2. , -1. ],
[-1. , 0.1, 3. ],
[-1. , 2. , 3.5]])
I would like to select a value from each row at random, but I would like to exclude the -1 values from the random sampling.
What I do currently is:
x=[]
for i in range(a.shape[0]):
idx=numpy.where(a[i,:]>0...
If I have a list of numpy arrays, then using remove method returns a value error.
For example:
import numpy as np
list = [np.array([1,1,1]),np.array([2,2,2]),np.array([3,3,3])]
list.remove(np.array([2,2,2]))
Would give me
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
...
I have a label matrix with dimension (100*100), stored as a numpy array, and I would like to display the matrix with pyglet.
My original idea is to use this matrix to form a new pyglet image using function pyglet.image.ImageData(). It requres a buffer of the imagedata as an input, however I have no idea how to get a right formated buffe...
I am trying to use the scipy stats package in Python and am getting the following error (on Mac OS X):
$ python
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> from scipy import stats
I then get t...
I'm trying to convert a string array of categorical variables to an integer array of categorical variables.
Ex.
import numpy as np
a = np.array( ['a', 'b', 'c', 'a', 'b', 'c'])
print a.dtype
>>> |S1
b = np.unique(a)
print b
>>> ['a' 'b' 'c']
c = a.desired_function(b)
print c, c.dtype
>>> [1,2,3,1,2,3] int32
I realize this can be d...
I am trying to install pygsl using latest version of GCC, i.e.:
$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5659)
I get the error:
$ sudo python setup.py build
numpy
Building testing ufuncs!
running build
running build_py
running build_ext
building 'errno' extension
C compiler: gcc-4.0 -arch ppc -arch...
I am having lots of trouble installing numpy on Mac OS X 10.6. When I try to install it from source, I get the following error:
customize NAGFCompiler
Could not locate executable f95
customize AbsoftFCompiler
Could not locate executable f90
Could not locate executable f77
customize IBMFCompiler
Could not locate executable xlf90
Could no...
I am trying to change the matplotlib font to helvetica, which I'd like to use in a PDF plot. I try the following:
import matplotlib
matplotlib.use('PDF')
import matplotlib.pylab as plt
from matplotlib import rc
plt.rcParams['ps.useafm'] = True
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.rcParams['pdf.fonttype'] ...
Hi there,
I am still writing on a python interface for my c code with ctypes. Today I substituted my file reading function with a python version, which was programmed by somebody else usind NumPy. The 'old' c version was called with a byref(p_data) while p_data=PFloat() (see below). The main function takes the p_data.
Old file reading:...
Hello, I am using sparse matrices as a mean of compressing data, with loss of course, what I do is I create a sparse dictionary from all the values greater than a specified treshold. I'd want my compressed data size to be a variable which my user can choose.
My problem is, I have a sparse matrix with alot of near-zero values, and what I...
How can I plot the empirical CDF of an array of numbers in matplotlib in Python? I'm looking for the cdf analog of pylab's "hist" function.
One thing I can think of is:
from scipy.stats import cumfreq
a = array([...]) # my array of numbers
num_bins = 20
b = cumfreq(a, num_bins)
plt.plot(b)
Is that correct though? Is there an easie...
I tried to find the eigenvalues of a matrix multiplied by its transpose but I couldn't do it using numpy.
testmatrix = numpy.array([[1,2],[3,4],[5,6],[7,8]])
prod = testmatrix * testmatrix.T
print eig(prod)
I expected to get the following result for the product:
5 11 17 23
11 25 39 53
17 39 61 83
23 53 ...