Instrument Neutral Distributed Interface INDI 2.2.5
s2e.c
Go to the documentation of this file.
1#include "spk.h"
2
3int spkS2e ( double xp, double yp, double dut1, double slon,
4 double slat, double sh, int mount, double pnogo, double p,
5 double tc, double h, double fl, double wl, double pia,
6 double pib, double pvd, double pca, double pnp, double paw,
7 double pan, double ga, double gb, double x, double y,
8 double a, double b, double r, int iy, int im, int id,
9 int ih, int mi, double sec, double rc, double dc,
10 double pr, double pd, double px, double rv,
11 double* adem, double* bdem, double* ademb, double* bdemb,
12 double* rdem )
13/*
14** - - - - - - -
15** s p k S 2 e
16** - - - - - - -
17**
18** One-call star to mount calculation.
19**
20** The function performs the end-to-end pointing transformation,
21** starting with an ICRS star catalog entry and predicting the mount
22** encoder demands required to acquire the star image. It does so in
23** the simplest possible way, by first populating the SPK data
24** structures and then calling spkAstr, spkCtar and spkVtel, with no
25** consideration for computational efficiency.
26**
27** Its main purpose is as the core component of the SPK demonstrator
28** POINT, though it could be used in a basic telescope control system
29** where only the pointing/tracking capability of SPK is needed and
30** efficiency is not an important consideration.
31**
32** Given:
33**
34** Earth orientation parameters (Note 1)
35** xp double polar motion x coordinate (radians)
36** yp double polar motion y coordinate (radians)
37** dut1 double Delta UT1: UT1-UTC (seconds)
38**
39** Observatory
40** slon double site east longitude (ITRF, radians)
41** slat double site geodetic latitude (ITRF, radians)
42** sh double site altitude above WGS84 ellipsoid (m)
43** mount int mount type: 1 = equatorial, else = altazimuth
44** pnogo double closest to mount pole allowed (radians)
45**
46** Ambient air conditions
47** p double pressure (hPa = mB)
48** tc double temperature (degrees Celsius)
49** h double relative humidity (0-1)
50**
51** Optics
52** fl double focal length (user units)
53** wl double wavelength (micrometers)
54**
55** Pointing model coefficients (radians)
56** pia double IA: roll (-HA or pi-azimuth) index error
57** pib double IB: pitch (Dec or elevation) index error
58** pvd double VD: droop
59** pca double CA: telescope/pitch nonperpendicularity
60** pnp double NP: roll/pitch nonperpendicularity
61** paw double AW: roll axis misalignment across meridian
62** pan double AN: roll axis misalignment along meridian
63** ga double dCA guiding correction
64** gb double dIB guiding correction
65**
66** Hotspot
67** x double x-coordinate in rotating FP (user units)
68** y double y-coordinate in rotating FP (user units)
69**
70** Mount and rotator angles (achieved)
71** a double achieved -HA or pi-Az (radians)
72** b double achieved Dec or El (radians)
73** r double achieved rotator angle (radians, Note 3)
74**
75** UTC
76** iy int year CE
77** im int month
78** id int day
79** ih int hour
80** mi int minute
81** sec double seconds
82**
83** Target (Note 2)
84** rc double ICRS right ascension at J2000.0 (radians)
85** dc double ICRS declination at J2000.0 (radians)
86** pr double RA proper motion (radians/year, Note 2)
87** pd double Dec proper motion (radians/year)
88** px double parallax (arcsec, Note 3)
89** rv double radial velocity (km/s, +ve if receding)
90**
91** Returned:
92** adem double* demand -HA or pi-Az (radians)
93** bdem double* demand Dec or El (radians)
94** ademb double* demand -HA or pi-Az (radians, Note 4)
95** bdemb double* demand Dec or El (radians, Note 4)
96** rdem double* demand rotator angle (radians, Note 5)
97**
98** Returned (function value):
99** int 0 = OK, else = fail (Note 5)
100**
101** Notes:
102**
103** 1) The Earth Orientation Parameters can be obtained from tabulations
104** provided by the International Earth Rotation and Reference
105** Systems Service.
106**
107** xp and yp are the coordinates (in radians) of the Celestial
108** Intermediate Pole with respect to the International Terrestrial
109** Reference System (see IERS Conventions), measured along the
110** meridians 0 and 90 deg west respectively.
111**
112** The Delta UT1 changes very slowly except for UTC leap seconds,
113** where it jumps by one second.
114**
115** 2) Star data for an epoch other than J2000.0 (for example from the
116** Hipparcos catalog, which has an epoch of J1991.25) will require
117** preliminary treatment.
118**
119** The target's proper motion in RA is dRA/dt rather than
120** cos(Dec)*dRA/dt. In catalogs where the RA and Dec proper motions
121** are given in milliarcseconds per year, both will need scaling
122** into radians before the RA value is divided by cos(Dec).
123** n.b. Some catalogs quote proper motions per century, others per
124** year.
125**
126** The parallax value is in arcseconds rather than radians as it is
127** a distance measure rather than an angle.
128**
129** 3) The achieved rotator angle r is zero when the +y axis points
130** toward the projection of the mount's south pole, and increases
131** counterclockwise.
132**
133** 4) The second set of mount demands, ademb,bdemb, is for the "beyond
134** the pole" solution.
135**
136** 5) The demand rotator angle rdem is that required to align the
137** +y axis to ICRS north when the mount is in its normal (i.e. not
138** beyond the pole) attitude.
139**
140** 6) This function does not itself validate the given arguments, but
141** does return the error status if any of the called functions
142** fails.
143**
144** 7) Although grossly inefficient, it will run at kilohertz rates on
145** any modern processor.
146**
147** Called:
148** spkAstr update astrometry parameters
149** spkCtar ICRS to astrometric
150** spkVtel solve a virtual telescope
151**
152** This revision: 2024 July 18
153**
154** Author P.T.Wallace - see license notice at end.
155*/
156
157{
158/* VT constituents */
159 spkEOP eop; /* polar motion and UT1-UTC (from IERS) */
160 spkOBS obs; /* site location and mount type */
161 spkAIR air; /* local weather readings */
162 spkOPT opt; /* focal length and color */
163 spkPM pm; /* 7-term pointing model */
164 spkPO po; /* image position in focal plane */
165 spkAX3 ax3; /* achieved roll, pitch, rotator angles */
166 spkUTC utc; /* UTC date and time */
167 spkAST ast; /* target-independent astrometric parameters */
168 spkTAR tar; /* sky target */
169
170/* Miscellaneous */
171 int j;
172 double tara, tare, tarr, tarp, soln[5];
173
174/*
175** ----------------------------
176** Populate the VT constituents
177** ----------------------------
178*/
179
180/* Earth orientation parameters. */
181 eop.xp = xp; /* polar motion */
182 eop.yp = yp; /* polar motion */
183 eop.dut1 = dut1; /* UT1-UTC */
184
185/* Observatory. */
186 obs.slon = slon; /* east longitude */
187 obs.slat = slat; /* geodetic latitude */
188 obs.sh = sh; /* altitude */
189 obs.mount = mount == 1 ? EQUAT : ALTAZ; /* mount type */
190 obs.pavoid = pnogo; /* pole avoidance */
191
192/* Ambient air conditions. */
193 air.p = p; /* pressure */
194 air.t = tc; /* temperature */
195 air.h = h; /* humidity */
196
197/* Optics. */
198 opt.fl = fl; /* focal length */
199 opt.wl = wl; /* wavelength */
200
201/* Pointing model. */
202 pm.pia = pia; /* -IH or +IA */
203 pm.pib = pib; /* +ID or +IE */
204 pm.pvd = pvd; /* +FLOP */
205 pm.pca = pca; /* -CH or +CA */
206 pm.pnp = pnp; /* -NP or +NPAE*/
207 pm.paw = paw; /* -MA or +AW */
208 pm.pan = pan; /* +ME or +AN*/
209
210 pm.ga = ga; /* correction to pca */
211 pm.gb = gb; /* correction to pib */
212
213/* Hotspot. */
214 po.x = x; /* image x */
215 po.y = y; /* image y */
216
217/* Mount and rotator angles, achieved. */
218 ax3.a = a; /* -HA or pi-Az */
219 ax3.b = b; /* Dec or El */
220 ax3.r = r; /* rotator angle */
221
222/* UTC date & time. */
223 utc.iy = iy; /* year (CE) */
224 utc.mo = im; /* month (1-12) */
225 utc.id = id; /* day (1-28,29,30,31) */
226 utc.ih = ih; /* hour */
227 utc.mi = mi; /* minute */
228 utc.sec = sec; /* seconds */
229
230/* Astrometry. */
231 if ( spkAstr ( 1, utc, 0.0,
232 &eop, &obs, &air, &opt, &ast ) ) return -1;
233
234/* Target. */
235 spkCtar ( rc, dc, pr, pd, px, rv, &ast, &tar );
236
237/*
238** --------------------------
239** Solve for the axis demands
240** --------------------------
241*/
242
243 j = spkVtel ( AXES, &obs, &opt, &pm, &ast, &ax3, &tar, &po,
244 &tara, &tare, &tarr, &tarp, soln );
245 if ( j ) return -1;
246
247 *adem = soln[0];
248 *bdem = soln[1];
249 *ademb = soln[2];
250 *bdemb = soln[3];
251 *rdem = soln[4];
252
253/* Success. */
254 return 0;
255}
256
257/*----------------------------------------------------------------------
258**
259** Copyright (C) 2024 by P.T.Wallace
260**
261** Permission to use, copy, modify, and/or distribute this software for
262** any purpose with or without fee is hereby granted.
263**
264** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
265** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
266** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
267** AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
268** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
269** OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
270** NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
271** CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
272**
273**--------------------------------------------------------------------*/
int spkAstr(int jfull, spkUTC utc, double dt, spkEOP *eop, spkOBS *obs, spkAIR *air, spkOPT *opt, spkAST *ast)
Definition astr.c:4
void spkCtar(double rc, double dc, double pr, double pd, double px, double rv, spkAST *ast, spkTAR *tar)
Definition ctar.c:4
int spkS2e(double xp, double yp, double dut1, double slon, double slat, double sh, int mount, double pnogo, double p, double tc, double h, double fl, double wl, double pia, double pib, double pvd, double pca, double pnp, double paw, double pan, double ga, double gb, double x, double y, double a, double b, double r, int iy, int im, int id, int ih, int mi, double sec, double rc, double dc, double pr, double pd, double px, double rv, double *adem, double *bdem, double *ademb, double *bdemb, double *rdem)
Definition s2e.c:3
@ EQUAT
Definition spk.h:41
@ ALTAZ
Definition spk.h:42
@ AXES
Definition spk.h:52
int spkVtel(spkVTS isoln, spkOBS *obs, spkOPT *opt, spkPM *pm, spkAST *ast, spkAX3 *ax3, spkTAR *tar, spkPO *po, double *tara, double *tare, double *tarr, double *tarp, double soln[5])
Definition vtel.c:33
Definition spk.h:87
double h
Definition spk.h:90
double t
Definition spk.h:89
double p
Definition spk.h:88
Definition spk.h:136
Definition spk.h:119
double b
Definition spk.h:121
double a
Definition spk.h:120
double r
Definition spk.h:122
Definition spk.h:71
double xp
Definition spk.h:72
double dut1
Definition spk.h:74
double yp
Definition spk.h:73
Definition spk.h:78
double slat
Definition spk.h:80
double slon
Definition spk.h:79
double pavoid
Definition spk.h:83
spkMOUNT mount
Definition spk.h:82
double sh
Definition spk.h:81
Definition spk.h:94
double wl
Definition spk.h:96
double fl
Definition spk.h:95
Definition spk.h:100
double pib
Definition spk.h:102
double ga
Definition spk.h:108
double paw
Definition spk.h:106
double pca
Definition spk.h:104
double pnp
Definition spk.h:105
double pia
Definition spk.h:101
double pvd
Definition spk.h:103
double gb
Definition spk.h:109
double pan
Definition spk.h:107
Definition spk.h:113
double x
Definition spk.h:114
double y
Definition spk.h:115
Definition spk.h:143
Definition spk.h:126
int mi
Definition spk.h:131
int mo
Definition spk.h:128
double sec
Definition spk.h:132
int id
Definition spk.h:129
int iy
Definition spk.h:127
int ih
Definition spk.h:130