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
|
include <imhdr.h>
include <math.h>
include <mwset.h>
include <pkg/skywcs.h>
# RG_CELTOSTD - Convert the longitude / latitude coordinates to standard
# coordinates given the position of the reference point and the form of
# the projection.
procedure rg_celtostd (projection, lngref, latref, xi, eta, npts, reflng,
reflat, lngunits, latunits)
char projection[ARB] #I the projection type
double lngref[ARB] #I the input ra / longitude coordinates
double latref[ARB] #I the input dec / latitude coordinates
double xi[ARB] #O the output ra / longitude std coordinates
double eta[ARB] #O the output dec / latitude std coordinates
int npts #I the number of data points
double reflng #I the ra / longitude reference point
double reflat #I the dec / latitude reference point
int lngunits #I the ra / longitude units
int latunits #I the dec / latitude units
double tlngref, tlatref
int i
pointer mw, ct
pointer rg_projwcs(), mw_sctran()
errchk mw_sctran()
begin
# Initialize the projection transformation.
mw = rg_projwcs (projection, reflng, reflat, lngunits, latunits)
# Compile the transformation.
ct = mw_sctran (mw, "world", "logical", 03B)
# Evaluate the standard coordinates.
do i = 1, npts {
switch (lngunits) {
case SKY_DEGREES:
tlngref = lngref[i]
case SKY_RADIANS:
tlngref = RADTODEG(lngref[i])
case SKY_HOURS:
tlngref = 15.0d0 * lngref[i]
default:
tlngref = lngref[i]
}
switch (latunits) {
case SKY_DEGREES:
tlatref = latref[i]
case SKY_RADIANS:
tlatref = RADTODEG(latref[i])
case SKY_HOURS:
tlatref = 15.0d0 * latref[i]
default:
tlatref = latref[i]
}
call mw_c2trand (ct, tlngref, tlatref, xi[i], eta[i])
}
call mw_close (mw)
end
# RG_STDTOCEL - Convert the longitude / latitude coordinates to standard
# coordinates given the position of the reference point and the form of
# the projection.
procedure rg_stdtocel (projection, xi, eta, lngfit, latfit, npts, reflng,
reflat, lngunits, latunits)
char projection[ARB] #I the sky projection geometry
double xi[ARB] #I the output ra / longitude std coordinates
double eta[ARB] #I the output dec / latitude std coordinates
double lngfit[ARB] #O the input ra / longitude coordinates
double latfit[ARB] #O the input dec / latitude coordinates
int npts #I the number of data points
double reflng #I the ra / longitude reference point
double reflat #I the dec / latitude reference point
int lngunits #I the ra / longitude units
int latunits #I the dec / latitude units
double tlngref, tlatref
int i
pointer mw, ct
pointer rg_projwcs(), mw_sctran()
errchk mw_sctran()
begin
# Initialize the projection transformation.
mw = rg_projwcs (projection, reflng, reflat, lngunits, latunits)
# Compile the transformation.
ct = mw_sctran (mw, "logical", "world", 03B)
# Evaluate the standard coordinates.
do i = 1, npts {
call mw_c2trand (ct, xi[i], eta[i], tlngref, tlatref)
switch (lngunits) {
case SKY_DEGREES:
lngfit[i] = tlngref
case SKY_RADIANS:
lngfit[i] = DEGTORAD(tlngref)
case SKY_HOURS:
lngfit[i] = tlngref / 15.0d0
default:
lngfit[i] = tlngref
}
switch (latunits) {
case SKY_DEGREES:
latfit[i] = tlatref
case SKY_RADIANS:
latfit[i] = DEGTORAD(tlatref)
case SKY_HOURS:
latfit[i] = tlatref / 15.0d0
default:
latfit[i] = tlatref
}
}
call mw_close (mw)
end
# RG_PROJWCS -- Set up a projection wcs given the projection type, the
# coordinates of the reference point, and the reference point units.
pointer procedure rg_projwcs (projection, reflng, reflat, lngunits, latunits)
char projection[ARB] #I the projection type
double reflng #I the ra / longitude reference point
double reflat #I the dec / latitude reference point
int lngunits #I the ra / longitude units
int latunits #I the dec / latitude units
int ndim
pointer sp, projstr, projpars, wpars, ltm, ltv, cd, r, w, mw, axes
pointer mw_open()
begin
ndim = 2
# Allocate working space.
call smark (sp)
call salloc (projstr, SZ_FNAME, TY_CHAR)
call salloc (projpars, SZ_LINE, TY_CHAR)
call salloc (wpars, SZ_LINE, TY_CHAR)
call salloc (ltm, ndim * ndim, TY_DOUBLE)
call salloc (ltv, ndim, TY_DOUBLE)
call salloc (cd, ndim * ndim, TY_DOUBLE)
call salloc (r, ndim, TY_DOUBLE)
call salloc (w, ndim, TY_DOUBLE)
call salloc (axes, IM_MAXDIM, TY_INT)
# Open the wcs.
mw = mw_open (NULL, ndim)
# Set the axes and projection type.
Memi[axes] = 1
Memi[axes+1] = 2
if (projection[1] == EOS)
call mw_swtype (mw, Memi[axes], ndim, "linear", "")
else {
call sscan (projection)
call gargwrd (Memc[projstr], SZ_FNAME)
call gargstr (Memc[projpars], SZ_LINE)
call sprintf (Memc[wpars], SZ_LINE,
"axis 1: axtype = ra %s axis 2: axtype = dec %s")
call pargstr (Memc[projpars])
call pargstr (Memc[projpars])
call mw_swtype (mw, Memi[axes], ndim, Memc[projstr], Memc[wpars])
}
# Set the lterm.
call mw_mkidmd (Memd[ltm], ndim)
call aclrd (Memd[ltv], ndim)
call mw_sltermd (mw, Memd[ltm], Memd[ltv], ndim)
# Set the wterm.
call mw_mkidmd (Memd[cd], ndim)
call aclrd (Memd[r], ndim)
switch (lngunits) {
case SKY_DEGREES:
Memd[w] = reflng
case SKY_RADIANS:
Memd[w] = RADTODEG(reflng)
case SKY_HOURS:
Memd[w] = 15.0d0 * reflng
default:
Memd[w] = reflng
}
switch (latunits) {
case SKY_DEGREES:
Memd[w+1] = reflat
case SKY_RADIANS:
Memd[w+1] = RADTODEG(reflat)
case SKY_HOURS:
Memd[w+1] = 15.0d0 * reflat
default:
Memd[w+1] = reflat
}
call mw_swtermd (mw, Memd[r], Memd[w], Memd[cd], ndim)
call sfree (sp)
return (mw)
end
|