Equivalent matlab damp function for Python - python

Does anybody know which is the equivalent (or any equivalent) matlab damp function for Python (in scipy, numpy or some other)?
Thanks

Whilst I haven't personally used it, a quick google suggests that the python control systems library might be what you're after.
It appears to implement the functionality of the MATLAB control systems toolbox with a compatibility mode which matches the same interface as in MATLAB.
Specifically the function you have asked for is here.

Related

Python equivalent of MATLAB function findchangepts

I need a python equivalent of the MATLAB command findchangepts . I am unable to find one yet. Essentially I want to find K abrupt changes in my time series.
I am able to use the matlab command but unable to find an equivalent function in python. Any help/pointers to existing libraries will be very helpful. I am not proficient in the optimization modules of scipy and thus would prefer an existing python package.
Thanks.
If you cannot use Matlab under the hood there is e.g. ruptures which implements change point detection (docs).
Just in case the answer might help:
I have both MATLAB and Python on my computer. I was able to use MATLAB bindings for python to use findchangepts in my python code.
Source for bindings : MATLAB API for Python

Connecting Matlab to Tensorflow

I am using an open-source Matlab toolbox for brain-computer interface (BCI). I want to send the brain imaging data over to Tensorflow for classification and get the results back to Matlab. Is there any way to pass data structures from Matlab to Tensorflow and get the results back into Matlab?
In case someone lands here with a similar question, I'd like to suggest a Matlab package I am currently writing. It's called tensorflow.m and it's available on GitHub. There's no stable release yet, but simple functionality like importing a frozen graph and running an inference is already possible (see the examples) - this is all you'd need to classify the images in Matlab (only).
The advantage is that you don't need any expensive toolbox nor a Python/Tensorflow installation on your machine. The Python interface of Matlab also seems to be rather adventurous, while tensorflow.m is pure Matlab/C.
I'd be glad if the package can be of use for someone looking for similar solutions; even more so, in case you extend/implement something and open a PR.
So far the best way I found is to run your python module in matlab through matlab's now built-in mechanism for connecting to python:
I wrote my python script in a .py file and in there I imported tensorflow and used it in different functions. You can then return the results to matlab by calling
results = py.myModule.myFunction(arg1,arg2,...,argN)
More detailed instructions for calling user-defined python modules in matlab could be found in the following link:
http://www.mathworks.com/help/matlab/matlab_external/call-user-defined-custom-module.html

Numpy analog for Jython [duplicate]

This question already has answers here:
Is there a good NumPy clone for Jython? [closed]
(4 answers)
Closed 9 years ago.
I am considering porting scientific code from Python to Jython and I am interested, whether there exist math libraries
for Jython, which are:
free for commercial use
have convenient matrix syntax designed for Jython - i.e. permit slicing, binary and integer indexing, +-*/ operations like matlab and numpy.
Additional availability of machine learning and statistical routes would be a plus (or easy convertibility of data to some common data format, understood by major Java machine learning libraries).
Thanks in advance for any information about such libraries.
I took on the role of maintaining such a package a while back. It's called jnumeric (available on github and installable via maven).
JNumeric kind of has a weird history though, dating back to the early 2000s. It's never really been functionally equivalent to NumPy (or even numeric, which is what it's actually trying to emulate), and while it was "good enough" for what we were using it for, to use it as the primary number-cruncher in a Java program is probably not a good idea. It was a bad enough idea that we rewrote our application from scratch in Python so that we could use NumPy instead of trying to do vector math in Java. For that reason, jnumeric is undermaintained, and should probably silently fade into non-existence.
I recently noticed a new project pop up on Github, Numpy4J, which may have a brighter future.
While I know it doesn't quite address your question, I am curious why you would want to move to Jython for scientific code. Java does not have the nice number crunching and plotting libraries that Python has. ML libraries like Weka have Python equivalents in scikit-learn. Imaging stuff like ImageJ has an equivalent in scikit-image. Statistical packages exist in pandas and statsmodels. What is your scientific itch that Python does not scratch?
If you want to move to Jython in order to interface with an existing Java library that cannot be easily ported to Python, I would consider JPype rather than Jython.

Multidimensional FFT in python with CUDA or OpenCL

I have been browsing around for simple ways to program FFTs to work on my graphic card (Which is a recent NVIDIA supporting CUDA 3.something).
My current option is either to learn C, then that special C version for CUDA, or use some python CUDA functions. I'd rather not learn C yet, since I only programmed in high-level languages.
I looked at pyCUDA and other ways to use my graphic card in python, but I couldn't find any FFT library which could be use with python code only.
Some libraries/project seem to tackle similar project (CUDAmat, Theano), but sadly I found no FFTs.
Does a function exist which could do the same thing as numpy.fft.fft2(), using my graphic card?
EDIT: Bonus point for an open source solution.
There's PyFFT, which is open-source and based on Apple's (somewhat limited) implementation. Disclaimer: I work on PyFFT :)
Yes, ArrayFire has a 2-D FFT for Python.
Disclaimer: I work on ArrayFire.

How to use Python OpenCV functions in Sikuli

I'd like to use OpenCV functions, like Hough Transform and Corner Detection, in Sikuli.
I tried the OpenCV installation instructions for CPython on Sikuli and it's a no go.
I understand that Sikuli is Jython and this might be the hard way to do things. What are the easier alternatives?
I'd still like to use Sikuli & Python because the code I write just works; but maybe I'm hitting the limits of Sikuli.
You could use Automa as an alternative to Sikuli. It is a pure Python library (so you can use any other Python library with it) and its image search algorithms are fully compatible with Sikuli. In fact, it uses OpenCV's Python bindings itself, and thus ships with them.
Disclaimer: I'm one of Automa's developers.
Generally spoken: Python modules containing C-based code (which is the case for Python OpenCV) cannot be used in the Sikuli Script (Jython).
The integration of some OpenCV features in Sikuli is realized using the Java-To-C interface (JNI) and the usage of OpenCV features itself is coded in C++.
If you want to use OpenCV features not supported by Sikuli, then you either have to use the above mentioned JNI approach or use the Java implementation of OpenCV (javacv) (Java stuff can be used seamlessly from Jython scripts).
Another option of course is to implement the additional things in plain Python scripts using the Python/OpenCV and call these scripts via the C-Python interpreter in a subprocess.

Categories