line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
*+ |
3
|
|
|
|
|
|
|
* Name: |
4
|
|
|
|
|
|
|
* palPxy |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
* Purpose: |
7
|
|
|
|
|
|
|
* Given arrays of "expected" and "measured" [x,y] coordinates, and a |
8
|
|
|
|
|
|
|
* linear model relating them (as produced by palFitxy), compute |
9
|
|
|
|
|
|
|
* the array of "predicted" coordinates and the RMS residuals. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
* Language: |
12
|
|
|
|
|
|
|
* Starlink ANSI C |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
* Type of Module: |
15
|
|
|
|
|
|
|
* Library routine |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
* Invocation: |
18
|
|
|
|
|
|
|
* palPxy ( int np, double xye[][2], double xym[][2], double coeffs[6], |
19
|
|
|
|
|
|
|
* double xyp[][2], double *xrms, double *yrms, double *rrms ) |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
* Arguments: |
22
|
|
|
|
|
|
|
* np = int (Given) |
23
|
|
|
|
|
|
|
* number of samples |
24
|
|
|
|
|
|
|
* xye = double[np][2] (Given) |
25
|
|
|
|
|
|
|
* expected [x,y] for each sample |
26
|
|
|
|
|
|
|
* xym = double[np][2] (Given) |
27
|
|
|
|
|
|
|
* measured [x,y] for each sample |
28
|
|
|
|
|
|
|
* coeffs = double[6] |
29
|
|
|
|
|
|
|
* coefficients of model (see below) |
30
|
|
|
|
|
|
|
* xyp = double[np][2] (Returned) |
31
|
|
|
|
|
|
|
* predicted [x,y] for each sample |
32
|
|
|
|
|
|
|
* xrms = double (Returned) |
33
|
|
|
|
|
|
|
* RMS in x |
34
|
|
|
|
|
|
|
* yrms = double (Returned) |
35
|
|
|
|
|
|
|
* RMS in y |
36
|
|
|
|
|
|
|
* rrms = double (Returned) |
37
|
|
|
|
|
|
|
* total RMS (vector sum of xrms and yrms) |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
* Description: |
40
|
|
|
|
|
|
|
* The model is supplied in the array coeffs. Naming the |
41
|
|
|
|
|
|
|
* elements of coeffs as follows: |
42
|
|
|
|
|
|
|
* --- |
43
|
|
|
|
|
|
|
* coeffs[0] = A |
44
|
|
|
|
|
|
|
* coeffs[1] = B |
45
|
|
|
|
|
|
|
* coeffs[2] = C |
46
|
|
|
|
|
|
|
* coeffs[3] = D |
47
|
|
|
|
|
|
|
* coeffs[4] = E |
48
|
|
|
|
|
|
|
* coeffs[5] = F |
49
|
|
|
|
|
|
|
* --- |
50
|
|
|
|
|
|
|
* the model is applied thus: |
51
|
|
|
|
|
|
|
* --- |
52
|
|
|
|
|
|
|
* xp = A + B * xm + C * ym |
53
|
|
|
|
|
|
|
* yp = D + E * xm + F * ym |
54
|
|
|
|
|
|
|
* --- |
55
|
|
|
|
|
|
|
* The residuals are (xp - xe) and (yp - ye). |
56
|
|
|
|
|
|
|
* |
57
|
|
|
|
|
|
|
* If np is less than or equal to zero, no coordinates are |
58
|
|
|
|
|
|
|
* transformed, and the RMS residuals are all zero. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
* See also: |
61
|
|
|
|
|
|
|
* palFitxy, palInvf, palXy2xy and palDcmpf |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
* Authors: |
64
|
|
|
|
|
|
|
* PTW: Pat Wallace (STFC) |
65
|
|
|
|
|
|
|
* GSB: Graham Bell (EAO) |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
* History: |
68
|
|
|
|
|
|
|
* 1996-05-22 (PTW): |
69
|
|
|
|
|
|
|
* SLALIB implementation. |
70
|
|
|
|
|
|
|
* 2018-10-23 (GSB): |
71
|
|
|
|
|
|
|
* Initial version in C. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
* Copyright: |
74
|
|
|
|
|
|
|
* Copyright (C) 1996 Rutherford Appleton Laboratory |
75
|
|
|
|
|
|
|
* Copyright (C) 2018 East Asian Observatory. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
* Licence: |
78
|
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify |
79
|
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by |
80
|
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
81
|
|
|
|
|
|
|
* (at your option) any later version. |
82
|
|
|
|
|
|
|
* |
83
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful, |
84
|
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
85
|
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
86
|
|
|
|
|
|
|
* GNU General Public License for more details. |
87
|
|
|
|
|
|
|
* |
88
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License |
89
|
|
|
|
|
|
|
* along with this program (see SLA_CONDITIONS); if not, write to the |
90
|
|
|
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
91
|
|
|
|
|
|
|
* Boston, MA 02110-1301 USA |
92
|
|
|
|
|
|
|
*- |
93
|
|
|
|
|
|
|
*/ |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
#include |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#include "pal.h" |
98
|
|
|
|
|
|
|
#include "palmac.h" |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
|
void palPxy ( int np, double xye[][2], double xym[][2], double coeffs[6], |
101
|
|
|
|
|
|
|
double xyp[][2], double *xrms, double *yrms, double *rrms ) { |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
int i; |
104
|
|
|
|
|
|
|
double sdx2, sdy2, xp, yp, dx, dy, dx2, dy2, p; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
/* Initialize summations */ |
107
|
|
|
|
|
|
|
sdx2 = 0.0; |
108
|
|
|
|
|
|
|
sdy2 = 0.0; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
/* Loop by sample */ |
111
|
9
|
100
|
|
|
|
|
for (i = 0; i < np; i ++) { |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
/* Transform "measured" [X,Y] to "predicted" [X,Y] */ |
114
|
8
|
|
|
|
|
|
palXy2xy(xym[i][0], xym[i][1], coeffs, &xp, &yp); |
115
|
8
|
|
|
|
|
|
xyp[i][0] = xp; |
116
|
8
|
|
|
|
|
|
xyp[i][1] = yp; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
/* Compute residuals in X and Y, and update summations */ |
119
|
8
|
|
|
|
|
|
dx = xye[i][0] - xp; |
120
|
8
|
|
|
|
|
|
dy = xye[i][1] - yp; |
121
|
8
|
|
|
|
|
|
dx2 = dx * dx; |
122
|
8
|
|
|
|
|
|
dy2 = dy * dy; |
123
|
8
|
|
|
|
|
|
sdx2 = sdx2 + dx2; |
124
|
8
|
|
|
|
|
|
sdy2 = sdy2 + dy2; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
/* Next sample */ |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
/* Compute RMS values */ |
130
|
1
|
50
|
|
|
|
|
p = DMAX(1.0, (double) np); |
131
|
1
|
|
|
|
|
|
*xrms = sqrt(sdx2 / p); |
132
|
1
|
|
|
|
|
|
*yrms = sqrt(sdy2 / p); |
133
|
1
|
|
|
|
|
|
*rrms = sqrt(*xrms * *xrms + *yrms * *yrms); |
134
|
1
|
|
|
|
|
|
} |