aboutsummaryrefslogtreecommitdiff
path: root/noao/twodspec/multispec/setmodel.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/multispec/setmodel.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/twodspec/multispec/setmodel.x')
-rw-r--r--noao/twodspec/multispec/setmodel.x86
1 files changed, 86 insertions, 0 deletions
diff --git a/noao/twodspec/multispec/setmodel.x b/noao/twodspec/multispec/setmodel.x
new file mode 100644
index 00000000..98c1a630
--- /dev/null
+++ b/noao/twodspec/multispec/setmodel.x
@@ -0,0 +1,86 @@
+include "ms.h"
+
+# SET_MODEL -- Set a line of model data from profiles based on their
+# ranges starting values.
+
+procedure set_model (ms, model, model_profiles, ranges, len_line, len_profile,
+ nspectra)
+
+pointer ms # MULTISPEC data structure
+real model[len_line] # Model line created
+real model_profiles[len_profile, nspectra] # Model profiles
+real ranges[nspectra, LEN_RANGES] # Ranges array for the profiles
+int len_line # The length of the model line
+int len_profile # The length of the profiles
+int nspectra # The number of spectra
+
+int i, x, spectrum
+
+begin
+ # Set the model background to zero.
+ call aclrr (model, len_line)
+
+ # For each spectrum and each profile point add contribution to model.
+ do spectrum = 1, nspectra {
+ do i = 1, len_profile {
+ # Column corresponding to profile point i and spectrum.
+ x = ranges[spectrum, X_START] + i - 1
+
+ # Scale the model profile by the model parameter I0 and
+ # add to the model line.
+ if ((x >= 1) && (x <= len_line))
+ model[x] = model[x] + PARAMETER(ms, I0, spectrum) *
+ model_profiles[i, spectrum]
+ }
+ }
+end
+
+# SET_MODEL1 -- Set a line of model data from profiles based on the spectra
+# function fit position centers and the ranges dx_start value.
+
+procedure set_model1 (ms, line, profiles, coeff, ranges, len_line, len_profile,
+ nspectra, model)
+
+pointer ms # MULTISPEC data structure
+int line # Image line for model
+real profiles[len_profile, nspectra] # Profiles
+real coeff[ARB] # Image interpolation coeff.
+real ranges[nspectra, LEN_RANGES] # Ranges array for profiles
+int len_line # Length of model line
+int len_profile # Length of profiles
+int nspectra # Number of spectra
+real model[len_line] # Model line to be created
+
+int i, x, spectrum
+real x_start, dx
+
+real cveval(), asival()
+
+begin
+ # Clear the model to a zero background.
+ call aclrr (model, len_line)
+
+ # Add the contribution for each spectrum.
+ do spectrum = 1, nspectra {
+ # Fit image interpolator to profile.
+ call asifit (profiles[1,spectrum], len_profile, coeff)
+
+ # Determine starting column corresponding to spectrum at specified
+ # line whose central position is given by the fit function.
+ x_start = cveval (CV(ms, X0_FIT, spectrum), real (line)) +
+ ranges[spectrum, DX_START]
+
+ # For each column corresponding to a point in the profile determine
+ # the interpolation point dx within the profile and evaluate the
+ # the image interpolation function.
+
+ x = x_start
+ do i = 1, len_profile - 1 {
+ x = x + 1
+ if ((x >= 1) && (x <= len_line)) {
+ dx = x - x_start + 1
+ model[x] = model[x] + asival (dx, coeff)
+ }
+ }
+ }
+end