aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/ptools/prenumber.cl
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/digiphot/ptools/prenumber.cl
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/digiphot/ptools/prenumber.cl')
-rw-r--r--noao/digiphot/ptools/prenumber.cl50
1 files changed, 50 insertions, 0 deletions
diff --git a/noao/digiphot/ptools/prenumber.cl b/noao/digiphot/ptools/prenumber.cl
new file mode 100644
index 00000000..2a174275
--- /dev/null
+++ b/noao/digiphot/ptools/prenumber.cl
@@ -0,0 +1,50 @@
+# PRENUMBER - Renumber the ID column of an APPHOT/DAOPHOT database from 1 to
+# N where N is the number of objects in the database. The renumbering is
+# done in place.
+
+procedure prenumber (infile)
+
+string infile {prompt="Input apphot/daophot databases(s) to be renumbered"}
+int idoffset {0, min=0, prompt="Id number offset"}
+string id {"ID", prompt="Id name keyword"}
+
+struct *inlist
+
+begin
+ # Local variable declarations.
+ file tmpin
+ string in, inname, expr
+
+ # Cache the istable parameters.
+ cache ("istable")
+
+ # Get the positional parameters.
+ in = infile
+ expr = "rownum + " // idoffset
+
+ # Expand the file list names.
+ tmpin = mktemp ("tmp$")
+ files (in, sort=no, > tmpin)
+
+ # Loop over each file in the input and output lists selecting records.
+ inlist = tmpin
+ while (fscan (inlist, inname) != EOF) {
+ istable (inname)
+ if (istable.table) {
+ if (defpar ("tcalc.verbose") || defpar ("tcalc.harmless")) {
+ tcalc (inname, id, expr, datatype="real", colunits="",
+ colfmt="", verbose=no, harmless=0.1)
+ } else {
+ tcalc (inname, id, expr, datatype="real", colunits="",
+ colfmt="")
+ }
+ } else if (istable.text) {
+ txrenumber (inname, idoffset=idoffset, id=id)
+ } else {
+ print ("Cannot run PRENUMBER on file: " // inname)
+ }
+ }
+ inlist = ""
+
+ delete (tmpin, ver-, >& "dev$null")
+end