comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » crazy contour
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
crazy contour [message #53741] Wed, 02 May 2007 10:08 Go to next message
news.qwest.net is currently offline  news.qwest.net
Messages: 137
Registered: September 2005
Senior Member
I have come across a strange problem with a contour plot.
I have an array that is 2048 by 1025, with a minumum of 0
and a max of 10.
The values all vary smoothly.

If I contour with levels = findgen(10)+1, /fill
the right edge of the plot has a problem (the contours do not
go to the edge, even though they should.) It implies the data goes
to zero in that last column (it does not).
This creates a ps file about about 1 mb.

If I do a contour with levels = findgen(10)+1, /cell
then it plots properly, but is really slow, and creates a 20mb
ps file.

This is a very simple plot. There is only one
maximum per column, monotomically decreasing off that
maximum, and no NANs or other weird points.

Anyone have any ideas on what is going on? It almost seems
like a bug in the contouring algorithm at the right hand edge of the plot,
but I really don't have time to look into it any more.
(I rotated a shade_surf command with shade= keyword and
blanked out the zaxis labels to create a very nice facsimile of
the contour plot I wanted.)

Cheers,
bob


PS David, what do you thing the problem is?
-just kidding :)
Re: crazy contour [message #53814 is a reply to message #53741] Wed, 02 May 2007 13:25 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
R.G. Stockwell writes:

> I always get the 'too many polygons' message. I just figured that was
> a leftover from when IDL ran on IBM 386SX computers and you
> were only allowed 12 polygons and four colors.
> Seriously, this is not an unusual array to plot, and it only had
> 12 contours. It's not like i was trying to calculate googol factorial
> or something like that.

I think the PostScript device is due for some serious maintenance.
Maybe we could convince ITTVIS to set up a program whereby we
could designate that some of our maintenance dollars go for things
we really need. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: crazy contour [message #53815 is a reply to message #53741] Wed, 02 May 2007 13:18 Go to previous message
news.qwest.net is currently offline  news.qwest.net
Messages: 137
Registered: September 2005
Senior Member
"David Fanning" <news@dfanning.com> wrote in message
news:MPG.20a296d7788d155a989f7d@news.frii.com...
> R.G. Stockwell writes:
>
>> So, do you think the 78 mb /cell file is a normal result for a contour
>> plot like this?
>
> Well, I think CELL_FILL produces a LOT of polygons. Even with
> your FILL method I got a warning about lots of polygons. So
> it is probably not out of the question. Have you tried to make
> a PDF file from it? Maybe that will be smaller. Most printers
> will accept that now.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

I always get the 'too many polygons' message. I just figured that was
a leftover from when IDL ran on IBM 386SX computers and you
were only allowed 12 polygons and four colors.
Seriously, this is not an unusual array to plot, and it only had
12 contours. It's not like i was trying to calculate googol factorial
or something like that.

I'll look into the z buffer and pdf solutions when I run into this
problem again. The file is for inclusion into latex, which can handle
these other types of files now.

Cheers,
bob
Re: crazy contour [message #53816 is a reply to message #53741] Wed, 02 May 2007 13:13 Go to previous message
news.qwest.net is currently offline  news.qwest.net
Messages: 137
Registered: September 2005
Senior Member
"Ed Hyer" <ejhyer@gmail.com> wrote in message
news:1178135490.340567.286010@e65g2000hsc.googlegroups.com.. .
> Bob,
>
> In my experience, 25MB, 50MB, 75MB, 130MB, right on up until a crash,
> when you use CONTOUR,/CELL_FILL in a PostScript context. I'm sure
> someone else could explain it better, but PostScript files have a
> raster resolution which is used internally by IDL, which is best
> described as "very, very high." I don't know how to determine the
> "effective raster resolution" that CONTOUR is using.
>
> When I have to do these plots, I make the contour plot using /
> CELL_FILL in the Z buffer, and then place it on the PS image. It would
> be nice if we could put some "pixel-size" magic into CONTOUR (like TV
> has), but I'm not aware of any solutions along those lines.
>
> --Edward H.

I will look into the z buffer approach (both you and David mentioned it)
the next time I come across a similar problem. The rotated shade_surf
works well too (for a scalable postscript file).

Thanks,
bob
Re: crazy contour [message #53818 is a reply to message #53741] Wed, 02 May 2007 12:51 Go to previous message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
Bob,

In my experience, 25MB, 50MB, 75MB, 130MB, right on up until a crash,
when you use CONTOUR,/CELL_FILL in a PostScript context. I'm sure
someone else could explain it better, but PostScript files have a
raster resolution which is used internally by IDL, which is best
described as "very, very high." I don't know how to determine the
"effective raster resolution" that CONTOUR is using.

When I have to do these plots, I make the contour plot using /
CELL_FILL in the Z buffer, and then place it on the PS image. It would
be nice if we could put some "pixel-size" magic into CONTOUR (like TV
has), but I'm not aware of any solutions along those lines.

--Edward H.
Re: crazy contour [message #53822 is a reply to message #53741] Wed, 02 May 2007 12:39 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
R.G. Stockwell writes:

> So, do you think the 78 mb /cell file is a normal result for a contour
> plot like this?

Well, I think CELL_FILL produces a LOT of polygons. Even with
your FILL method I got a warning about lots of polygons. So
it is probably not out of the question. Have you tried to make
a PDF file from it? Maybe that will be smaller. Most printers
will accept that now.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: crazy contour [message #53825 is a reply to message #53741] Wed, 02 May 2007 12:25 Go to previous message
news.qwest.net is currently offline  news.qwest.net
Messages: 137
Registered: September 2005
Senior Member
"David Fanning" <news@dfanning.com> wrote in message
news:MPG.20a28fef59ddc9ad989f7a@news.frii.com...
> R.G. Stockwell writes:
>
>> Note: this seems to be a problem with the ps code (I bet). Perhaps I
>> have a bad ps driver or something. It would be interesting to see if
>> anyone reproduces my problem.
>
> I have a better idea! I think it is your PostScript *viewer*.
> Have you actually printed the PostScript file?

A-HA!

Well, my printer is directly connected to my recycle bin - saves
a lot of time.

I printed it out, and I would say that the "problem" is greatly reduced.
It still appears that there is a thin column of "zero" at the end of the
figure. My ghostview is downlevel 4.6 instead of 4.8 which seems to
be the current version.

So, do you think the 78 mb /cell file is a normal result for a contour
plot like this?


Thanks for the help!

Cheers,
bob
Re: crazy contour [message #53828 is a reply to message #53741] Wed, 02 May 2007 12:12 Go to previous message
news.qwest.net is currently offline  news.qwest.net
Messages: 137
Registered: September 2005
Senior Member
"David Fanning" <news@dfanning.com> wrote in message
news:MPG.20a28e8962669003989f79@news.frii.com...
> R.G. Stockwell writes:
>
>> One odd thing, using /fill the file size 0.4mb. I just created the file
>> using /cell and it is a whopping 78Mb (yes megabytes). Obviously
>> something crazy is going on, that cell is handling it (in a thrashing
>> sort
>> of way)
>> and fill is dropping it.
>>
>> I'll reduce the code and post it.
>
> Oh, oh. I'm becoming convinced.
>
> What about this as an off-the wall suggestion. Do the
> fill part of the contour plot (without axes) in the Z
> graphics buffer with CELL_FILL. Then take a snapshot
> of this portion of the window for later display with
> something like TVIMAGE in the PS file. Add your
> actually contour values on top of this image
> (CONTOUR with NOERASE).


Yes, good suggestion. I had tried creating the plot on screen,
and captured it and wrote a jpeg file, the quality was not nearly
good enough for publication. I ended up doing the following:

shade_surf,abs(s.st),s.time,s.freq,shade=bytscl(abs(s.st)),$
xtitle='Time',ytitle='Frequency',az=0,ax=90,$
ztickname = [' ',' ',' ',' ',' ',' ']


(the blank z ticknames remove a tiny bit of clutter that appears
from the z labels)

Cheers,
bob
Re: crazy contour [message #53830 is a reply to message #53741] Wed, 02 May 2007 12:09 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
R.G. Stockwell writes:

> Note: this seems to be a problem with the ps code (I bet). Perhaps I
> have a bad ps driver or something. It would be interesting to see if
> anyone reproduces my problem.

I have a better idea! I think it is your PostScript *viewer*.
Have you actually printed the PostScript file?

In any case, I don't see the problem after running your
code. It looks fine in my viewer. I don't really have
a PostScript printer.

Cheers,

DAvid

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: crazy contour [message #53831 is a reply to message #53741] Wed, 02 May 2007 12:04 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
R.G. Stockwell writes:

> One odd thing, using /fill the file size 0.4mb. I just created the file
> using /cell and it is a whopping 78Mb (yes megabytes). Obviously
> something crazy is going on, that cell is handling it (in a thrashing sort
> of way)
> and fill is dropping it.
>
> I'll reduce the code and post it.

Oh, oh. I'm becoming convinced.

What about this as an off-the wall suggestion. Do the
fill part of the contour plot (without axes) in the Z
graphics buffer with CELL_FILL. Then take a snapshot
of this portion of the window for later display with
something like TVIMAGE in the PS file. Add your
actually contour values on top of this image
(CONTOUR with NOERASE).

I'm going to guess that should reduce the size of the
file (which I'm sure are due to LOTS of polygons)
considerably. Probably to less than a filled contour
with FILL. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: crazy contour [message #53832 is a reply to message #53741] Wed, 02 May 2007 12:00 Go to previous message
news.qwest.net is currently offline  news.qwest.net
Messages: 137
Registered: September 2005
Senior Member
"R.G. Stockwell" <no@email.please> wrote in message
news:4638de7b$0$505$815e3792@news.qwest.net...

>
> I'll reduce the code and post it.

Note: this seems to be a problem with the ps code (I bet). Perhaps I
have a bad ps driver or something. It would be interesting to see if
anyone reproduces my problem. The thing to look for is: on the left hand
plot, at time = 2048. That column of the plot should continue the peak
of the chirp signal (i.e. the signal goes right to the edge). On my
postscript
file, the chirp ends at around time = 2000, and those final columns are
all "0", i.e. they are black. The plot on the right (using /cell) is
correct.
I see this problem in ps only, the problem does not appear if I plot to
screen.

len = 256.*8
t = findgen(len)
dt = 1

h = 10*cos(2*!pi*(40+t/7.2)*t/len)
s = s_trans(h,samp=dt)

loadct,0
set_plot,'ps'
name='c:\temp\crazycontour.ps'
device,filename=name,color=0,xsize=6.5,xoffset=1,yoffset=2,y size=3,/inches

!p.charsize=1.
!P.multi=[0,2,1]
levels = findgen(15) - 2

contour,abs(s.st),s.time,s.freq,levels=levels,/fill,$
xtitle='Time',ytitle='Frequency',title='(a) ST'

; this below creates the correct contour plot,
; HOWEVER on my system it creates a 77mb ps file.
; So go ahead and see what happens.
contour,abs(s.st),s.time,s.freq,levels=levels,/cell,$
xtitle='Time',ytitle='Frequency',title='(a) ST'


device,/close
set_plot,'win'


end


The ST function is located at:
http://www.cora.nwra.com/~stockwel/rgspages/S-Transform/s_tr ans.pro
Re: crazy contour [message #53833 is a reply to message #53741] Wed, 02 May 2007 11:54 Go to previous message
news.qwest.net is currently offline  news.qwest.net
Messages: 137
Registered: September 2005
Senior Member
"David Fanning" <news@dfanning.com> wrote in message
news:MPG.20a27ebfac10f124989f75@news.frii.com...
> I presume you have XSTYLE=1 and YSTYLE=1 set, as you should
> on ALL contour plots.

Yes. !x.style =1 and !y.style =1 in the startup.


I think the problem is that you are
> looking at the "hole" in the contour plot and *thinking*
> that is the problem.

That is not the problem. There is a "hole" where a maximum should
be, not a minimum. The behaviour remains when I create levels both
above and below the range of the data.

One odd thing, using /fill the file size 0.4mb. I just created the file
using /cell and it is a whopping 78Mb (yes megabytes). Obviously
something crazy is going on, that cell is handling it (in a thrashing sort
of way)
and fill is dropping it.

I'll reduce the code and post it.



>
> http://www.dfanning.com/tips/contour_hole.html
>
> This could probably be fixed if your levels started
> with your minimum value. I would set the levels like this:
>
> step = (Max(array) - Min(array)) / 10
> levels = Indgen(10) * step + Min(array)
>
> If that doesn't solve the problem, then I'd like to
> see that array, cause I don't really believe the story. :-)

:O


Thanks for the response. BTW idl 6.3 on windows.
IDL Version 6.3, Microsoft Windows (Win32 x86 m32). (c) 2006, Research
Systems, Inc.
Re: crazy contour [message #53838 is a reply to message #53741] Wed, 02 May 2007 10:56 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
R.G. Stockwell writes:

> Anyone have any ideas on what is going on? It almost seems
> like a bug in the contouring algorithm at the right hand edge of the plot,
> but I really don't have time to look into it any more.
> (I rotated a shade_surf command with shade= keyword and
> blanked out the zaxis labels to create a very nice facsimile of
> the contour plot I wanted.)

I presume you have XSTYLE=1 and YSTYLE=1 set, as you should
on ALL contour plots. I think the problem is that you are
looking at the "hole" in the contour plot and *thinking*
that is the problem.

http://www.dfanning.com/tips/contour_hole.html

This could probably be fixed if your levels started
with your minimum value. I would set the levels like this:

step = (Max(array) - Min(array)) / 10
levels = Indgen(10) * step + Min(array)

If that doesn't solve the problem, then I'd like to
see that array, cause I don't really believe the story. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: contour over a map and 180 degrees off or problems with dateline
Next Topic: emacs-snapshot and IDLWAVE

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:39:58 PDT 2025

Total time taken to generate the page: 0.00739 seconds