About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: December 2007

URL: http://cxc.harvard.edu/ciao4.0/stackio.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 4.0 stackio Context: modules

Synopsis

The S-Lang interface to the CXC stack library

Description

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:

  require("stackio");

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);
hrc_leg-1.fits
slsh> stk_delete_num(stk,2);
slsh> stk_count(stk);
2
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);
acisf001.fits
slsh> () = stk_change_num(stk,"hrc_evt2.fits",2);
slsh> stk_current(stk) ;
1
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);

Bugs

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

Hardcopy (PDF): A4 | Letter
Last modified: December 2007



The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.