aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/photcal/fitparams/ftref.x
diff options
context:
space:
mode:
Diffstat (limited to 'noao/digiphot/photcal/fitparams/ftref.x')
-rw-r--r--noao/digiphot/photcal/fitparams/ftref.x50
1 files changed, 50 insertions, 0 deletions
diff --git a/noao/digiphot/photcal/fitparams/ftref.x b/noao/digiphot/photcal/fitparams/ftref.x
new file mode 100644
index 00000000..0fab41c4
--- /dev/null
+++ b/noao/digiphot/photcal/fitparams/ftref.x
@@ -0,0 +1,50 @@
+include <error.h>
+include "../lib/parser.h"
+
+
+# FT_RFEVAL - Evaluate reference equation (left hand side) for all observations
+# and store them into a one column table, called the reference table (rtable).
+
+procedure ft_rfeval (code, otable, rtable)
+
+pointer code # equation code
+pointer otable # 2d observation table
+pointer rtable # 1d reference table (output)
+
+int n
+real rval
+real dummy[1]
+
+#bool clgetb()
+int mct_nrows()
+real pr_eval()
+pointer mct_getrow()
+
+begin
+ # Debug ?
+ #if (clgetb ("debug.fitcode")) {
+ #call eprintf ("ft_rfeval (code=%d) (otable=%d)\n")
+ #call pargi (code)
+ #call pargi (otable)
+ #}
+
+ # Allocate space for reference table.
+ # call mct_alloc (rtable, mct_nrows (otable), 1, TY_REAL)
+
+ # Loop over all data in the table.
+ do n = 1, mct_nrows (otable) {
+
+ # Evaluate the equation.
+ iferr (rval = pr_eval (code, Memr[mct_getrow (otable, n)], dummy)) {
+ call eprintf ("ft_ref (%d)\n")
+ call pargi (n)
+ call erract (EA_ERROR)
+ }
+
+ # Put data into reference table.
+ call mct_putr (rtable, n, 1, rval)
+ }
+
+ # Debug ?
+ #call dg_dref ("from ft_rfeval", rtable)
+end