aboutsummaryrefslogtreecommitdiff
path: root/noao/twodspec/apextract/apcvset.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 /noao/twodspec/apextract/apcvset.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/twodspec/apextract/apcvset.x')
-rw-r--r--noao/twodspec/apextract/apcvset.x47
1 files changed, 47 insertions, 0 deletions
diff --git a/noao/twodspec/apextract/apcvset.x b/noao/twodspec/apextract/apcvset.x
new file mode 100644
index 00000000..656187d5
--- /dev/null
+++ b/noao/twodspec/apextract/apcvset.x
@@ -0,0 +1,47 @@
+include <math/curfit.h>
+include "apertures.h"
+
+# AP_CVSET -- Set the trace curve.
+# If the input template aperture is NULL then the output trace curve
+# is set to a constant zero otherwise a copy from the input template
+# aperture is made.
+
+procedure ap_cvset (apin, apout)
+
+pointer apin # Input template aperture
+pointer apout # Output aperture
+
+int apaxis, dispaxis, ncoeffs
+real a, b, c[1]
+pointer sp, coeffs
+
+int cvstati()
+
+begin
+ if (AP_CV(apout) != NULL)
+ call cvfree (AP_CV(apout))
+
+ if (apin == NULL) {
+ # Determine the aperture and alternate axes.
+ apaxis = AP_AXIS(apout)
+ dispaxis = mod (apaxis, 2) + 1
+
+ # Determine the limits over which the curve is defined.
+ a = AP_CEN(apout, dispaxis) + AP_LOW(apout, dispaxis)
+ b = AP_CEN(apout, dispaxis) + AP_HIGH(apout, dispaxis)
+ if (a == b)
+ b = b + 1
+
+ # Set the curve to a legendre polynomial of order 1 and value 0.
+ c[1] = 0.
+ call cvset (AP_CV(apout), LEGENDRE, a, b, c, 1)
+ } else {
+ # Use a SAVE and RESTORE to copy the CURFIT data.
+ call smark (sp)
+ ncoeffs = cvstati (AP_CV(apin), CVNSAVE)
+ call salloc (coeffs, ncoeffs, TY_REAL)
+ call cvsave (AP_CV(apin), Memr[coeffs])
+ call cvrestore (AP_CV(apout), Memr[coeffs])
+ call sfree (sp)
+ }
+end