![]() |
sread - Read a spectrum from file |
![]() |
|---|
sread [-format fmt] [-[no]snapshot] [-[no]replace] [-[no]bind] file
Reads a spectrum either from a file specified by name or a file opened with the Tcl open command.
The next spectrum in the file parameter is read. The file parameter can either be a path to a file, or a handle returned from the Tcl open command. If the file is a path, the file is opened, the first spectrum read, and then the file is closed. If the file parameter is a Tcl file handle, the next spectrum at the current position in the file is read, and the file remains open for further I/O.
The -format switch specifies the format of the spectrum in the file. The default is ascii.
| Format Specifier | Format |
| ascii | NSCL ASCII formatted file. |
| binary | NSCL Binary (SMAUG) formatted file. |
| nsclascii | NSCL ASCII formatted file. |
| nsclbinary | NSCL Binary (SMAUG) formatted file. |
SpecTcl's Spectrum I/O facility is user extensible. The set of file formats supported by sread for any build of SpecTcl can be gotten by just typing:
sread
What is done with the spectrum read in depends on the the state of the switches:
| Switch | Default | Action |
| -[no]snapshot | -snapshot | |
| -[no]replace | -noreplace | |
| -[no]bind | -bind |
swrite -format ascii /usr/users/TruCluster/users/fox/test.asc spec1 spec2 spec3
The spectra specified by spec1, spec2, spec3 are written in that order to the file /usr/users/TruCluster/users/fox/test.asc in NSCL ascii format.
This example reads the file created by the first example in the swrite command page.
set file [open ~/test.asc r] gets $file var sread -format ascii $file sread -format ascii $file gets $file var sread -format binary $file close $file
This example reads the gzipped spectra created by the second example in the swrite command page
set file [open {|gzcat /usr/users/TruCluster/users/fox/test.asc} r]
sread -format ascii $file
sread -format ascii $file
sread -format ascii $file
close $file
Writes the spectra spec1, spec2 and spec3 to a pipe into gzip in ascii form. The gzip pipe compresses this file producing /usr/users/Trucluster/users/fox/test.asc
Last Modified: October 28, 2003
by: fox@nscl.msu.edu
© Copyright NSCL 1999, All rights reserved