diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/twodspec/multispec/sampline.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'noao/twodspec/multispec/sampline.x')
-rw-r--r-- | noao/twodspec/multispec/sampline.x | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/noao/twodspec/multispec/sampline.x b/noao/twodspec/multispec/sampline.x new file mode 100644 index 00000000..37583f9f --- /dev/null +++ b/noao/twodspec/multispec/sampline.x @@ -0,0 +1,73 @@ +include <mach.h> +include "ms.h" + + +# GET_SAMPLE_LINE -- Get the nearest sample line to the given image lines. +# +# The nearest sample line to each image line is found an returned +# as the function value. + +int procedure get_sample_line (ms, line) + +pointer ms # MULTISPEC data structure +int line # Image line + +int sample, midpoint + +begin + sample = 0 + midpoint = 0 + + repeat { + sample = sample + 1 + if (sample < MS_NSAMPLES(ms)) + midpoint = (LINE(ms, sample) + LINE(ms, sample + 1)) / 2 + else if (sample == MS_NSAMPLES(ms)) + midpoint = MAX_INT + else + break + } until (line < midpoint) + + return (sample) +end + + +# GET_SAMPLE_LINES -- Get the sample lines for the given image lines. +# +# Image lines in the form of a range array are given. +# The nearest sample line to each image line is found. The array of +# sample lines is returned and the function value is the number of +# sample lines. + +int procedure get_sample_lines (ms, lines, samples) + +pointer ms # MULTISPEC data structure +int lines[ARB] # Image line range array +int samples[ARB] # Return sample lines + +int nsamples, sample, line, midpoint +int get_next_number() + +begin + nsamples = 0 + sample = 0 + midpoint = 0 + line = 0 + + while (get_next_number (lines, line) != EOF) { + repeat { + sample = sample + 1 + if (sample < MS_NSAMPLES(ms)) + midpoint = (LINE(ms, sample) + LINE(ms, sample + 1)) / 2 + else if (sample == MS_NSAMPLES(ms)) + midpoint = MAX_INT + else + return (nsamples) + } until (line < midpoint) + + nsamples = nsamples + 1 + samples[nsamples] = sample + line = midpoint - 1 + } + return (nsamples) +end |