Skip to the navigation links
Last modified: December 2009

AHELP for CIAO 4.2


Context: modules


The S-Lang interface to the CXC stack library


The stackio module is the interface between the S-Lang interpreter (see "ahelp slang") and the CXC stack library. Briefly, a stack consists of a list of strings stored in a text file (e.g. stk.lis), or a single string. In the former case, the stack is referred to via the @stk.lis convention. This will return an N-element stack, one item for each line in the input file. The latter case of a simple string, however, is also a legal stack, with a single element equal to the input string. See "ahelp stack" for more information.

This document provides an overview of the features of the stack module, and tips for using it efficiently in a S-Lang program. Detailed descriptions of each function are provided by individual ahelp pages.

The stackio module is not available by default; to use it in a S-Lang program, it must be loaded using the S-Lang require() function:


Functions provided by the module

The following functions are provided by the module; use "ahelp <function>" to get a detailed description of a function:

Function name with arguments
Stack_Type stk_build(String_Type,[Integer_Type])
Void_type stk_close(Stack_Type)
Integer_Type stk_count(Stack_Type)
Integer_Type stk_current(Stack_Type)
Integer_Type stk_set_current(Stack_Type, Integer_Type)
String_Type stk_read_next(Stack_Type)
Void_Type stk_rewind(Stack_Type)
Integer_Type stk_delete_current(Stack_Type)
Void_Type stk_disp(Stack_Type)
Integer_Type stk_delete_num(Stack_type, Integer_Type)
String_Type stk_read_num(Stack_Type, Integer_Type)
Integer_Type stk_append(Stack_Type, String_Type, [Integer_Type])
Integer_Type stk_change_current(Stack_type, String_Type)
Integer_Type stk_change_num(Stack_Type, String_Type, Integer_Type)
Stack_Type stk_expand_n(String_Type, Integer_Type)

Using Stack_Type variables

The stackio module defines a new variable type, Stack_Type, which has a complex internal structure that cannot be printed using the S-lang print() command. To see the components of a Stack_Type variable, use the stk_disp() call. Stack_Type variables can be defined using the stk_build() function, which converts a CIAO stack string into a Stack_Type variable.

Example 1

slsh> require("stackio");
slsh> stk = stk_build("acis_evt2.fits");
slsh> stk_disp(stk);
Stack position: 0
Stack size: 1
Stack allocated: 100
Stack entries:
1 :acis_evt2.fits:
slsh> () = stk_append(stk,"hrc_leg-1.fits");
slsh> () = stk_append(stk,"hrc_leg1.fits");
slsh> stk_read_num(stk,2);
slsh> stk_delete_num(stk,2);
slsh> stk_count(stk);
slsh> stk_close(stk);

Example 2

slsh> require("stackio");
slsh> stk = stk_expand_n("acisf00#.fits",4);
slsh> stk_disp(stk);
Stack position: 0
Stack size: 4
Stack allocated: 4
Stack entries:
1 :acisf001.fits:
2 :acisf002.fits:
3 :acisf003.fits:
4 :acisf004.fits:
slsh> stk_read_next(stk);
slsh> () = stk_change_num(stk,"hrc_evt2.fits",2);
slsh> stk_current(stk) ;
slsh> () = stk_delete_current(stk);
slsh> stk_append(stk,"@/data/ciao/stack.lis",1);
slsh> stk_disp(stk);
Stack position: 1
Stack size: 6
Stack allocated: 6
Stack entries:
1 :hrc_evt2.fits:
2 :acisf003.fits:
3 :acisf004.fits:
4 :/data/ciao/a.dat:
5 :/data/ciao/b.dat:
6 :/data/ciao/c.dat:
slsh> stk_close(stk);


See the bugs page for the stackio library on the CIAO website for an up-to-date listing of known bugs.

See Also

coords, level, pileup, times
autoname, ciao, ciaorc, parameter, stack, subspace
dm, dmascii, dmbinning, dmfiltering, dmopt, dmregions
stk_append, stk_build, stk_change_current, stk_change_num, stk_close, stk_count, stk_current, stk_delete_current, stk_delete_num, stk_disp, stk_expand_n, stk_read_next, stk_read_num, stk_rewind, stk_set_current
stk_build, stk_count, stk_read_num, stk_where

Last modified: December 2009