diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/digiphot/ptools/txtools/t_txrenumber.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'noao/digiphot/ptools/txtools/t_txrenumber.x')
-rw-r--r-- | noao/digiphot/ptools/txtools/t_txrenumber.x | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/noao/digiphot/ptools/txtools/t_txrenumber.x b/noao/digiphot/ptools/txtools/t_txrenumber.x new file mode 100644 index 00000000..2b41d541 --- /dev/null +++ b/noao/digiphot/ptools/txtools/t_txrenumber.x @@ -0,0 +1,65 @@ +include <fset.h> + +# T_TXRENUMBER -- Procedure to renumber standard APPHOT and DAOPHOT text +# output files. The ST TTOOLS task can be used for binary format. +# The program assumes that there is a column labelled ID. + +procedure t_txrenumber () + +pointer tp_in # pointer to the input table +pointer tp_out # pointer to the output table +pointer id # name of the id column + +int inlist, nrecs, idoffset +pointer sp, infile, outfile +int clpopnu(), clgeti(), clgfil(), access(), open(), fstati(), pt_renumber() + +begin + # Set the standard output to flush on newline. + if (fstati (STDOUT, F_REDIR) == NO) + call fseti (STDOUT, F_FLUSHNL, YES) + + # Get some memory. + call smark (sp) + call salloc (infile, SZ_FNAME, TY_CHAR) + call salloc (outfile, SZ_FNAME, TY_CHAR) + call salloc (id, SZ_FNAME, TY_CHAR) + + # Get the various task parameters. + inlist = clpopnu ("textfiles") + idoffset = clgeti ("idoffset") + call clgstr ("id", Memc[id], SZ_FNAME) + call strlwr (Memc[id]) + + # Loop over the input files. + while (clgfil (inlist, Memc[infile], SZ_FNAME) != EOF) { + + # Open the input file. + if (access (Memc[infile], 0, TEXT_FILE) == YES) + tp_in = open (Memc[infile], READ_ONLY, TEXT_FILE) + else + next + + # Open an output text file. + call mktemp ("temp", Memc[outfile], SZ_FNAME) + tp_out = open (Memc[outfile], NEW_FILE, TEXT_FILE) + + # Renumber the stars. + nrecs = pt_renumber (tp_in, tp_out, idoffset, Memc[id]) + + # Close up the input and output files. + call close (tp_in) + call close (tp_out) + + # Rename the files. + if (nrecs <= 0) + call delete (Memc[outfile]) + else { + call delete (Memc[infile]) + call rename (Memc[outfile], Memc[infile]) + } + } + + call clpcls (inlist) + call sfree (sp) +end |