aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/identify/idpeak.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/onedspec/identify/idpeak.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/onedspec/identify/idpeak.x')
-rw-r--r--noao/onedspec/identify/idpeak.x95
1 files changed, 95 insertions, 0 deletions
diff --git a/noao/onedspec/identify/idpeak.x b/noao/onedspec/identify/idpeak.x
new file mode 100644
index 00000000..c3e7559d
--- /dev/null
+++ b/noao/onedspec/identify/idpeak.x
@@ -0,0 +1,95 @@
+include <smw.h>
+include "identify.h"
+
+# ID_PEAK -- Find the peak value above continuum.
+
+double procedure id_peak (id, pix)
+
+pointer id # ID pointer
+double pix # Pixel position
+double peak # Peak value
+
+int c, l, u
+
+begin
+ if (IS_INDEFD(pix))
+ return (INDEFD)
+
+ c = nint (pix)
+ l = max (1, nint (pix - ID_FWIDTH(id)))
+ u = min (ID_NPTS(id), nint (pix + ID_FWIDTH(id)))
+ peak = IMDATA(id,c) - (IMDATA(id,l) + IMDATA(id,u)) / 2.
+
+ return (peak)
+end
+
+
+# ID_PEAKS -- Find peaks in the data. This just calls find_peaks but does
+# the logical to physical pixel conversion.
+
+int procedure id_peaks (id, data, x, npoints, contrast, separation, edge, nmax,
+ threshold, debug)
+
+pointer id #I Identify pointer
+real data[npoints] #I Input data array
+real x[npoints] #O Output peak position array
+int npoints #I Number of data points
+real contrast #I Maximum contrast between strongest and weakest
+int separation #I Minimum separation between peaks
+int edge #I Minimum distance from the edge
+int nmax #I Maximum number of peaks to be returned
+real threshold #I Minimum threshold level for peaks
+bool debug #I Print diagnostic information?
+
+int i, n, np1, find_peaks()
+double smw_c1trand()
+errchk find_peaks
+
+begin
+ # Find the peaks in logical coordinates.
+ n = find_peaks (data, x, npoints, contrast, separation, edge,
+ nmax, threshold, debug)
+
+ # Convert to physical coordinates.
+ np1 = NP1(ID_SH(id)) - 1
+ do i = 1, n
+ x[i] = smw_c1trand (ID_LP(id), double (x[i]+np1))
+
+ return (n)
+end
+
+
+# ID_UPEAKS -- Find uniformly distributed peaks in the data. This just calls
+# find_upeaks but does the logical to physical pixel conversion.
+
+int procedure id_upeaks (id, data, x, npoints, contrast, separation, edge,
+ nmax, nbins, threshold, debug)
+
+pointer id #I Identify pointer
+real data[npoints] #I Input data array
+real x[npoints] #O Output peak position array
+int npoints #I Number of data points
+real contrast #I Maximum contrast between strongest and weakest
+int separation #I Minimum separation between peaks
+int edge #I Minimum distance from the edge
+int nmax #I Maximum number of peaks to be returned
+int nbins #I Number of bins across the data array
+real threshold #I Minimum threshold level for peaks
+bool debug #I Print diagnostic information?
+
+int i, n, np1, find_upeaks()
+double smw_c1trand()
+errchk find_upeaks
+
+begin
+ # Find the peaks in logical coordinates.
+ n = find_upeaks (data, x, npoints, contrast, separation, edge,
+ nmax, nbins, threshold, debug)
+
+ # Convert to physical coordinates.
+ np1 = NP1(ID_SH(id)) - 1
+ do i = 1, n
+ x[i] = smw_c1trand (ID_LP(id), double (x[i]+np1))
+
+ return (n)
+end