griffinfoster / shapelets

python-based shapelet decomposition package
Other
26 stars 7 forks source link

Optimized version for polar shaplets #3

Closed rth closed 10 years ago

rth commented 10 years ago

Hello Griffin, first of all thanks a lot for implementing this shapelets package! A year ago or so I wanted to use it to model (and remove) background noise in some experimental images. This pull request contains some optimisations for polar shaplets:

For instance for a problem size of (1000, 500), the execution time on my laptop is

The script/profile.py file contains the code to run this test and lists the used parameters.

I include both versions here if ever it is of interest to you, but otherwise I can do another pull request with only the numexpr version as it is easier to maintain and setup. Curretly the 3 implementations can be used for the genPolarBasisMatrix function

import shapelets.decomp as sh
import shapelets.fshapelet as fsh
import shapelets.cshapelet as csh
# original version
sh.genPolarBasisMatrix(*args)
# numexpr version
fsh.genPolarBasisMatrix(*args)
# Cython version
csh.genPolarBasisMatrix(*args)

There are some unitests that validate that all of the implementations give the same results:

   $ cd src/ ; nose -s tests.py

Best,

rth commented 10 years ago

I did most of the work more then a year ago, and I can't remember all of the details. It looks like at present the cython functions doesn't use the GSL library anymore, so the corresponding lines can be safely removed from setup.py making it more portable. Anyway, I'm pushing this whole thing before I forget completly what I did there...

griffinfoster commented 10 years ago

Hey Roman, thanks for the work, it is a nice little speed up. I have let this code sit around for quite a long time, about 75% complete, I need to make some time to finish it off as we are using it more these days.