aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/daophot/daolib/dpwcs.x
blob: 9961b933959144280cd978a4615cd5f35c76a3ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include <imio.h>
include "../lib/daophotdef.h"

# DP_WIN -- Convert the input coordinates to logical coordinates.

procedure dp_win (dp, im, xin, yin, xout, yout, npts)

pointer	dp			# the apphot package descriptor
pointer	im			# the input image descriptor
real	xin[ARB]		# the input x coordinate
real	yin[ARB]		# the input y coordinate
real	xout[ARB]		# the output x coordinate 
real	yout[ARB]		# the output y coordinate
int	npts			# the number of coordinates to convert

int	dp_stati()

begin
        # Transform the input coordinates.
        switch (dp_stati (dp, WCSIN)) {
        case WCS_WORLD, WCS_PHYSICAL:
            call dp_itol (dp, xin, yin, xout, yout, npts)
        case WCS_TV:
            call dp_vtol (im, xin, yin, xout, yout, npts)
        default:
	    call amovr (xin, xout, npts)
	    call amovr (yin, yout, npts)
        }
end


# DP_WOUT -- Convert the logical coordinates to output coordinates.

procedure dp_wout (dp, im, xin, yin, xout, yout, npts)

pointer	dp			# the apphot package descriptor
pointer	im			# the input image descriptor
real	xin[ARB]		# the input x coordinate
real	yin[ARB]		# the input y coordinate
real	xout[ARB]		# the output x coordinate 
real	yout[ARB]		# the output y coordinate
int	npts			# the number of coordinates to convert

int	dp_stati()

begin
        # Transform the input coordinates.
        switch (dp_stati (dp, WCSOUT)) {
        case WCS_WORLD, WCS_PHYSICAL:
            call dp_ltoo (dp, xin, yin, xout, yout, npts)
        case WCS_TV:
            call dp_ltov (im, xin, yin, xout, yout, npts)
        default:
	    call amovr (xin, xout, npts)
	    call amovr (yin, yout, npts)
        }
end


# DP_WPSF -- Convert the logical coordinates to psf coordinates.

procedure dp_wpsf (dp, im, xin, yin, xout, yout, npts)

pointer	dp			# the apphot package descriptor
pointer	im			# the input image descriptor
real	xin[ARB]		# the input x coordinate
real	yin[ARB]		# the input y coordinate
real	xout[ARB]		# the output x coordinate 
real	yout[ARB]		# the output y coordinate
int	npts			# the number of coordinates to convert

int	dp_stati()

begin
        # Transform the input coordinates.
        switch (dp_stati (dp, WCSPSF)) {
        case WCS_WORLD, WCS_PHYSICAL:
            call dp_ltop (dp, xin, yin, xout, yout, npts)
        case WCS_TV:
            call dp_ltov (im, xin, yin, xout, yout, npts)
        default:
	    call amovr (xin, xout, npts)
	    call amovr (yin, yout, npts)
        }
end


# DP_ITOL -- Convert coordinates from the input coordinate system to the
# logical coordinate system.

procedure dp_itol (dp, xin, yin, xout, yout, npts)

pointer	dp			# the apphot package descriptor
real	xin[ARB]		# the input x coordinate
real	yin[ARB]		# the input y coordinate
real	xout[ARB]		# the output x coordinate 
real	yout[ARB]		# the output y coordinate
int	npts			# the number of coordinates to convert

double	xt, yt
pointer	ct
int	i
int	dp_stati()

begin
	ct = dp_stati (dp, CTIN)
	if (ct == NULL) {
	    call amovr (xin, xout, npts)
	    call amovr (yin, yout, npts)
	    return
	}

	do i = 1, npts {
	    call mw_c2trand (ct, double (xin[i]), double (yin[i]), xt, yt) 
	    xout[i] = xt
	    yout[i] = yt
	}
end


# DP_LTOO -- Convert coordinates from the logical coordinate system to the
# output coordinate system.

procedure dp_ltoo (dp, xin, yin, xout, yout, npts)

pointer	dp			# the apphot package descriptor
real	xin[ARB]		# the input x coordinate
real	yin[ARB]		# the input y coordinate
real	xout[ARB]		# the output x coordinate 
real	yout[ARB]		# the output y coordinate
int	npts			# the number of coordinates to convert

double	xt, yt
pointer	ct
int	i
int	dp_stati()

begin
	ct = dp_stati (dp, CTOUT)
	if (ct == NULL) {
	    call amovr (xin, xout, npts)
	    call amovr (yin, yout, npts)
	    return
	}

	do i = 1, npts {
	    call mw_c2trand (ct, double (xin[i]), double (yin[i]), xt, yt) 
	    xout[i] = xt
	    yout[i] = yt
	}
end


# DP_LTOP -- Convert coordinates from the logical coordinate system to the
# output coordinate system.

procedure dp_ltop (dp, xin, yin, xout, yout, npts)

pointer	dp			# the apphot package descriptor
real	xin[ARB]		# the input x coordinate
real	yin[ARB]		# the input y coordinate
real	xout[ARB]		# the output x coordinate 
real	yout[ARB]		# the output y coordinate
int	npts			# the number of coordinates to convert

double	xt, yt
pointer	ct
int	i
int	dp_stati()

begin
	ct = dp_stati (dp, CTPSF)
	if (ct == NULL) {
	    call amovr (xin, xout, npts)
	    call amovr (yin, yout, npts)
	    return
	}

	do i = 1, npts {
	    call mw_c2trand (ct, double (xin[i]), double (yin[i]), xt, yt) 
	    xout[i] = xt
	    yout[i] = yt
	}
end


# DP_LTOV -- Convert coordinate from the logical coordinate system to the
# output coordinate system.

procedure dp_ltov (im, xin, yin, xout, yout, npts)

pointer	im			# the input image descriptor
real	xin[ARB]		# the input x coordinate
real	yin[ARB]		# the input y coordinate
real	xout[ARB]		# the output x coordinate 
real	yout[ARB]		# the output y coordinate
int	npts			# the number of coordinates to convert

int	i, index1, index2

begin
	index1 = IM_VMAP(im,1)
	index2 = IM_VMAP(im,2)
	do i = 1, npts {
	    xout[i] = xin[i] * IM_VSTEP(im,index1) + IM_VOFF(im,index1)
	    yout[i] = yin[i] * IM_VSTEP(im,index2) + IM_VOFF(im,index2)
	}
end


# DP_VTOL -- Convert coordinate from the tv coordinate system to the
# logical coordinate system.

procedure dp_vtol (im, xin, yin, xout, yout, npts)

pointer	im			# the input image descriptor
real	xin[ARB]		# the input x coordinate
real	yin[ARB]		# the input y coordinate
real	xout[ARB]		# the output x coordinate 
real	yout[ARB]		# the output y coordinate
int	npts			# the number of coordinates to convert

int	i, index1, index2

begin
	index1 = IM_VMAP(im,1)
	index2 = IM_VMAP(im,2)
	do i = 1, npts {
	    xout[i] = (xin[i] - IM_VOFF(im,index1)) / IM_VSTEP(im,index1)
	    yout[i] = (yin[i] - IM_VOFF(im,index2)) / IM_VSTEP(im,index2)
	}
end