aboutsummaryrefslogtreecommitdiff
path: root/local/src
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /local/src
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'local/src')
-rw-r--r--local/src/README75
-rw-r--r--local/src/bswap.par3
-rw-r--r--local/src/bswap.x42
-rwxr-xr-xlocal/src/doc/bswap.hlp36
-rw-r--r--local/src/doc/pavg.hlp29
-rw-r--r--local/src/local.cl10
-rw-r--r--local/src/local.hd7
-rw-r--r--local/src/local.men2
-rw-r--r--local/src/local.par3
-rw-r--r--local/src/mkpkg27
-rw-r--r--local/src/pavg.par1
-rw-r--r--local/src/pavg.x45
-rw-r--r--local/src/x_local.x6
13 files changed, 286 insertions, 0 deletions
diff --git a/local/src/README b/local/src/README
new file mode 100644
index 00000000..7ca0cb0f
--- /dev/null
+++ b/local/src/README
@@ -0,0 +1,75 @@
+LOCAL -- Locally added tasks and packages.
+
+ The LOCAL package is a place to put locally added tasks and packages
+without modifying the standard IRAF system (and thereby complicating future
+updates and so on). The LOCAL provided with the distributed system is a
+template package provided to make it as easy as possible for user sites to
+set up their own custom LOCAL packages.
+
+To create a custom LOCAL package:
+
+ [1] Copy the template package directory tree (iraf$local) to a new
+ directory somewhere outside the iraf directories. DO NOT MODIFY
+ THE TEMPLATE LOCAL, CREATE AN EXTERNAL COPY AND MODIFY THAT INSTEAD.
+ This is necessary to ensure that your custom local is unaffected by
+ updates to the core IRAF system.
+
+ [2] Edit the pathame of local in the "reset local = ..." statement in the
+ IRAF file hlib$extern.pkg, replacing the "iraf$local/" by the host
+ pathname of the root directory of your custom LOCAL. Be sure to
+ include the trailing / on UNIX systems, or escape $ and [ on VMS
+ systems. All references to LOCAL will now refer to your custom
+ version of LOCAL, rather than to the template version provided with
+ the distributed system.
+
+To add a new task to LOCAL:
+
+ [1] Add the source and parameter file if any to this directory, e.g.,
+ mytask.x, mytask.par.
+
+ [2] Add the name of the new task to x_local.x. Any number of tasks may
+ be added to the package in this way.
+
+ task pavg = t_pavg,
+ mytask = t_mytask
+
+ [3] Add the manual page for the task to the `doc' subdirectory, e.g.,
+ file doc/mytask.hlp. Add entries for the new task to local.hd
+ (so that HELP can find the new manual page) and local.men (so that
+ the task will be listed when `help local' is entered). Load the
+ softools package and run `mkhelpdb' to recompile the help database
+ else HELP will not know about the new manual page.
+
+ cl> mkhelpdb local$lib/root.hd local$lib/helpdb.mip
+
+ [4] Add an entry for all source files to the library member list in
+ the mkpkg file in this directory. List any include files referenced
+ in the source file to the right of the source file name.
+
+ libpkg.a:
+ pavg.x <imhdr.h>
+ mytask.x
+ ;
+
+ [5] Add an entry for the new task in local.cl, so that the CL will
+ know about the new task when the LOCAL package is loaded. Prefix
+ the task name with a dollar sign ($mytask) if the new task does
+ not have an associated parameter (.par) file.
+
+ task pavg,
+ mytask = "local$src/x_local.e"
+
+ [6] Enter the command `mkpkg -p local' to compile and link the new package
+ executable `x_local.e'. After testing the new task, install the new
+ package executable in bin$ with the command `mkpkg -p local install'.
+
+You should now be able to load the LOCAL package in the CL, and run the new
+task, or get help for any of the LOCAL package tasks.
+
+Any number of tasks may be added to your custom LOCAL package in this fashion.
+Host programs and IMFORT programs may also be added, modifying the task
+statements and mkpkg compile/link instructions appropriately (if used).
+Subpackages should be used to group like tasks if the LOCAL grows large
+enough. For more information on program development in IRAF, refer to the
+SOFTOOLS package help pages for xc, mkpkg, etc., the SPP/VOS technical
+documentation, the IMFORT manual, and so on.
diff --git a/local/src/bswap.par b/local/src/bswap.par
new file mode 100644
index 00000000..815d00dd
--- /dev/null
+++ b/local/src/bswap.par
@@ -0,0 +1,3 @@
+input,f,a,,,,"input file"
+output,f,a,,,,"output file"
+wordswap,b,h,no,,,"swap every 4 bytes rather than every 2 bytes"
diff --git a/local/src/bswap.x b/local/src/bswap.x
new file mode 100644
index 00000000..d9fad447
--- /dev/null
+++ b/local/src/bswap.x
@@ -0,0 +1,42 @@
+include <mach.h>
+
+define SZ_IOBUF 2048
+
+
+# BSWAP -- Copy a file, swapping the bytes.
+
+procedure t_bswap()
+
+bool wordswap
+int in, out, nchars
+pointer sp, input, output, bp
+int open(), read()
+bool clgetb()
+
+begin
+ call smark (sp)
+ call salloc (input, SZ_FNAME, TY_CHAR)
+ call salloc (output, SZ_FNAME, TY_CHAR)
+ call salloc (bp, SZ_IOBUF, TY_CHAR)
+
+ call clgstr ("input", Memc[input], SZ_FNAME)
+ call clgstr ("output", Memc[output], SZ_FNAME)
+ wordswap = clgetb ("wordswap")
+
+ in = open (Memc[input], READ_ONLY, BINARY_FILE)
+ out = open (Memc[output], NEW_FILE, BINARY_FILE)
+
+ repeat {
+ nchars = read (in, Memc[bp], SZ_IOBUF)
+ if (nchars > 0) {
+ if (wordswap)
+ call bswap4 (Memc[bp], 1, Memc[bp], 1, nchars * SZB_CHAR)
+ else
+ call bswap2 (Memc[bp], 1, Memc[bp], 1, nchars * SZB_CHAR)
+ call write (out, Memc[bp], nchars)
+ }
+ } until (nchars == EOF)
+
+ call close (in)
+ call close (out)
+end
diff --git a/local/src/doc/bswap.hlp b/local/src/doc/bswap.hlp
new file mode 100755
index 00000000..779105de
--- /dev/null
+++ b/local/src/doc/bswap.hlp
@@ -0,0 +1,36 @@
+.help bswap Mar89 local
+.ih
+NAME
+bswap - swap the bytes in a file
+.ih
+USAGE
+bswap input output
+.ih
+PARAMETERS
+.ls input
+The file to be swapped.
+.le
+.ls output
+The name of the output swapped file.
+.le
+.ls wordswap = no
+Swap four-byte longwords rather than pairs of bytes.
+.le
+.ih
+DESCRIPTION
+The \fIbswap\fR task reads the input file as a binary file,
+writing the result to the output file.
+Successive byte pairs are interchanged if \fIwordswap\fR=no,
+otherwise the four bytes within each successive longword are swapped.
+.ih
+EXAMPLES
+1. Byte swap file A, writing the result to file B.
+
+ cl> bswap a b
+.ih
+BUGS
+The input and output files cannot be the same.
+.ih
+SEE ALSO
+dataio.reblock
+.endhelp
diff --git a/local/src/doc/pavg.hlp b/local/src/doc/pavg.hlp
new file mode 100644
index 00000000..d0c29185
--- /dev/null
+++ b/local/src/doc/pavg.hlp
@@ -0,0 +1,29 @@
+.help pavg Apr86 local
+.ih
+NAME
+pavg - plot the average of the lines of an image or image section
+.ih
+USAGE
+pavg image
+.ih
+PARAMETERS
+.ls image
+The image or image section to be averaged and plotted.
+.le
+.ih
+DESCRIPTION
+The \fIpavg\fR task averages the lines of the given image or image section
+and plots the result on the standard graphics output.
+.ih
+EXAMPLES
+1. Plot line 125 of the standard test image "dev$pix".
+
+ cl> pavg dev$pix[*,125]
+
+2. Plot the average of lines 100 through 200 of the same image.
+
+ cl> pavg dev$pix[*,100:200]
+.ih
+SEE ALSO
+plot.*
+.endhelp
diff --git a/local/src/local.cl b/local/src/local.cl
new file mode 100644
index 00000000..41e2b092
--- /dev/null
+++ b/local/src/local.cl
@@ -0,0 +1,10 @@
+#{ Package script task for the LOCAL package. Add task declarations here
+# for any locally added tasks or subpackages.
+
+cl < "local$lib/zzsetenv.def"
+package local, bin=localbin$
+
+task bswap,
+ pavg = "local$src/x_local.e"
+
+clbye()
diff --git a/local/src/local.hd b/local/src/local.hd
new file mode 100644
index 00000000..04117f92
--- /dev/null
+++ b/local/src/local.hd
@@ -0,0 +1,7 @@
+# Help directory for the LOCAL package.
+
+$defdir = "local$src/"
+$doc = "local$src/doc/"
+
+bswap hlp=doc$bswap.hlp, src=bswap.x
+pavg hlp=doc$pavg.hlp, src=pavg.x
diff --git a/local/src/local.men b/local/src/local.men
new file mode 100644
index 00000000..bb82ed45
--- /dev/null
+++ b/local/src/local.men
@@ -0,0 +1,2 @@
+ bswap - Swap the bytes in a file
+ pavg - Plot the average of the lines of an image or image section
diff --git a/local/src/local.par b/local/src/local.par
new file mode 100644
index 00000000..66d02acc
--- /dev/null
+++ b/local/src/local.par
@@ -0,0 +1,3 @@
+# Dummy LOCAL package parameter file.
+
+version,s,h,"Mar89"
diff --git a/local/src/mkpkg b/local/src/mkpkg
new file mode 100644
index 00000000..5b86e2fe
--- /dev/null
+++ b/local/src/mkpkg
@@ -0,0 +1,27 @@
+# Make the LOCAL package.
+
+$call relink
+$exit
+
+update:
+ $call relink
+ $call install
+ ;
+
+relink:
+ $set LIBS = "-lxtools"
+
+ $update libpkg.a
+ $omake x_local.x
+ $link x_local.o libpkg.a $(LIBS) -o xx_local.e
+ ;
+
+install:
+ $move xx_local.e pkgbin$x_local.e
+ $purge pkgbin$
+ ;
+
+libpkg.a:
+ bswap.x <mach.h>
+ pavg.x <imhdr.h>
+ ;
diff --git a/local/src/pavg.par b/local/src/pavg.par
new file mode 100644
index 00000000..61e9e430
--- /dev/null
+++ b/local/src/pavg.par
@@ -0,0 +1 @@
+image,s,a,,,,Image from which to plot average of lines
diff --git a/local/src/pavg.x b/local/src/pavg.x
new file mode 100644
index 00000000..7124c4d0
--- /dev/null
+++ b/local/src/pavg.x
@@ -0,0 +1,45 @@
+include <imhdr.h>
+
+# PAVG -- CL callable task to plot the average of the lines of an image or
+# image section on the standard graphics output. This example is taken from
+# the IRAF paper.
+
+procedure t_pavg()
+
+char image[SZ_FNAME] # name of image to be plotted
+char title[SZ_LINE]
+int npix, nlines
+long v[IM_MAXDIM]
+pointer im, lineptr, sumv
+pointer immap(), imgnlr()
+
+begin
+ # Fetch image name from CL and open the image. The IMMAP
+ # function returns a pointer to the image descriptor structure.
+
+ call clgstr ("image", image, SZ_FNAME)
+ im = immap (image, READ_ONLY, 0)
+
+ # Allocate a zeroed buffer of length NPIX for the sum-vector,
+ # and set V to point to first image line, i.e., v=[1,1,1,...].
+
+ npix = IM_LEN(im,1)
+ call calloc (sumv, npix, TY_REAL)
+ call amovkl (long(1), v, IM_MAXDIM)
+
+ # Sum the lines of the image.
+ for (nlines=0; imgnlr(im,lineptr,v) != EOF; nlines=nlines+1)
+ call aaddr (Memr[lineptr], Memr[sumv], Memr[sumv], npix)
+
+ # Normalize the sum-vector to get the average.
+ call adivkr (Memr[sumv], real(nlines), Memr[sumv], npix)
+
+ # Format plot title and plot the sum-vector on STDGRAPH.
+ call sprintf (title, SZ_LINE, "Line Average of %s")
+ call pargstr (image)
+ call gplotv (Memr[sumv], npix, 1., real(npix), title)
+
+ # Free storage for sum-vector and close image.
+ call mfree (sumv, TY_REAL)
+ call imunmap (im)
+end
diff --git a/local/src/x_local.x b/local/src/x_local.x
new file mode 100644
index 00000000..02b52027
--- /dev/null
+++ b/local/src/x_local.x
@@ -0,0 +1,6 @@
+# Task declaration for the LOCAL package. To add new task entries, add a
+# comma to the last line and a new line "mytask = t_mytask". In the task
+# sourcefile the main procedure should be named "procedure t_mytask".
+
+task bswap = t_bswap,
+ pavg = t_pavg