[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: array dimensions



Paul van Delst wrote:
> 
> Martin Schultz wrote:
> >
> > "Richard G. French" wrote:
> > >
> > > David Fanning wrote:
> > > >>     dimensions = Size(myarray, /Dimensions)
> > > >
> > > > Cheers,
> > >
> > > David is the master of keywords - I've used SIZE all these years without
> > > knowing that there was a /DIMENSIONS keyword. I guess the only way to
> > > know about these things is to read through the documentation over and
> > > over again and take notes on potentially useful keywords and options.
> > >
> > > Which brings me to my question - does anyone out there have a favorite
> > > keyword on a routine that we mere mortals might not know about, but
> > > which
> > > might make our lives much easier? Any suggestions welcome, except for
> > > HISTOGRAM and PLOT!
> > >
> > > Dick French
> >
> > Not a favorite keyword, but a favorite tool: Get a decent system (if
> > you haven't one), install emacs with idlwave, run the routine-info
> > collection, and then you have all the keywords you never knew but
> > always dreamt about literally at your fingertips.
> 
> Similar to typing "?" at the IDL prompt and getting similar info - with examples no less!
> Gasp!

Not even *sort of* similar.  Yes, it's the same information (Carsten
simply process the pdf manuals to get the documentation).  But the
access is amazingly better.  Example:

IDL> d=size(myvar,/

Hmm what was that keyword to size?  I'll hit [Tab] to see. Up comes:

Possible completions are:
DIMENSIONS			   FILE_LUN
L64				   N_DIMENSIONS
N_ELEMENTS			   STRUCTURE
TNAME				   TYPE

Aha, DIMENSIONS, I think that's it.  Why don't I right click on it to
find out.  Up pops in the help window with help on size() displayed, and
queued up to:

      DIMENSIONS
      Set this keyword to return the dimensions
      of Expression. If Expression is scalar, the
      result is a scalar containing a 0. For arrays,
      the result is an array containing the array
      dimensions. ...

OK, dimensions it is, middle click on it:

IDL> d=size(myvar,/DIMENSIONS

Aren't there some other arguments to size()?  I don't recall.  I'll just
show the calling syntax.  [C-c ?].  Here comes:

Usage:    Result = SIZE( Expression)
Keywords: DIMENSIONS FILE_LUN L64 N_DIMENSIONS N_ELEMENTS STRUCTURE
TNAME TYPE
Source:   Builtin   

Hmm. I guess not.  But what is that STUCTURE keyword all about.  I don't
remember that one.  Why not right click on it (it's blue, which means it
exists in the help).

      STRUCTURE
      Set this keyword to return all available
      information about Expression in a structure.

OK, I'll file that away for a rainy day.  As you can see, you soon
become intimately aware of all the keywords in all your favorite
routines, and able to summon them into existence with a few keystrokes. 
One positive side effect of keyword completion is that I am no longer
lazy when it comes to partial keywords (OK I'm still lazy, but IDLWAVE
is not).  No longer is my code littered with framents like
"a=size(var,/DIME)" and other non-sequiturs.  

This is not to mention help with finding the correct routine in the
first place.  I haven't thrown away my regular on-line data-files, I
just visit them only about once a month.

To see (and work through) even more examples, have a look at the
tutorial:
http://www.strw.LeidenUniv.nl/~dominik/Tools/idlwave/idlwave.html#SEC3

JD

P.S.  There are a couple of new features in the offing for an IDLWAVE
release.  If you've ever been tired of the wait for routine info to
load, look for a nice improvement "real soon now".  A nice new
drag-to-print feature for instant debugging fun is also in the works. 
Stay tuned.