aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/wspectext.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/onedspec/wspectext.cl
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/onedspec/wspectext.cl')
-rw-r--r--noao/onedspec/wspectext.cl47
1 files changed, 47 insertions, 0 deletions
diff --git a/noao/onedspec/wspectext.cl b/noao/onedspec/wspectext.cl
new file mode 100644
index 00000000..9a7e1571
--- /dev/null
+++ b/noao/onedspec/wspectext.cl
@@ -0,0 +1,47 @@
+# WSPECTEXT -- Write a 1D image spectrum as an ascii text file.
+# This simply uses WTEXTIMAGE to write the header is selected and
+# formats the wavelength/flux data using LISTPIX.
+
+procedure wspectext (input, output)
+
+string input {prompt="Input list of image spectra"}
+string output {prompt="Output list of text spectra"}
+bool header = yes {prompt="Include header?"}
+string wformat = "" {prompt="Wavelength format"}
+
+begin
+ int ndim
+ string specin, specout, spec
+
+ specin = mktemp ("tmp$iraf")
+ specout = mktemp ("tmp$iraf")
+ spec = mktemp ("tmp$iraf")
+
+ # Expand the input and output image templates and include naxis.
+ hselect (input, "$I,naxis", yes, > specin)
+ sections (output, option="fullname", > specout)
+ join (specin, specout, output=spec, delim=" ", shortest=yes, verbose=yes)
+ delete (specin, verify=no)
+ delete (specout, verify=no)
+
+ # For each input spectrum check the dimensionality. Extract the header
+ # with WTEXTIMAGE if desired and then use LISTPIX to extract the
+ # wavelengths and fluxes.
+
+ list = spec
+ while (fscan (list, specin, ndim, specout) != EOF) {
+ if (ndim != 1) {
+ print ("WARNING: "//specin//" is not one dimensional")
+ next
+ }
+ if (header) {
+ wtextimage (specin, specout, header=yes, pixels=no, format="",
+ maxlinelen=80)
+ listpixels (specin, wcs="world", formats=wformat, verbose=no,
+ >> specout)
+ } else
+ listpixels (specin, wcs="world", formats=wformat, verbose=no,
+ > specout)
+ }
+ list=""; delete (spec, verify=no)
+end