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

Home » Public Forums » archive » Re: Trouble with IDL 5.0.2 (filled contours) unsolved?
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
Re: Trouble with IDL 5.0.2 (filled contours) unsolved? [message #11045] Thu, 05 March 1998 00:00
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <34FD2406.D7CD49EC@gmx.net>, Reinhold Schaaf <Kakadu42@gmx.net>
writes:

> A third remark concernes event handling: It is not possible to define a
> method of a class as the event handler of a widget. Consider:
>
> PRO CFrame__Define
> struct = { CFrame, $
> wBase:0L, $
> wDraw:0L $
> }
> END
>
> FUNCTION CFrame::Init
> self.wBase = WIDGET_BASE()
> self.wDraw = WIDGET_DRAW(self.wBase)
> WIDGET_CONTROL, self.wBase, EVENT_PRO='CFrame::Event'; Not allowed!
> WIDGET_CONTROL, self.wBase, /REALIZE
> RETURN, 1
> END
>
> PRO CFrame::Event, sEvent
> ;handle events
> END
>
> This leads to the runtime error:
>
> % WIDGET_CONTROL: Object method is not allowed in this context.
>
> As a consequence, one is forced to make the event handler a global
> function. But global functions cannot access members of objects, so one
> has to add methods to the class which would be unnecessary otherwise.

I agree that this is somewhat inconvenient, but the workaround is really pretty
easy. The trick I use is to stick the object itself in the uvalue of the top
level base for this object. There is no need to keep the list of objects.
Here is an example:

;*********************************************************** ******************
pro mca_display_event, event ; event processing for MCA application

widget_control, event.top, get_uvalue = mca_display
mca_display->event, event
end

;*********************************************************** ******************
pro mca_display::event, event ; event processing for MCA application

case event.id of

.... Rest of event processing goes here.


;*********************************************************** ******************
function mca_display::init, font_size=font_size, parent=parent
...
base = self.widgets.base
widget_control, base, set_uvalue=self
xmanager, 'mca_display::init', base, event='mca_display_event', $
cleanup = 'mca_display_cleanup', /no_block
...

____________________________________________________________
Mark Rivers (773) 702-2279 (office)
CARS (773) 702-9951 (secretary)
Univ. of Chicago (773) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars.uchicago.edu (e-mail)

or:
Argonne National Laboratory (630) 252-0422 (office)
Building 434A (630) 252-0405 (lab)
9700 South Cass Avenue (630) 252-1713 (beamline)
Argonne, IL 60439 (630) 252-0443 (FAX)
Re: Trouble with IDL 5.0.2 (filled contours) unsolved? [message #11061 is a reply to message #11045] Wed, 04 March 1998 00:00 Go to previous message
Reinhold Schaaf is currently offline  Reinhold Schaaf
Messages: 10
Registered: March 1998
Junior Member
David Fanning wrote:

> By the way, I've been writing object-oriented programs
> this week and I am absolutely blown away by how powerful,
> flexible, and simple these programs can be. This is the best
> thing RSI has EVER added to IDL with the exception of widgets.
> If you haven't yet tried to write an OOP program, give it
> a go. I guarantee you will be impressed with it.
>
> (I'm not talking about the object graphics class library,
> which is much more difficult to learn. But just writing
> programs as objects with their own methods, etc. I spent the
> last two days writing a plot object that uses direct graphics
> calls. It does things that I didn't think were possible
> in IDL! And every time I make it do something else, I get
> about 10 new ideas for something ELSE it can do. I like it.)
>

As a newcomer to IDL with a background in C++, I more or less share
David's opinion on object oriented programming in IDL. I am programming
a (simple) user-inteface for data-reduction software, tried object
graphics, found it full of bugs (or unexpected features?), and settled
on a combination of direct graphics and object oriented programming.

When I started digging into IDL, I could not believe that object
oriented programming was possible without any typechecking. Well, it can
be done (of course one must be prepared to do a lot of testing and
debugging which would be unnecessary in C++). As a second point, one
really has to get used to the fact that objects cannot be created on the
stack, (stack objects are destructed automatically on exit from the
program unit in which the object was constructed). Hence one is forced
to destruct any object manually, which is highly error-prone and makes
life really uncomfortable.

A third remark concernes event handling: It is not possible to define a
method of a class as the event handler of a widget. Consider:

PRO CFrame__Define
struct = { CFrame, $
wBase:0L, $
wDraw:0L $
}
END

FUNCTION CFrame::Init
self.wBase = WIDGET_BASE()
self.wDraw = WIDGET_DRAW(self.wBase)
WIDGET_CONTROL, self.wBase, EVENT_PRO='CFrame::Event'; Not allowed!
WIDGET_CONTROL, self.wBase, /REALIZE
RETURN, 1
END

PRO CFrame::Event, sEvent
;handle events
END

This leads to the runtime error:

% WIDGET_CONTROL: Object method is not allowed in this context.

As a consequence, one is forced to make the event handler a global
function. But global functions cannot access members of objects, so one
has to add methods to the class which would be unnecessary otherwise.
I.e. handling resize events in the example requires:

- A way to get the CFrame object that contains the widget sEvent.id.
Therefore one has to maintain a list of all existing CFrame objects.
This list has to be supplied with methods to search for a widget in
its
members.

- CFrame::Resize, xSize, ySize, in which the actual resizing is done.


Things could be ways simpler if global functions were allowed to be
event handling routines! I wonder whether this could be changed in
future versions of IDL.

Bye

Reinhold

--
************************************************************ *
Reinhold Schaaf
Ettighofferstr. 22
53123 Bonn
Germany

Tel.: 0049-228-625713
Email: schaaf@astro.uni-bonn.de
************************************************************ *
Re: Trouble with IDL 5.0.2 (filled contours) unsolved? [message #11063 is a reply to message #11061] Wed, 04 March 1998 00:00 Go to previous message
hcp is currently offline  hcp
Messages: 41
Registered: August 1995
Member
In article <34FBFD71.3F54@dmi.dk>, Mikael Barfred <mb@dmi.dk> writes:
|> Mikael Barfred wrote:
|> >
|> > Hello,
|> >
|> > I have searched dejanews for articles in this newsgroup regarding
|> > the filled contour problems in IDL 5.0.2. I got a handfull of
|> > recent articles on this, indicating that I am not the only
|> > frustrated IDL 5.0.2 user, but none of them had a solution
|> > or even an explanation to the problem, so I will try to raise
|> > the question again:
|> > [ ... SNIP! ...]

[The snipped stuff is that the cell_fill keyword causes your plot to degenerate
into a mess of flashing triangles]

|> Oops! Looking further on the net, I came across:
|>
|> http://www.dfanning.com/idl5_info/cell_fill.html
|>
|> which seems to indicate that the problem has already been raised
|> to RSI, and a response is pending.

When I brought this up a few months ago, RSI supplied a work-around.
The work-around is to use this short wrapper function to contour instead of
contour itself.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PRO CONTOUR_CELL, z, x, y, _EXTRA=e
; This program was supplied by RSI as a fix for the bugs in the
; cell_fill algorithm of the contour
; routine. contour_cell,data,xgrid,ygrid,/cell_fill will work where
; contour ,data,xgrid,ygrid,/cell_fill will not

nx = n_elements(x) ;Divide a rectangular grid into
;triangles
ny = n_elements(y)
tr = lonarr(6, nx-1, ny-1, /NOZERO)
for iy=0, ny-2 do for ix=0,nx-2 do $ ;Make the triangles
tr(0, ix, iy) = [0, 1, nx+1, 0, nx+1, nx] + (ix + iy*nx)
;2/cell
CONTOUR, z, x # replicate(1,ny), replicate(1,nx) # y, $
TRIANGULATION=tr, _EXTRA=e
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Hugh

--

============================================================ ==============
Hugh C. Pumphrey | Telephone 0131-650-6026
Department of Meteorology | FAX 0131-662-4269
The University of Edinburgh | Replace 0131 with +44-131 if outside U.K.
EDINBURGH EH9 3JZ, Scotland | Email hcp@met.ed.ac.uk
OBDisclaimer: The views expressed herein are mine, not those of UofE.
============================================================ ==============
Re: Trouble with IDL 5.0.2 (filled contours) unsolved? [message #11071 is a reply to message #11061] Tue, 03 March 1998 00:00 Go to previous message
Andy Loughe is currently offline  Andy Loughe
Messages: 174
Registered: November 1995
Senior Member
David Fanning wrote:

> Is this the same Andy Loughe who used to work at NOAA!?
> I'd say RSI must finally be getting their act together to
> get this kind of comment from THAT Andy Loughe. :-)

Now how many "Andy Loughes" do you run across in your travels!?
I still have my moments of frustration, but I like to think I call
a spade a spade, and some problems--not all-- have been fixed by RSI.
I believe, for example, that map_continents, /fill is greatly improved
in v5.0.3.


> P.S. Did you see Scott Lett's comments yesterday that there
> would be MEAN, VARIANCE, STDEV, etc. routines in IDL 5.1?
> Is it just my imagination or is RSI really starting to
> pay closer attention to what customers want and need?


Yes, and I was surprised by the return email address.
For whom does Scott Lett work... (hello, Scott)?

If RSI were to take *any* old routines out of IDL it would affect
backward compatability, so I hope they do not remove stdev as was
earlier announced. What are we supposed to do, replace all occurrences
of stdev with sqrt((moment(array))(1))? I am still unable to use my
routines that require the !map.out system variable that was removed
in version 5 of IDL. What am I to do, add a call to map_set_ll_box?
That is exactly what I have done... with mixed success. Help!


> By the way, I've been writing object-oriented programs
> this week and I am absolutely blown away by how powerful,
> flexible, and simple these programs can be. This is the best
> thing RSI has EVER added to IDL with the exception of widgets.
> If you haven't yet tried to write an OOP program, give it
> a go. I guarantee you will be impressed with it.

I'll try and find some time for OOP!
With 3-1/3 kids at home I am an expert at GOOP and SLOP. ;-)

If I could increase our IDL user base here at NOAA, we could have you
down for a PAID performance to teach us OOP.

Good luck with the newly expanded teaching role you announced this
weekend.

--
Andrew F. Loughe |
afl@cdc.noaa.gov
University of Colorado, CIRES Box 449 |
http://cdc.noaa.gov/~afl
Boulder, CO 80309-0449 | phn:(303)492-0707
fax:(303)497-7013
------------------------------------------------------------ ---------------
"I do not feel obliged to believe that the same God who has endowed us
with
sense, reason, and intellect has intended us to forego their use."
-Galileo
Re: Trouble with IDL 5.0.2 (filled contours) unsolved? [message #11073 is a reply to message #11071] Tue, 03 March 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Andy Loughe (afl@cdc.noaa.gov) writes:

> My experience is that RSI has addressed many of these problems
> in their most recent version, which I believe to be 5.0.3.

Is this the same Andy Loughe who used to work at NOAA!?
I'd say RSI must finally be getting their act together to
get this kind of comment from THAT Andy Loughe. :-)

Cheers,

David

P.S. Did you see Scott Lett's comments yesterday that there
would be MEAN, VARIANCE, STDEV, etc. routines in IDL 5.1?
Is it just my imagination or is RSI really starting to
pay closer attention to what customers want and need?

By the way, I've been writing object-oriented programs
this week and I am absolutely blown away by how powerful,
flexible, and simple these programs can be. This is the best
thing RSI has EVER added to IDL with the exception of widgets.
If you haven't yet tried to write an OOP program, give it
a go. I guarantee you will be impressed with it.

(I'm not talking about the object graphics class library,
which is much more difficult to learn. But just writing
programs as objects with their own methods, etc. I spent the
last two days writing a plot object that uses direct graphics
calls. It does things that I didn't think were possible
in IDL! And every time I make it do something else, I get
about 10 new ideas for something ELSE it can do. I like it.)

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Trouble with IDL 5.0.2 (filled contours) unsolved? [message #11075 is a reply to message #11071] Tue, 03 March 1998 00:00 Go to previous message
Andy Loughe is currently offline  Andy Loughe
Messages: 174
Registered: November 1995
Senior Member
> Oops! Looking further on the net, I came across:
>
> http://www.dfanning.com/idl5_info/cell_fill.html
>
> which seems to indicate that the problem has already been raised
> to RSI, and a response is pending.
>
> This hopefully means that a solution is on its way from RSI.


My experience is that RSI has addressed many of these problems
in their most recent version, which I believe to be 5.0.3.
There is still a problem when latmin=-90.00 and latmax=90.00,
and so you have to alter those points to be something like +-89.99.
This latest work-around came from a kind soul on this newsgroup.

Get the newest version of IDL, and please let us know if your
problems are solved. If not, I am curious to know what map
projection you are using... just the cylindrical? If it is
Mollweide or Polar sterographic, you may find it necessary to
limit your data to that portion of the map that is visible--
those points which are "mappable" by the map_set routine.

Have fun!

--
Andrew F. Loughe |
afl@cdc.noaa.gov
University of Colorado, CIRES Box 449 |
http://cdc.noaa.gov/~afl
Boulder, CO 80309-0449 | phn:(303)492-0707
fax:(303)497-7013
------------------------------------------------------------ ---------------
"I do not feel obliged to believe that the same God who has endowed us
with
sense, reason, and intellect has intended us to forego their use."
-Galileo
Re: Trouble with IDL 5.0.2 (filled contours) unsolved? [message #11078 is a reply to message #11071] Tue, 03 March 1998 00:00 Go to previous message
Mikael Barfred is currently offline  Mikael Barfred
Messages: 2
Registered: March 1998
Junior Member
Mikael Barfred wrote:
>
> Hello,
>
> I have searched dejanews for articles in this newsgroup regarding
> the filled contour problems in IDL 5.0.2. I got a handfull of
> recent articles on this, indicating that I am not the only
> frustrated IDL 5.0.2 user, but none of them had a solution
> or even an explanation to the problem, so I will try to raise
> the question again:
> [ ... SNIP! ...]

Oops! Looking further on the net, I came across:

http://www.dfanning.com/idl5_info/cell_fill.html

which seems to indicate that the problem has already been raised
to RSI, and a response is pending.

This hopefully means that a solution is on its way from RSI.

Mikael

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
MSc Mikael Barfred | E-mail : mb@dmi.dk
Danish Meteorological Institute | Phone (work): (+45) 39 15 74 66
Met. and Oceanographic Research Div. | Fax (work): (+45) 39 15 74 60
Lyngbyvej 100 | Phone (home): (+45) 44 49 12 77
DK-2100 Copenhagen 0E, DENMARK | http://chaos.fys.dtu.dk/~mb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Re: Trouble with IDL 5.0.2 (filled contours) unsolved? [message #11079 is a reply to message #11071] Tue, 03 March 1998 00:00 Go to previous message
Mikael Barfred is currently offline  Mikael Barfred
Messages: 2
Registered: March 1998
Junior Member
Hello,

I have searched dejanews for articles in this newsgroup regarding
the filled contour problems in IDL 5.0.2. I got a handfull of
recent articles on this, indicating that I am not the only
frustrated IDL 5.0.2 user, but none of them had a solution
or even an explanation to the problem, so I will try to raise
the question again:

I have a global dataset, and two vectors holding the lon and
lat coordinates.
I plot them using:

map_set
contour, DATA, LON, LAT, nlevels=10, /cell_fill, /overplot

When plotting, it does the right thing most of the time, but
suddenly during the process, big spikes and triangles may
be drawn across the whole plot, leaving the result useless,
of course.
some times, but not always, it writes:

% Program caused arithmetic error: Floating illegal operand

after completing the plot.

I have access to both IDL v. 5.0.2 and v. 4.0.1. In the old
version, excactly the same task using excactly the same data,
produces the correct plot with no spurious spikes or triangles
messing everything up, and no error messages afterwards.

Some detailed info (which may not be relevant?):
The DATA array is 320x160 with range: -3000 to 55000 and no
undefined values. It starts from (-180, -90), as the IDL 5.0.2
contour doc. says "the X and Y arrays (if supplied) must be
arranged in increasing order" when using contour on map
projections.
The LON is a vector with 320 points, with range: -180.0 to 180.0
and the LAT is a vector with 160 points, with range: -89.14 to 89.14
The first and last columns in DATA are duplicates, as they in fact
represent the same physical locations.

This really beats me! Can it be anything but a (fullfeatured
roaring trucksize) bug?

- What do you think?

Mikael

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
MSc Mikael Barfred | E-mail : mb@dmi.dk
Danish Meteorological Institute | Phone (work): (+45) 39 15 74 66
Met. and Oceanographic Research Div. | Fax (work): (+45) 39 15 74 60
Lyngbyvej 100 | Phone (home): (+45) 44 49 12 77
DK-2100 Copenhagen 0E, DENMARK | http://chaos.fys.dtu.dk/~mb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: NN IDL Freeware
Next Topic: general matrix multiplication

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

Current Time: Fri Oct 10 10:33:11 PDT 2025

Total time taken to generate the page: 0.79985 seconds