Instrument Neutral Distributed Interface INDI 2.2.5
astr.c
Go to the documentation of this file.
1#include "spk.h"
2#include <sofa.h>
3
4int spkAstr ( int jfull, spkUTC utc, double dt, spkEOP* eop,
5 spkOBS* obs, spkAIR* air, spkOPT* opt, spkAST* ast )
6/*
7** - - - - - - - -
8** s p k A s t r
9** - - - - - - - -
10**
11** For a specified UTC, update star-independent astrometry parameters.
12**
13** Given:
14** jfull int TRUE/FALSE = full/partial update (Notes 1,2)
15** utc spkUTC UTC date and time (Notes 2-4)
16** dt double offset (SI seconds, Note 2)
17** eop spkEOP* Earth orientation parameters
18** obs spkOBS* site location and mount type
19** air spkAIR* ambient weather conditions
20** opt spkOPT* for color
21**
22** Returned:
23** ast spkAST* astrometry parameters (Note 1)
24**
25** Returned (function value):
26** int status: +3 = both of next two
27** +2 = time is after end of day (Note 3)
28** +1 = dubious year (Note 4)
29** 0 = OK
30** -1 = bad year
31** -2 = bad month
32** -3 = bad day
33** -4 = bad hour
34** -5 = bad minute
35** -6 = bad second (<0)
36** -7 = other error (Note 5)
37**
38** Notes:
39**
40** 1) The flag jfull selects whether the entire set of star-independent
41** astrometry parameters are refreshed (jfull = TRUE) or just the
42** Earth rotation angle. Other quantities such as precession
43** matrices are not recomputed in the jfull = FALSE case, and will
44** as time goes on become less accurate. How frequently the
45** parameters are fully refreshed is a decision for the application
46** developer, but once for each new target could be adequate. The
47** TAI included in the star-independent astrometry parameters
48** corresponds to the ERA.
49**
50** 2) The UTC date and time is supplied as an spkUTC structure,
51** containing y,m,d,h,m,s fields, with an offset in seconds. The
52** user may elect to supply a fresh spkUTC structure each time, with
53** the offset always zero, or can supply the same spkUTC structure
54** each time and move forward using the offset alone.
55**
56** 3) The warning status "time is after end of day" usually means that
57** the second argument is greater than 60.0. However, in a day
58** ending in a leap second the limit changes to 61.0 (or 59.0 in the
59** case of a negative leap second).
60**
61** 4) The warning status "dubious year" flags UTCs that predate the
62** introduction of the time scale or that are too far in the future
63** to be trusted. See the iauDat function for further details.
64**
65** 5) The error status -7 should be impossible.
66**
67** Called:
68** iauDtf2d encode date and time fields into quasi-JD
69** iauUtctai UTC to TAI
70** iauTaiutc TAI to UTC
71** iauApco13 prepare star-independent astrometry parameters
72** iauAper13 update Earth rotation
73**
74** This revision: 2021 November 22
75**
76** Author P.T.Wallace - see license notice at end.
77*/
78
79{
80 int jstat, j;
81 double utc1, utc2, tai1, tai2, ut11, ut12;
82
83
84/* Translate UTC into SOFA internal quasi-JD. */
85 jstat = iauDtf2d ( "UTC", utc.iy, utc.mo, utc.id,
86 utc.ih, utc.mi, utc.sec, &utc1, &utc2 );
87 if ( jstat < 0 ) return jstat;
88
89/* Translate into TAI. */
90 j = iauUtctai ( utc1, utc2, &tai1, &tai2 );
91 if ( j < 0 ) return -7;
92
93/* Include the offset. */
94 tai2 += dt / DAYSEC;
95
96/* Record the TAI as MJD. */
97 ast->tai = ( tai1 - DJM0 ) + tai2;
98
99/* Translate TAI back into UTC. */
100 j = iauTaiutc ( tai1, tai2, &utc1, &utc2 );
101 if ( j < 0 ) return -7;
102
103/* Full or partial update? */
104 if ( jfull ) {
105
106 /* Full: complete refresh. */
107 j = iauApco13 ( utc1, utc2, eop->dut1, obs->slon, obs->slat,
108 obs->sh, eop->xp, eop->yp, air->p, air->t, air->h,
109 opt->wl, &ast->astrom, &ast->eo );
110 if ( j < 0 ) return -7;
111
112 } else {
113
114 /* Partial: UTC to UT1. */
115 j = iauUtcut1 ( utc1, utc2, eop->dut1, &ut11, &ut12 );
116 if ( j < 0 ) return -7;
117
118 /* Refresh the ERA. */
119 iauAper13 ( ut11, ut12, &ast->astrom );
120 }
121
122/* Return the status. */
123 return jstat;
124
125}
126
127/*----------------------------------------------------------------------
128**
129** Copyright (C) 2021 by P.T.Wallace
130**
131** Permission to use, copy, modify, and/or distribute this software for
132** any purpose with or without fee is hereby granted.
133**
134** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
135** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
136** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
137** AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
138** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
139** OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
140** NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
141** CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
142**
143**--------------------------------------------------------------------*/
int spkAstr(int jfull, spkUTC utc, double dt, spkEOP *eop, spkOBS *obs, spkAIR *air, spkOPT *opt, spkAST *ast)
Definition astr.c:4
#define iauApco13
Definition sofa.h:68
#define iauDtf2d
Definition sofa.h:59
#define iauAper13
Definition sofa.h:67
#define iauTaiutc
Definition sofa.h:62
#define iauUtctai
Definition sofa.h:61
#define iauUtcut1
Definition sofa.h:63
#define DJM0
Definition spk.h:29
#define DAYSEC
Definition spk.h:32
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
double eo
Definition spk.h:139
iauASTROM astrom
Definition spk.h:138
double tai
Definition spk.h:137
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 sh
Definition spk.h:81
Definition spk.h:94
double wl
Definition spk.h:96
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