The format of .stk files

The program pca_gui.pro was written to accept pre-aligned image sequences as stack .stk files from the program stack_analyze.pro. We provide here the information on how these files are created, so that one can create a .stk file from another program.

The file format is most easily explained using a snippet of IDL code:

  get_lun,lun
  openw,lun,'myfile.stk',/xdr
The file is opened in Sun XDR format, which simply means that all binary data is written in ``network'' byte order (the same thing that the C routines htonl() and htons() accomplish, so that one could write out a .stk file from any computer language.).

Next, one writes as 32 bit integers the number of pixels in the $x$ direction as n_cols, and in the $y$ direction as n_rows. This is followed with the number of energy points as n_ev:

  writeu,lun,long(n_cols),long(n_rows),long(n_ev)

One now writes the arrays x_dist (single-precision floating point data with n_cols values) and y_dist (n_rows values) of pixel center positions in microns. This is followed by the arrays ev and msec, each with n_ev values. Note that pca_gui ignores the msec array, so you can always write out n_ev floating point zeroes for it.

  writeu,lun,float(x_dist),float(y_dist),float(ev),float(msec)

Finally, you write out the image stack. This is an array of floating point values of transmitted flux arranged in a 3D array of dimensions [n_cols,n_rows,n_ev].

  writeu,lun,float(image_stack)
After writing out image_stack, the IDL commands used to close the file are
  close,lun
  free_lun,lun

Holger Fleckenstein 2008-07-08