JBIU and MOMENTDIMEN

Jeremy Bailin's IDL Utilities

JBIU contains a number of IDL utilities that I have written for my own use that you may find useful. Note that many of these routines make use of The IDL Astronomy User's Library and/or David Fanning's Coyote Program Library.

Download

Documentation

MOMENTDIMEN

For reasons unknown, while some built-in IDL routines like TOTAL accept an argument or keyword that performs the action only over a given dimension of a multidimensional array, some very obvious functions such as MOMENT and all of its cousins (MEAN, STDDEV, VARIANCE, SKEWNESS and KURTOSIS), where it would be extremely useful, do not. I have created modified versions of these functions called MOMENT_D, MEAN_D, STDDEV_D, VARIANCE_D, SKEWNESS_D and KURTOSIS_D that accept a keyword DIMEN that specifies the dimension over which the operation should be performed.

Because much of the code and/or documentation in these routines comes directly from the built-in IDL versions, which are copyright ITT, I cannot legally distribute my functions. However, I can distribute the patches that will copy over your own version of the built-in routines and patch them into my routines!

I have only tested this procedure on IDL 7.0.4 for Mac. However, none of the built-in functions have been updated since 1998, so this should work for any previous version still in use.

Download

Installation

Unix/Mac:

  1. Download the tar file and place it in a directory somewhere in your IDL path.
  2. Untar the file: tar xzvf momentdimen-1.0.tgz. It will create a subdirectory called momentdimen.
  3. Change into the momentdimen subdirectory: cd momentdimen.
  4. Run the dimenpatch.sh script: sh dimenpatch.sh.
  5. The script will look for the functions in several common locations. If it can't find them, it will prompt for the location. This should be the directory where the file moment.pro is located, and will be in the lib subdirectory of the IDL installation directory. It will then copy the functions to the momentdimen directory, rename them with "_d" endings, and apply the patches to allow the DIMEN keyword.

Windows:
If you have something like Cygwin installed, the above procedure (or with slight modifications to dimenpatch.sh) might work for you. If not, you'll need to manually copy the files from your IDL lib directory over, rename them, and then apply the patches from the downloaded tar file. A version of patch that works for Windows can be found here.

Example Usage

MEAN_D, STDDEV_D, VARIANCE_D, SKEWNESS_D and KURTOSIS_D work exactly as you would expect. If the DIMEN keyword is given, the final result has one fewer dimensions than the input array.

When MOMENT_D is used with the DIMEN keyword, the final result has the same dimensions as the input array; the specified dimension is eliminated, and a trailing dimension of span 4 is added, one for each of the mean, standard deviation, skewness and kurtosis. For example:

IDL> a = findgen(2,3,4)
IDL> print, a
      0.00000      1.00000
      2.00000      3.00000
      4.00000      5.00000

      6.00000      7.00000
      8.00000      9.00000
      10.0000      11.0000

      12.0000      13.0000
      14.0000      15.0000
      16.0000      17.0000

      18.0000      19.0000
      20.0000      21.0000
      22.0000      23.0000
IDL> b = mean_d(a, dimen=3)
IDL> help, b
B               FLOAT     = Array[2, 3]
IDL> print, b
      6.00000      6.66667
      7.33333      8.00000
      8.66667      9.33333
IDL> c = moment_d(a, dimen=2)
IDL> help, c
C               FLOAT     = Array[2, 4, 4]
IDL> print, c
      2.00000      3.00000
      8.00000      9.00000
      14.0000      15.0000
      20.0000      21.0000

      4.00000      4.00000
      4.00000      4.00000
      4.00000      4.00000
      4.00000      4.00000

      0.00000      0.00000
      0.00000      0.00000
      0.00000      0.00000
      0.00000      0.00000

     -2.33333     -2.33333
     -2.33333     -2.33333
     -2.33333     -2.33333
     -2.33333     -2.33333

Contact

Suggestions, bug reports, and (especially!!) bug fixes are extremely welcome: jbiu at astroconst dot org.