Presentation Supercomputing Zulip @ IAC SIEpedia IT News

Logo SIE


We include here a FAQ dealing with the most common problems found in IDL.

Q-1 I am experiencing problems with colors. I cannot change the palette, or I can but the image colors are not updated, etc.

A-1 This is due to the way IDL manage colors in a 24-bit display. The information reported below should help you solve your problem. You should see yourself what combination of commands among the ones suggested below works out best for you.


1) From an email by D. Fanning

Q. I have an unapealling problem with the "xloadct" function in the SUN-environment. It works properly in any machine, excepting the ULTRA-10 one, maybe because it uses 24-bit colors.
The widget is properly initialized, and it seems to work, but it is not able to change the palette or the correction or whatever of the current image displayed.

R: It is not a problem so much as it is the way 24-bit color displays work. You must re-display your graphics after you change the colors in the color table. There is no direct connection between the colors in current graphics windows and the colors currently loaded in the color table.

This is exactly why people *wanted* 24-bit color in the first place. :-)

Re-displaying your graphics is not so hard. See the UpdateCallback and UpdateCBData keywords to XLoadCT, for example. Here is an article that shows you how to update colors in a widget program:


2) Sugerencias de A. Vazdekis

Sobre los posibles problemas con xloadct, resumiendo puede ocurrir:

1) El hecho de estar trabajando con tarjeta grafica de 8 o 24 bits
2) un problema de falta de memoria por aplicaciones abiertas que limitan el xloadct, como pueden ser netscape... es casi seguro que si se abre otra sesion de idl en la misma maquina y se prueba con xloadct este estara muerto.

Para averiguar si la tarjeta es de 8 o 24 bits escribir desde IDL:
IDL> device,get_visual_name=n,get_visual_depth=d
IDL> print,n,d

Si es 8 bits solo se puede trabajar con el modelo indexado (256 colores).
Aqui la opcion que funciona es:
IDL> device,decomposed=0

Si es 24 bits serian 256*256*256 colores posibles. En principio con 24 bits no hay limitacion de colores y por tanto es mucho mejor si se desea trabajar con una gama muy alta de colores. Para activarlo, hay que escribir, por ejemplo, dentro del programa que pinta o bien en el fichero de arranque:
IDL> device, decomposed=1

Si se desea desactivarlo y conservar el modo indexado (es decir, trabajar con un maximo de 256 colores, como si fuera en 8 bits) entonces hay que escribir:
IDL> device,decomposed=0

Nota: si la maquina es de 8-bit no aceptara la opcion =1.

El programa alternativo "xcolors" es mas habil y te ahorra estar pendiente de esto. Si no arrancase correctamente, hacer lo siguiente:
IDL> .reset
IDL> loadct,0
IDL> xcolors

Muy importante: hay que redisplayar la imagen/plot en cuestion cada vez que se cambie algo.

Si se esta en linux (y esto puede que valga para Sun tambien) es posible que se tenga que escribir al principio de todo (no vale con teclearlo despues que ya se haya echo otras cosas):
IDL> device, true=24

y se quieren usar las tablas de colores de 8bit entonces (recomendado por D. Fanning en caso de display en 24 bits).
IDL> device,decomposed=0


3) Information we found in the IDL website

Among the TechTips, we found VIZ99 (number 1688) about "flashing colors" problems in Unix. They say that, to avoid it, the commad "device, true=24" must be executed before any other commands, followed by "device, decomposed=0" (recommended by D. Fanning for 24-bit displays).

# Example of IDL commands to test correct color display
IDL> device, true=24       # must be the very first command
IDL> device, decomposed=0
IDL> window, xsize=360, ysize=360
IDL> world=loaddata(7)
IDL> loadct, 5
IDL> tv, world

4) Further useful info

Further information about the way IDL manage colors can be found in the IDL 6.2 Help System, by looking for "Colors and IDL Graphics Systems", "Display Device Color Schemes" and links therein.

Q-2How can I create an IDL startup file with the commands I want to be executed automatically when I start IDL?

A-2The first two commands in the example above can be put in a personal startup file, where you can also add all other commands that you wish to be executed automatically each time IDL is started. To do so, you need to define the environment variable IDL_STARTUP as the name of the startup file.
For instance:
nedit /home/ncaon/idl.startup
... write the commands you wish to be executed automatically when you start IDL ...
setenv IDL_STARTUP /home/ncaon/idl.startup   # (csh/tcsh)
export IDL_STARTUP="/home/ncaon/idl.startup"
  # (sh/bash)

You can put the latter definition in your .cshrc or .bash_profile file.

Q-3If I have a window with an image or a plot made with IDL, and it gets covered by another window, then when I move this window off the IDL one, the image or plot is not refreshed, only a black box is left (This problem generally affects Linux machines).

A-3A detailed explanation of the problem can be found at page 4286 of the IDL 6.1 Reference Guide. The most practical solution is probably to enable the Backingstore option in the XF86Config-4 or equivalent file, by adding the line:
Option "BackingStore"
in the "Device" section.
This must be done by the superuser. The machine must then be rebooted after making this change. If this affects a IAC Linux machine, please submit this request to the CAU.

Alternatively, you can use the IDL command:
IDL> device, retain=2
to accomplish the same.

Q-4How can I add my own library with IDL procedures to IDL's PATH?

A-4The safest way is to use the idl.startup file for this. Add to such file the line:
!path = !path + ':' + expand_path("+/path/to/my/own/library")
The + sign will instruct IDL to include in the path all subdirectories within the main one. The above command may be repeated to include further directories. If you wish to check that IDL indeed has loaded the correct path, from IDL type:
IDL> print, !path
or, to display the path in a more friendly format:
IDL> print, strsplit(!PATH, path_sep(/SEARCH_PATH), /EXTRACT), FORMAT='(A)'

If you have a laptop with IDL installed following our scripts, you can add the "idl_local" library collection (includes astrolib and coyote):
!path = !path + ':' + expand_path("+/usr/pkg/rsi/idl_local")

Q-5After adding the variable IDL_PATH in my .cshrc file, following the instructions to install an IDL-based external application, IDL behaves strangely and issues unusual error messages.

A-5Sometimes some external applications based on IDL suggest that the variable IDL_PATH be set (depending on how such application is designed, the instructions in Q-4 above may not work). This must be done carefully, otherwise it may overwrite IDL's own internal paths. The best way to do this is with the shell command:
setenv IDL_PATH "+/path/indicated/by/application:<IDL_DEFAULT>"
Again, the + sign will instruct IDL to include in the path all subbdirectories within that one, while the <IDL_DEFAULT> string instructs IDL to append its own internal paths to the application's ones. Again, to check that IDL indeed has loaded the correct path, from idl type:
IDL> print, !path
This should show, for instance, a number of directories within /usr/pkg/rsi/idl_6.2 (version number and path may vary depending on your IDL installation), other directories within the ones indicated by the application installed, plus all other ones you have set in your idl.startup file.