aboutsummaryrefslogtreecommitdiff
path: root/sys/mwcs/mwopen.x
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 /sys/mwcs/mwopen.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/mwcs/mwopen.x')
-rw-r--r--sys/mwcs/mwopen.x81
1 files changed, 81 insertions, 0 deletions
diff --git a/sys/mwcs/mwopen.x b/sys/mwcs/mwopen.x
new file mode 100644
index 00000000..7841f904
--- /dev/null
+++ b/sys/mwcs/mwopen.x
@@ -0,0 +1,81 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <syserr.h>
+include <error.h>
+include "mwcs.h"
+
+# MW_OPEN -- Create a new MWCS descriptor. If the non-NULL address of a
+# buffer containing a saved MWCS is given, the saved MWCS will be loaded,
+# otherwise a unitary MWCS of the indicated dimension is created.
+
+pointer procedure mw_open (bufptr, ndim)
+
+pointer bufptr #I pointer to encoded MWCS, or NULL
+int ndim #I dimension of system to be created
+
+int i
+pointer mw, wp
+int mw_allocd()
+errchk calloc, mw_load, syserrs, mw_allocd
+string s_physical "physical"
+
+begin
+ # Initialize the function drivers.
+ call wf_init()
+
+ # Allocate the base descriptor.
+ call calloc (mw, LEN_MWCS, TY_STRUCT)
+
+ # Load saved MWCS, if one was given.
+ if (bufptr != NULL) {
+ call mw_load (mw, bufptr)
+ return (mw)
+ }
+
+ # Initialize the new descriptor to a unitary transform of dimension
+ # NDIM. Most of this is accomplished by merely creating a zeroed
+ # descriptor.
+
+ if (ndim < 1 || ndim > MAX_DIM) {
+ call mfree (mw, TY_STRUCT)
+ call syserrs (SYS_MWNDIM, "mw_open")
+ }
+
+ MI_MAGIC(mw) = MWCS_MAGIC
+ MI_NDIM(mw) = ndim
+ MI_NLOGDIM(mw) = ndim
+ MI_LTV(mw) = mw_allocd (mw, ndim)
+ MI_LTM(mw) = mw_allocd (mw, ndim * ndim)
+ call mw_mkidmd (D(mw,MI_LTM(mw)), ndim)
+ do i = 1, ndim {
+ MI_AXNO(mw,i) = i
+ MI_PHYSAX(mw,i) = i
+ }
+
+ # Set up the builtin world systems "physical" and "logical".
+ # Both are linear systems. The physical system is a unitary
+ # transformation (since world systems are defined relative to
+ # the physical system), and the logical system has the Lterm
+ # for its linear term. No wcs attributes other than wtype are
+ # defined.
+
+ # Create the physical system.
+ call mw_newsystem (mw, s_physical, ndim)
+ do i = 1, ndim
+ call mw_swtype (mw, i, 1, "linear", "")
+
+ # Create the logical system.
+ call mw_newsystem (mw, "logical", ndim)
+ do i = 1, ndim
+ call mw_swtype (mw, i, 1, "linear", "")
+
+ # Set W and CD for the logical system to point to the Lterm.
+ wp = MI_WCS(mw)
+ WCS_W(wp) = MI_LTV(mw)
+ WCS_CD(wp) = MI_LTM(mw)
+
+ # Set the default world system.
+ call mw_sdefwcs (mw)
+
+ return (mw)
+end