Ocean Biogeochemistry Lab
| home | people | research | courses | facilities
| projects | protocols | publications | tools/links

Home > Research > Tools > SeaDAS Tips & Tricks

SeaDAS/IDL (and some Unix) Tips & Tricks

SeaDAS is an IDL based software package used mainly for SeaWiFS and MODIS satellite image processing. Below some SeaDAS and IDL tips & tricks. A few might only be applicable to 'ocean', our Sun server. SeaDAS help: index [on ocean], command mode overview [on ocean]. On-line IDL help can be found here.

SeaDAS Band to IDL Array - A not documented handy command to get the data of a loaded band into an array which can be manipulated from the command line (instead of using the mband_cmd function). I also created the function 'get_band.pro' to store banddata into an IDL array. This is a very useful function when you want to work with blotches from the command-line or scripts. Simple example: quickly check if there are any valid data in your scene so you don't have to do any further analyses:

   band_no = 1   ; loaded band number
   sdp_band_get,band_no, banddata   ; store 'raw data' into array banddata
   geodata = sdp_raw2geo(band_no, banddata)  ; convert 'raw data' to geophysical values
   if (max(geodata) gt 0)then begin
       ; "do all kinds of things"

IDL Array to SeaDAS Band - The opposite of above. To get an IDL array into the SeaDAS bandlist. Simple example: you have a quality flag loaded in an array, qual, geolocation data similar to those in band 1.

   sdp_add_band_entry, qual, nav_band=1
You can also include units, bandname (usually "product : filename"), etc. Usage: SDP_ADD_BAND_ENTRY, banddata, info_band=info_band, nav_band=nav_band, FILENAME=filename, PRODNAME=prodname, BANDNAME=i_bandname, si=i_si, scale_type=i_scale_type, units=i_units (see file: $SEADAS/idl_lib/sdp_add_band_entry.pro)

Value at Specific Latitude/Longitude - Looking for the data at one specific station and don't know the 'pixel/line'? Without using 'Cursor Position' or 'Read and Profile' display functions you can use the sdp_nav_ll2tv function from the command line. Example below is using same loaded band and geodata as in first example above:

   lat = 30. & lon = -150  ; latitude/longitude of station
   sdp_nav_ll2tv, tmp, lat, lon, pix, lin, band=band_no
   station_value = geodata(pix-1, lin-1) ; have to subtract 1 from pixel and line since SeaDAS
                                         ; array index start with 1,1 and IDL with 0,0

Adjusting Maximum Value - The chlorophyll algorithm used can give unreasonable high concentration of 200 mg/m^3 and higher. Using the following code the values higher then 30 of loaded band 1 are reset to 30 with the mband_cmd program:

   cmd = ['result=b1','gt30=where(b1 gt 30., count)',  $
          'if(count gt 0) then result(gt30)=30.']
   new_band = 'chlor_a (max 30)'
   mband_cmd, cmd_array=cmd, bandname=new_band, navband=1, units='mg/m^3'

Removing specific bands - With the command 'clear_up' all bands are removed from the bandlist. If you want to remove specific bands and keep some, use the command: sdp_band_remove, num, where num is the band number you want to remove (relative to 0, so if you want to remove the thrid band in the list, num=2).

Stuck SeaDAS - When you get errors like '% Execution halted at: ...' try a combination of .skip, .out, .return or return (or retall) to get back to the main level. First try to skip a lot of lines to get to the end of that script by typing .skip 1000 (which will skip 1000 lines, more then there probably are in the script), then try .return and/or .out to get back to $MAIN$. If all fails kill the process (the process number is included in the main SeaDAS menu window title). When you run SeaDAS in batch mode (-b option) you can retrieve the process number as below (it's not the same process id as you find with 'ps -ef | grep seadas'). Put it at some strategic places in your script so it prints to the screen from time to time so you can easily find it.
   ; get SeaDAS pid
   c4idl_slib = getenv('SEADAS') + '/bin/IDLshare.so'
   pid = call_external(c4idl_slib, 'idl_pid')
   pid = strtrim(string(pid),2)

Another way to identify your session is to put the xterm number (tty) in the title bar of the xterm window. When you do a 'ps' you can then easily see on which terminal window a process is running. This is especially handy when you have more then one SeaDAS/IDL session running and you don't want to kill the wrong one. Do this by using the xtitle command. Put the following 3 commands in your ~/.login file:
   if ($TERM == 'xterm') then
    xtitle $HOST xterm \($tty\) > /dev/$tty

Changing the Cursor - Is your mouse cursor almost invisible when you go over an image window (like when using IDL/SeaDAS with X11 under Mac OS X)? Change it to something more clear by typing at the IDL/SeaDAS commandline: device, cursor_standard=32, which will change the default cursor (30, cross) to cross_reverse. Look in the file /usr/include/X11/cursorfont.h for many more choices, ranging from a pirate-cursor to sailboat-cursor.

Manipulating Color Table without xpalette - If you load a specific SeaDAS color lookup table with IDL and you want to change some colors, like adding white, you can do it with the xpalette gui. In scripts that is not really pratical. However, you can change colors with the tvlct command. For example if you want to change color index number 255 to white, use: tvlct, 255,255, 255, 255, that is: tvlct, R-value, G-value, B-value, colorindex-value-to-change. To put a colorbar on your image, use David Fanning's versatile colorbar script, called: cgcolorbar. Use ncolors to exclude the above changed colors from your colorbar.

Beep - If you want to be alerted when you script is done, just make it beep by putting the following line at the end of the program: print, string(7B) [or use the undocumented IDL command 'beep']. Or, to make it more distinguishable from other system beeps, make it beep 3 times:

   for i=0,2 do begin
       print, string(7B) & wait, 1

Loop from the Commandline - Normally it is hard to invoke a loop directly from the command line. But with the .run command you can enter a little program. Great for testing scripts. Example:

   - for i=0,2 do begin
   - print, i
   - endfor
   - end
Another way to do it with ending all lines (except the last) with '& $', like:
  for i=0,2 do begin & $
  print, i & $

Some custom made scripts:

Bonus Excel Tip:
Reference a cell by the value in another cell. Example: value A1 = 5, then =INDIRECT("B" & A1) will return value in B5. It is more useful than you think. See some examples at cpearson.com.

Page by: Gert van Dijken