getting list of interpolation functions...

Hi,

How can I get the list of the available interpolation functions
used by imshow() ?

TIA.

Cheers,

···

--
http://scipy.org/FredericPetit

fred wrote:

Hi,

How can I get the list of the available interpolation functions
used by imshow() ?

TIA.

Cheers,

ipython -pylab
imshow?

or

ipython
import pylab
pylab.imshow?

or

python
import pylab
help(pylab.imshow)

Eric

Eric Firing a �crit :

fred wrote:

Hi,

How can I get the list of the available interpolation functions
used by imshow() ?

TIA.

Cheers,

Sorry, I was not clear.

I want to get the list, not to know, in order to set it in a trait object, for instance,
using something like interpd.keys().

TIA.

Cheers,

···

--
http://scipy.org/FredericPetit

Fred,

In image.py, the AxesImage.__init__() includes:

        self._interpd = {
             'nearest' : _image.NEAREST,
             'bilinear' : _image.BILINEAR,
             'bicubic' : _image.BICUBIC,
             'spline16' : _image.SPLINE16,
             'spline36' : _image.SPLINE36,
             'hanning' : _image.HANNING,
             'hamming' : _image.HAMMING,
             'hermite' : _image.HERMITE,
             'kaiser' : _image.KAISER,
             'quadric' : _image.QUADRIC,
             'catrom' : _image.CATROM,
             'gaussian' : _image.GAUSSIAN,
             'bessel' : _image.BESSEL,
             'mitchell' : _image.MITCHELL,
             'sinc' : _image.SINC,
             'lanczos' : _image.LANCZOS,
             'blackman' : _image.BLACKMAN,
         }

Logically I suspect this should be a class attribute, not an instance attribute, which would make things easier for you (and is an easy change to make--I can make it unless someone quickly points out why this would be a mistake.) Maybe the keys should be a separate class attribute, with no underscore, since although the values in this dictionary may be implementation-dependent, the keys should not be--they are part of the external interface.

Let me know if making these changes in svn is worthwhile.

Eric

fred wrote:

···

Eric Firing a �crit :

fred wrote:

Hi,

How can I get the list of the available interpolation functions
used by imshow() ?

TIA.

Cheers,

Sorry, I was not clear.

I want to get the list, not to know, in order to set it in a trait object, for instance,
using something like interpd.keys().

TIA.

Cheers,

Eric Firing a �crit :

Fred,

In image.py, the AxesImage.__init__() includes:

       self._interpd = {
            'nearest' : _image.NEAREST,
            'bilinear' : _image.BILINEAR,
            'bicubic' : _image.BICUBIC,
            'spline16' : _image.SPLINE16,
            'spline36' : _image.SPLINE36,
            'hanning' : _image.HANNING,
            'hamming' : _image.HAMMING,
            'hermite' : _image.HERMITE,
            'kaiser' : _image.KAISER,
            'quadric' : _image.QUADRIC,
            'catrom' : _image.CATROM,
            'gaussian' : _image.GAUSSIAN,
            'bessel' : _image.BESSEL,
            'mitchell' : _image.MITCHELL,
            'sinc' : _image.SINC,
            'lanczos' : _image.LANCZOS,
            'blackman' : _image.BLACKMAN,
        }

Logically I suspect this should be a class attribute, not an instance attribute, which would make things easier for you (and is an easy change to make--I can make it unless someone quickly points out why this would be a mistake.) Maybe the keys should be a separate class attribute, with no underscore, since although the values in this dictionary may be implementation-dependent, the keys should not be--they are part of the external interface.

Let me know if making these changes in svn is worthwhile.

In fact, I would like something like datad for colormaps.
I use it like this:

    def __init__(self, **traits):
    HasTraits.__init__(self, **traits)
              dict_colormaps = copy(datad)
        self.cmap = get_cmap(self.default_colormap)
        for cm in dict_colormaps.keys():
            if (cm[-2:] == '_r'):
                dict_colormaps.pop(cm)

Doing this, I can display in my traits app the list of colormaps.

I would like to have something similar for available interpolation
methods.

I guess that implies to remove intperd from the AxesImage class,
as datad does not belong to any class, IIUC.
Obviously, I can build this list myself, hard-coding it,
but I would prefer something "cleaner".

Cheers,

···

--
http://scipy.org/FredericPetit

fred wrote:

Eric Firing a �crit :

Fred,

In image.py, the AxesImage.__init__() includes:

       self._interpd = {
            'nearest' : _image.NEAREST,
            'bilinear' : _image.BILINEAR,
            'bicubic' : _image.BICUBIC,
            'spline16' : _image.SPLINE16,
            'spline36' : _image.SPLINE36,
            'hanning' : _image.HANNING,
            'hamming' : _image.HAMMING,
            'hermite' : _image.HERMITE,
            'kaiser' : _image.KAISER,
            'quadric' : _image.QUADRIC,
            'catrom' : _image.CATROM,
            'gaussian' : _image.GAUSSIAN,
            'bessel' : _image.BESSEL,
            'mitchell' : _image.MITCHELL,
            'sinc' : _image.SINC,
            'lanczos' : _image.LANCZOS,
            'blackman' : _image.BLACKMAN,
        }

Logically I suspect this should be a class attribute, not an instance attribute, which would make things easier for you (and is an easy change to make--I can make it unless someone quickly points out why this would be a mistake.) Maybe the keys should be a separate class attribute, with no underscore, since although the values in this dictionary may be implementation-dependent, the keys should not be--they are part of the external interface.

Let me know if making these changes in svn is worthwhile.

In fact, I would like something like datad for colormaps.
I use it like this:

    def __init__(self, **traits):
    HasTraits.__init__(self, **traits)
              dict_colormaps = copy(datad)
        self.cmap = get_cmap(self.default_colormap)
        for cm in dict_colormaps.keys():
            if (cm[-2:] == '_r'):
                dict_colormaps.pop(cm)

Doing this, I can display in my traits app the list of colormaps.

I would like to have something similar for available interpolation
methods.

I guess that implies to remove intperd from the AxesImage class,
as datad does not belong to any class, IIUC.

I don't understand; it seems to me that all you need is _interpd.keys(), and since this is specific to AxesImage, it should be an attribute of that class, say AxesImage.interpolations. You can't add interpolation methods, and they have no meaning outside AxesImage (or the code it calls). The colormap dictionary is different: much more general and flexible, so it is where it belongs: outside any class.

Eric

···

Obviously, I can build this list myself, hard-coding it,
but I would prefer something "cleaner".

Cheers,

Eric Firing a �crit :

I don't understand; it seems to me that all you need is _interpd.keys(), and since this is specific to AxesImage, it should be an attribute of that class, say AxesImage.interpolations. You can't add interpolation methods, and they have no meaning outside AxesImage (or the code it calls). The colormap dictionary is different: much more general and flexible, so it is where it belongs: outside any class.

Well..., can you look at this ?

http://fredantispam.free.fr/a.mpg

I hope you can see what I want.

I agree with you that interpolation functions have no meaning outside,
but I only want to get their names, to let the user choose, as he
can choose the colormap.

The interpolation functions list has to be created before the user has loaded any data.

I hope I'm more clear.

Cheers,

···

--
http://scipy.org/FredericPetit

Fred,

Cleaning out old mail, I came across this thread. I know it is not exactly what you were requesting, but I still think it meets the need you describe: in svn 4936 I moved _interpd and _interpdr from __init__ to the class attribute level, and added a public class attribute, AxesImage.interpnames, so you can find out what the valid values are without making an AxesImage instance.

Eric

fred wrote:

···

Eric Firing a �crit :

I don't understand; it seems to me that all you need is _interpd.keys(), and since this is specific to AxesImage, it should be an attribute of that class, say AxesImage.interpolations. You can't add interpolation methods, and they have no meaning outside AxesImage (or the code it calls). The colormap dictionary is different: much more general and flexible, so it is where it belongs: outside any class.

Well..., can you look at this ?

http://fredantispam.free.fr/a.mpg

I hope you can see what I want.

I agree with you that interpolation functions have no meaning outside,
but I only want to get their names, to let the user choose, as he
can choose the colormap.

The interpolation functions list has to be created before the user has loaded any data.

I hope I'm more clear.

Cheers,