bryan cole | 3 Feb 2003 11:40
Picon

RE: shell for scipy

On Fri, 2003-01-31 at 23:20, eric jones wrote:
> > The problem is at re-running the
> > python-process each time to test things out is slow because Scipy
> takes
> > so long to load each time (OK I'm impatient). 
> 
> Agreed.  It would be cool if there was some way of doing on-demand
> loading of the sub-modules without explicitly requiring people to import
> them.   I guess this would have to be a python level feature instead of
> doing it in scipy.  If this were possible, it would ameliorate the
> problem markedly.  The effort involved (or even if it is possible --
> should be) is not clear to me.

I have found that ipython (www-hep.colorado.edu/~fperez/ipython/) goes
along way to provide this functionality.

With the ipython  <at> edit &  <at> run commands you can edit/run blocks of code.
Since the python interpreter remains running between executions, slow
module imports only occur once. This works great for SciPy; you can do
multiple edits and re-executions of code real fast. Plotting with
plt.plot also works this way, provided you use Gui_Thread. 

I ran into problems trying to call plt.plot from the main thread (with
my own wxApp() object and a few extra GUI items); once you destroy the
main plot-window, you can only re-create it in a new process (forcing
you to kill ipython and start over ... lucky for the ipython logging
facility...)

All ipython lacks is a pretty user-interface (yes, a worksheet would be
nice) with syntax-highlighting. This is important for Windows users who
(Continue reading)

Agustin Lobo | 3 Feb 2003 13:02
Picon

step in arrays


Hi! 
I would need a little help on this:

I want to read a set of images
(raw bin data, unsigned int*8) and
display them using xply.imagesc just
to mae sure there have been no errors at downloding
them.

For each file, I'm doing the following:

f =open("NDVI_GIMMS_8KM.8107","r")
a=f.read()
b = array(a,typecode=UnsignedInt8)
b.shape = (2168,5004)
xplt.imagesc(b)

The problem is that, as the array "b" is very large,
the display takes too long. Therefore, I'm trying
to subsample b. I've tried with take(), but no luck.
The question is, how could I select every i.e. 10th row
and col from matrix b?

Also, any other comment on improving what I want to do
is welcome! (perhaps I can subsample at reading).

Thanks

Agus
(Continue reading)

bryan cole | 3 Feb 2003 13:07
Picon

Re: step in arrays

how about:

...
b.shape=(2168,5004)
c = b[0:2168:8,0:5004:8] #this should subsample b every 8th point
xplt.imagesc(c)
...

Bryan

On Mon, 2003-02-03 at 12:02, Agustin Lobo wrote:
> Hi! 
> I would need a little help on this:
> 
> I want to read a set of images
> (raw bin data, unsigned int*8) and
> display them using xply.imagesc just
> to mae sure there have been no errors at downloding
> them.
> 
> For each file, I'm doing the following:
> 
> f =open("NDVI_GIMMS_8KM.8107","r")
> a=f.read()
> b = array(a,typecode=UnsignedInt8)
> b.shape = (2168,5004)
> xplt.imagesc(b)
> 
> The problem is that, as the array "b" is very large,
> the display takes too long. Therefore, I'm trying
(Continue reading)

Agustin Lobo | 3 Feb 2003 16:02
Picon

Re: step in arrays


Thanks, 

why is it that, while

xplt.imagesc(b[0:2168:8,0:5004:8])
and
xplt.imagesc(b[0:2168:8,5004:0:-8])

display the image with a black background

xplt.imagesc(b[2168:0:-8,0:5004:8])

displays it with a green background?

(the background in the image
has value 128, so it seems that somehow I 
change the lut).

Agus

Dr. Agustin Lobo
Instituto de Ciencias de la Tierra (CSIC)
Lluis Sole Sabaris s/n
08028 Barcelona SPAIN
tel 34 93409 5410
fax 34 93411 0012
alobo <at> ija.csic.es

On 3 Feb 2003, bryan cole wrote:
(Continue reading)

Travis Oliphant | 3 Feb 2003 17:10
Favicon

Re: step in arrays

> Thanks,
>
> why is it that, while
>
> xplt.imagesc(b[0:2168:8,0:5004:8])
> and
> xplt.imagesc(b[0:2168:8,5004:0:-8])
>
> display the image with a black background
>
> xplt.imagesc(b[2168:0:-8,0:5004:8])
>
> displays it with a green background?
>

The image is always a byte array and what is plotted is a colormap of
240-255 different colors.

Your image values are transformed into that range.  If you would like a
fixed range, then use cmax=<image value for highest color>  and
cmin=<image value for lowest color> as keywords to the imagesc plot.

But, in your case, the data should be exactly the same (it's just given in
a different order), so I'm not sure what is wrong.

You can do

source(xplt.imagesc) to see what is happening under the covers

Also, xplt.ghelp('pli') can give you the Gist documentation on the
(Continue reading)

Agustin Lobo | 3 Feb 2003 17:27
Picon

execute program from withn python


Is there any way to run a program
from within python?

I would like to run gunzip
(and other programs) and
then read in the result.
This is done within a loop, 
and beacuse of reasons
of disk space, it is not convenient
for me in theis case to run the program first for
all files and then start python.

Thanks

Agus

Dr. Agustin Lobo
Instituto de Ciencias de la Tierra (CSIC)
Lluis Sole Sabaris s/n
08028 Barcelona SPAIN
tel 34 93409 5410
fax 34 93411 0012
alobo <at> ija.csic.es
bryan cole | 3 Feb 2003 17:42
Picon

Re: execute program from withn python

Try "os.spawnl()" or one of it's relatives (there are eight different
variations ... see the Python reference docs). Alternatively, you could
use "os.popen()" (4 versions!) to run gunzip on a file and read the
result directly into python via a pipe (no need to write an intermediate
file).

Bryan

On Mon, 2003-02-03 at 16:27, Agustin Lobo wrote:
> Is there any way to run a program
> from within python?
> 
> I would like to run gunzip
> (and other programs) and
> then read in the result.
> This is done within a loop, 
> and beacuse of reasons
> of disk space, it is not convenient
> for me in theis case to run the program first for
> all files and then start python.
> 
> Thanks
> 
> Agus
> 
> Dr. Agustin Lobo
> Instituto de Ciencias de la Tierra (CSIC)
> Lluis Sole Sabaris s/n
> 08028 Barcelona SPAIN
> tel 34 93409 5410
(Continue reading)

Fernando Perez | 4 Feb 2003 19:18
Picon

Re: ipython => TeXmacs!

On Thu, 30 Jan 2003, David Ascher wrote:

> Fernando Perez wrote:
> 
> >However, as I said before, I don't intend to embark on a gui project myself.  
> >For my needs, ipython + xemacs is basically perfect.  However, if there is 
> >enough interest in a gui scientific pyhton shell,  I'd be glad to help along 
> >with the internal redesign and I can probably write the 'plumbing' necessary 
> >for ipython to plug into another external system.  But gui programming just 
> >doesn't interest me very much, sorry.
> >  
> >
> I'm interested, not so much in the scipy-ipython integration (although 
> that would be neat), but in finding a way of using ipython in Komodo, 
> when we get to do our interactive shells.  I'm not going to have time to 
> work on that for a while, but I'd love to learn more about ipython and 
> its architecture -- specifically what API you'd like to see between the 
> GUI handling part and the "model" of the shell.

Well, give IPython a try one day and see if it seems to fit your needs.  As 
far as architecture goes, let's say there isn't much of one (to be very kind 
to me :).  IPython is quite robust and useful, but internally a mess.  And 
that's precisely why I'm interested in hearing about possible development 
along with a good gui: so that I can drive a major internal cleanup with an 
eye out for gui integration.

Honestly, I think that for a text-only shell it's "good enough" and probably 
the effort of cleaning it up internally isn't really justified.  But if 
there's interest in using it as the core for a good gui, I could definitely 
reorganize it and actually come up with a good API.  The pieces are in my head  
(Continue reading)

Fernando Perez | 4 Feb 2003 19:31
Picon

Re: shell for scipy

On Thu, 30 Jan 2003, A.J. Rossini wrote:

> >>>>> "FP" == Fernando Perez <fperez <at> pizero.colorado.edu> writes:
> 
>     FP> That's exactly what I'd like to have for python: ipython as the command-line
>     FP> shell, and a gui which uses ipython as its interaction engine, but which can
>     FP> also save the whole session, edit across lines, embed graphics and change
>     FP> fonts, etc.
> 
>     FP> Such a project is fairly ambitious, but I'd like to pitch it here to see if
>     FP> there is community response. Mathematica, maple, matlab & IDL all have
>     FP> graphical desktops and for scipy to dethrone the last two of them, it will 
>     FP> probably need one too (I say the last two because I don't see scipy as 
>     FP> competing with Mathematica, but definitely as a better environment than matlab 
>     FP> or IDL).
> 
> You might look at the Sweave tools in R, combined with ESS (Emacs
> Speaks Statistics) for interactive construction and evaluation.  It
> isn't interactive in the Mathematica sense, but it is the next best
> thing -- construction of documents using Noweb/literate programming
> techniques, and evaluation of "chunks" interactively, or via a "report
> generation" mechanism.

sounds very interesting, thanks for the info.  If there is enough interest in 
this to move forward in the direction of a gui, we'll definitely take a look.

Cheers,

f
(Continue reading)

Fernando Perez | 4 Feb 2003 19:33
Picon

Re: shell for scipy

On 31 Jan 2003, bryan cole wrote:

> OK, I've taken a closer look at ipython and I see I can acheive 'code
> block' editing using the  <at> edit magic function. Looks like I'm now an
> ipython convert :)

Also look at  <at> macro and  <at> save, which allow you to respectively re-execute and 
save chunks of code you've typed interactively.  You can select non-contiguous 
sets of lines in your input history to assemble on the fly code snippets for 
quick re-execution.  I use  <at> macro a lot when doing interactive work to make 
single letter aliases for chunks of code I need to rerun many times.

Cheers,

f.

Gmane