diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /noao/twodspec/apextract/apgetdata.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'noao/twodspec/apextract/apgetdata.x')
-rw-r--r-- | noao/twodspec/apextract/apgetdata.x | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/noao/twodspec/apextract/apgetdata.x b/noao/twodspec/apextract/apgetdata.x new file mode 100644 index 00000000..6645a6c3 --- /dev/null +++ b/noao/twodspec/apextract/apgetdata.x @@ -0,0 +1,99 @@ +include <imhdr.h> + +# AP_GETDATA -- Get the summed dispersion line. +# Return the IMIO pointer, pointer to image data, the aperture axis and title. +# The pointers must be freed by the calling program. Note that the value of +# line may be changed. + +procedure ap_getdata (image, line, nsum, im, imdata, npts, apaxis, title) + +char image[SZ_FNAME] # Image name +int line # Dispersion line to graph +int nsum # Number of dispersion lines to sum +pointer im # IMIO pointer +pointer imdata # Pointer to image data +int npts # Number of pixels +int apaxis # Aperture axis +pointer title # Title for image data + +int i, j, k, l, n, dispaxis +pointer buf, medbuf + +real asumr(), amedr() +pointer ap_immap(), imgs2r() + +errchk ap_immap, imgs2r + +begin + # Map the image + im = ap_immap (image, apaxis, dispaxis) + + # Determine the dispersion and aperture axes. + if (IS_INDEFI (line)) + line = IM_LEN(im, dispaxis) / 2 + else + line = max (1, min (IM_LEN(im, dispaxis), line)) + + # Allocate memory for the image line and title. + npts = IM_LEN(im, apaxis) + call calloc (imdata, npts, TY_REAL) + call malloc (title, SZ_LINE, TY_CHAR) + + # Sum the specified number of dispersion lines. + n = max (1, abs (nsum)) + switch (apaxis) { + case 1: + i = max (1, line - n / 2) + j = min (IM_LEN(im, dispaxis), i + n - 1) + i = max (1, j - n + 1) + buf = imgs2r (im, 1, npts, i, j) + j = j - i + 1 + if (j < 3 || nsum > 0) { + do k = 1, j + call aaddr (Memr[buf+(k-1)*npts], Memr[imdata], + Memr[imdata], npts) + call sprintf (Memc[title], SZ_LINE, + "Image=%s, Sum of lines %d-%d") + call pargstr (image) + call pargi (i) + call pargi (i+j-1) + } else { + call malloc (medbuf, j, TY_REAL) + do k = 0, npts-1 { + do l = 0, j-1 + Memr[medbuf+l] = Memr[buf+l*npts+k] + Memr[imdata+k] = amedr (Memr[medbuf], j) + } + call mfree (medbuf, TY_REAL) + call sprintf (Memc[title], SZ_LINE, + "Image=%s, Median of lines %d-%d") + call pargstr (image) + call pargi (i) + call pargi (i+j-1) + } + + case 2: + i = max (1, line - n / 2) + j = min (IM_LEN(im, dispaxis), i + n - 1) + i = max (1, j - n + 1) + buf = imgs2r (im, i, j, 1, npts) + j = j - i + 1 + if (j < 3 || nsum > 0) { + do k = 1, npts + Memr[imdata+k-1] = asumr (Memr[buf+(k-1)*j], j) + call sprintf (Memc[title], SZ_LINE, + "Image=%s, Sum of columns %d-%d") + call pargstr (image) + call pargi (i) + call pargi (i+j-1) + } else { + do k = 1, npts + Memr[imdata+k-1] = amedr (Memr[buf+(k-1)*j], j) + call sprintf (Memc[title], SZ_LINE, + "Image=%s, Median of columns %d-%d") + call pargstr (image) + call pargi (i) + call pargi (i+j-1) + } + } +end |