aboutsummaryrefslogtreecommitdiff
path: root/noao/twodspec/multispec/msplot.x
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 /noao/twodspec/multispec/msplot.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'noao/twodspec/multispec/msplot.x')
-rw-r--r--noao/twodspec/multispec/msplot.x104
1 files changed, 104 insertions, 0 deletions
diff --git a/noao/twodspec/multispec/msplot.x b/noao/twodspec/multispec/msplot.x
new file mode 100644
index 00000000..4e02367f
--- /dev/null
+++ b/noao/twodspec/multispec/msplot.x
@@ -0,0 +1,104 @@
+include <imhdr.h>
+include "ms.h"
+
+# MSPLOT -- Plot image and model values.
+#
+# The output list format is column, image line, data value, model value.
+# This task differs from t_new_image primarily in that there is no profile
+# interpolation. The model is evaluated only at the sample lines. It
+# is used to check the results of the model fitting tasks.
+
+procedure msplot ()
+
+char image[SZ_FNAME] # Image
+int line # Image line to plot
+int naverage # Number of image lines to average
+real lower # Lower limit of profile model
+real upper # Upper limit of profile model
+
+int sample
+pointer ms, im
+pointer sp, data, model
+
+int clgeti(), get_sample_line
+real clgetr()
+pointer msmap(), immap()
+
+begin
+ # Get the task parameters.
+
+ call clgstr ("image", image, SZ_FNAME)
+ line = clgeti ("line")
+ naverage = clgeti ("naverage")
+ lower = clgetr ("lower")
+ upper = clgetr ("upper")
+
+ # Access the database and image.
+
+ ms = msmap (image, READ_ONLY, 0)
+ im = immap (image, READ_ONLY, 0)
+
+ # Allocate memory for the data and model.
+
+ call smark (sp)
+ call salloc (data, IM_LEN(im, 1), TY_REAL)
+ call salloc (model, IM_LEN(im, 1), TY_REAL)
+
+ sample = get_sample_line (ms, line)
+ line = LINE(ms, sample)
+ call msgimage (im, line, naverage, Memr[data])
+ call gauss5_model (ms, sample, lower, upper, Memr[model])
+
+ call ms_graph (Memr[data], Memr[model], IM_LEN(im, 1))
+
+ call sfree (sp)
+ call msunmap (ms)
+ call imunmap (im)
+end
+
+
+include <gset.h>
+
+# MS_GRAPH -- For the selected line get the data line and compute a model line.
+# Graph the data and model values.
+
+procedure ms_graph (data, model, npts)
+
+real data[npts] # Image data
+real model[npts] # Model data
+int npts # Number of data points
+
+char str[SZ_LINE]
+real x1, x2
+pointer gp, gt
+
+real wx, wy # Cursor position
+int wcs, key # WCS and cursor key
+
+int gt_gcur()
+pointer gopen(), gt_init()
+
+begin
+ call clgstr ("graphics", str, SZ_LINE)
+ gp = gopen (str, NEW_FILE, STDGRAPH)
+ gt = gt_init ()
+
+ x1 = 1
+ x2 = npts
+ call gswind (gp, x1, x2, INDEF, INDEF)
+ call gascale (gp, data, npts, 2)
+ call grscale (gp, model, npts, 2)
+ call gt_swind (gp, gt)
+ call gt_labax (gp, gt)
+
+ call gseti (gp, G_PLTYPE, 1)
+ call gvline (gp, data, npts, x1, x2)
+ call gseti (gp, G_PLTYPE, 2)
+ call gvline (gp, model, npts, x1, x2)
+
+ while (gt_gcur ("cursor", wx, wy, wcs, key, str, SZ_LINE) != EOF)
+ ;
+
+ call gclose (gp)
+ call gt_free (gt)
+end