I would like to use Welch's method for calculating the power spectral density of a 2D field. There is an implementation available in Scipy, but according to the docs it will only work for 1D timeseries.
Is anyone aware of an implementation that would work for 2D fields?
So far I have been using the 2D Fourier transform to do the calculation, but I have heard that this method is sensitive to noise and that Welch's method is more robust.
Related
I have an array of binned angle data, and another array of weights for each bin. I am using the vmpar() function found here in order to estimate the loc and kappa parameters. I then use the vmpdf() function, found in the same script, to create a von mises probability density function (pdf).
However, the vmpar function does not give me a scale parameter like the scipy vonmises.fit() function does. But I don't know how to use the vonmises.fit() function with binned data, since this function does not seem to accept weights as input.
My question is therefore: how do I estimate the scale from my binned angle data? The reason I want to adjust the scale is so that I can plot my original data and the pdf on the same graph. For example, now the pdf is not scaled to my original data, as seen in the image below (blue=original data, red line = pdf).
I am quite new to circular statistics, so perhaps there is a very easy way to implement this that I am overlooking. I need to figure out this asap, so I appreciate any help!
I have values on the surface of a unit sphere for certain angles on a polar grid. I'm trying to interpolate the values for the off-grid sphere points but can't seem to find any way to do this in Tensorflow. Ideally, I would like to use spherical bivariate spline interpolation.
Scipy has an interpolation type named RectSphereBivariateSpline which does exactly what I need but can't seem to find something like this for Tensorflow (can't use Scipy since I need backpropagation). I tried to follow the Scipy's approach but got stuck on trying to comprehend FITPACK which is written in Fortran. On the other side, tensorflow-graphics only has support for 1D B-spline interpolation.
Is there a function in Tensorflow (or some of its extensions) that could do interpolation for spherical values?
Hi am trying to calculate a vector of the major axis through a 3d mesh in python (using open3d library to interact with the mesh).
I have turned the mesh into a pointcloud using a poisson distribution (1000 points in a numpy array) and have thought about using scikit learn and its PCA functionality to try and get the value of this vector.
From googling around I think I'm on the right tract but have little idea about how to use the PCA function to get what I want.
I think I need to extract the largest eigenvalue from the pointcloud and its accompanying eigenvector - which should hopefully be what I'm looking for.
Have little idea how to do this as I am completely unfamiliar with scikit learn.
Any help please?
Have found a solution using trimesh library:
used the principal_inertia_vectors function to find the 3 largest eigenvalues and corresponding eigenvectors. The eigen vectors correspond to the 3 axes of the mesh.
This functions runs straight off the mesh therefore not requiring conversion to a point cloud.
I'm looking for a solution to fit a number of piecewise planes to linearly approximate a surface. Ideally the user could define the number of planes and the code would determine the "optimal" pieces of the data to fit them to.
There seems to be a number of 2D options discussed, e.g., here How to apply piecewise linear fit in Python? but nothing in 3D.
Thanks!
Is anybody of you aware of a higher order interpolation method (Catmull-Rom splines, cubic interpolation, etc.) for 2D contouring in Python?
Skimage, Matplotlib, and OpenCV provide the functions measure.find_contours(), contours() and findContours() respectively, but all are based on linear interpolation (also known as marching squares), I'm looking into something with higher accuracy in Python, preferably. Any pointers would be highly appreciated.
https://www.dropbox.com/s/orgr2yqhbbk2xnr/test.PNG
In the image above I'm trying to extract iso-value 25 from the scalar field of f(x,y)=x^3+y^3. I'm looking for 6 points with better accuracy than the 6 red points given by linear interpolation.
For unstructured 2d-data (or triangulated data), you might be interested by the following class:
http://matplotlib.org/api/tri_api.html?highlight=cubictriinterpolator#matplotlib.tri.CubicTriInterpolator
which provides a Clough-Tocher (cubic) interpolator from a user-defined Triangulation and field defined at triangulation nodes. It can also be used through the helper class UniformTriRefiner:
http://matplotlib.org/api/tri_api.html?highlight=refine_field#matplotlib.tri.UniformTriRefiner.refine_field
http://matplotlib.org/mpl_examples/pylab_examples/tricontour_smooth_user.png
Nevertheless the choice of the adapted interpolation depends of course of your data set.