Sun position
Sun position algorithm
star.h
Go to the documentation of this file.
1 #ifndef STAR_H
2 #define STAR_H
3 /*============================================================================*/
4 /*!\file
5  * \brief star.h - Astronomical conversion routines for stars and other objects
6  * beyond the Solar System
7  *
8  * \author David Hoadley
9  *
10  * \details
11  * Routines to convert a celestial object's catalogue position (as
12  * seen from the Solar System Barycentre) to a geocentric apparent
13  * position (as seen from the centre of the Earth). This means
14  * - find the position and velocity of the Earth with respect to the
15  * Solar System Barycentre.
16  * - apply proper motion from the catalogue epoch to the desired epoch
17  * - offset the position by the position of the Earth (apply Annual
18  * Parallax)
19  * - use the velocity of the Earth to calculate the Annual Aberration
20  * correction
21  *
22  * The geocentric position calculated is then converted from the
23  * coordinate system of the catalogue position to apparent coordinates.
24  * (Exception: if the catalogue position is already in Celestial
25  * Intermediate coordinates, then the resulting vector will still be
26  * in Celestial Intermediate coordinates.)
27  *
28  *==============================================================================
29  */
30 /*
31  * Copyright (c) 2020, David Hoadley <vcrumble@westnet.com.au>
32  * All rights reserved.
33  *
34  * Redistribution and use in source and binary forms, with or without
35  * modification, are permitted provided that the following conditions are met:
36  *
37  * * Redistributions of source code must retain the above copyright notice, this
38  * list of conditions and the following disclaimer.
39  * * Redistributions in binary form must reproduce the above copyright notice,
40  * this list of conditions and the following disclaimer in the documentation
41  * and/or other materials provided with the distribution.
42  *
43  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
44  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
47  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
48  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
49  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
50  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
51  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
53  * POSSIBILITY OF SUCH DAMAGE.
54  */
55 /*------------------------------------------------------------------------------
56  * Notes:
57  * Character set: UTF-8. (Non-ASCII characters appear in this file)
58  *----------------------------------------------------------------------------*/
59 
60 #include "sky1.h"
61 #include "general.h"
62 #include "sky.h"
63 #include "vectors3d.h"
64 
65 /*
66  * Global #defines and typedefs
67  */
68 /*! Coordinate system equator and origin */
69 typedef enum {
70  APPARENT, //!< True equator and equinox of date
71  INTERMEDIATE, //!< True equator and CIO of date
72  FK4, //!< Mean equator and equinox of Besselian epoch
73  FK5, //!< Mean equator and equinox of Julian epoch
74  ICRS //!< International Celestial Reference System
76 
77 
78 /*! Catalogue position of a celestial object. */
79 typedef struct {
80  char objectName[80];//!< Name of the celestial object (optional)
81  double ra_rad; //!< α - Right Ascension (radian)
82  double dec_rad; //!< δ - Declination (radian)
83  Star_CoordSys cSys; //!< equator and origin used for α & δ
84  double eqnxT_cy; /*!< time of equinox for FK4 or FK5 positions (Julian
85  * centuries since J2000, TT timescale) */
86  double epochT_cy; /*!< time zero for proper motion (Julian centuries
87  * since J2000, TT timescale) */
88  bool epochSpecified;//!< equinox and epoch were separately specified
89  double muRA_radpcy; //!< μα - Proper motion in RA (radian/Julian century)
90  double muDec_radpcy; //!< μδ - Proper motion in Dec (radian/Julian century)
91  double parallax_rad; //!< π - annual parallax (radian)
92  double radVel_aupcy; //!< ν - radial velocity (AU/Julian century)
93  bool muRaInclCosDec;//!< μα term already includes the cosδ factor
95 
96 /*! Errors detected when decoding a text coordinate string or when filling a
97  block of type Star_CatalogPosn with numerical data */
98 typedef enum {
99  STAR_NORMAL, /*!< Normal successful completion */
100  STAR_IVEPOCH, /*!< Invalid epoch or equinox specification */
101  STAR_ERRINOBJ, /*!< Error extracting object name from the string.
102  * (comma missing at end?, or name started with a
103  * double quote char but there was no closing
104  * double-quote?) */
105  STAR_NORA, /*!< Specification of Right Ascension is missing */
106  STAR_ERRINRA, /*!< Right Ascension can't be decoded */
107  STAR_RARANERR, /*!< Right Ascension out of range */
108  STAR_NODEC, /*!< Specification of Declination is missing */
109  STAR_ERRINDEC, /*!< Declination can't be decoded */
110  STAR_DECRANERR, /*!< Declination out of range */
111  STAR_ERRINMURA, /*!< Proper motion in RA can't be decoded */
112  STAR_ERRINMUDEC, /*!< Proper motion in Declination can't be decoded */
113  STAR_NOMUDEC, /*!< Specification of proper motion in Dec is missing
114  * when mu_ra was provided. Check commas in string */
115  STAR_NOMURA, /*!< Specification of proper motion in RA is missing
116  * when mu_dec was provided. Check commas in string */
117  STAR_ERRINPARAL, /*!< Parallax can't be decoded */
118  STAR_PINEEDSPM, /*!< Proper motion must be specified if specifying
119  * parallax */
120  STAR_ERRINVR, /*!< Radial Velocity can't be decoded */
121  STAR_VRNEEDSPM /*!< Proper motion and parallax must be specified if
122  * specifying Radial Velocity */
124 
125 /*
126  * Global functions available to be called by other modules
127  */
129 
130 /* Functions to get the current position of the star */
131 void star_catalogToApp(const Star_CatalogPosn *c,
132  double j2kTT_cy,
133  const Sky1_Nut1980 *nut,
134  V3D_Vector *appV,
135  double *dist_au);
136 void star_getApparent(double j2kTT_cy, Sky_TrueEquatorial *pos);
137 void star_getTopocentric(double j2kUtc_d,
138  const Sky_DeltaTs *deltas,
139  const Sky_SiteProp *site,
140  Sky_SiteHorizon *topo);
141 
142 /* Alternative functions to set up a coordinate block */
143 int star_setCatalogPosn(const char objectName[],
144  double ra_h,
145  double dec_deg,
146  Star_CoordSys coordSys,
147  double equinoxYear,
148  double epochYear,
149  double muRaSplat_maspa,
150  double muDec_maspa,
151  double annParallax_as,
152  double radVel_kmps,
153  Star_CatalogPosn *coordBlock);
154 int star_setCatalogOldStyle(const char objectName[],
155  double ra_h,
156  double dec_deg,
157  Star_CoordSys coordSys,
158  double equinoxYear,
159  double epochYear,
160  double muRa_spcy,
161  double muDec_aspcy,
162  double annParallax_as,
163  double radVel_kmps,
164  Star_CatalogPosn *coordBlock);
165 int star_parseCoordString(const char inStr[],
166  Star_CatalogPosn *coordBlock);
167 
168 /* Functions called by the above functions */
170  V3D_Vector *pV,
171  V3D_Vector *vV_radpcy);
172 void star_earth(double t1_cy,
173  const V3D_Matrix *npM,
174  V3D_Vector *ebV_au,
175  V3D_Vector *ebdotV_aupd,
176  V3D_Vector *sbV_au);
177 void star_annAberr(const V3D_Vector *p1V,
178  const V3D_Vector *earthVelV_aupd,
179  V3D_Vector *p2V);
180 
181 /* Writing out equinox and epoch in standard form */
182 char *star_equinoxToStr(const Star_CatalogPosn *coordBlock,
183  char equinoxStr[],
184  size_t eqnxStrSize);
185 char *star_epochToStr(const Star_CatalogPosn *coordBlock,
186  char epochStr[],
187  size_t epochStrSize);
188 
189 #if 0
190 void star_lightDeflection(const V3D_Vector *pV,
191  const V3D_Vector *earthBV_au,
192  const V3D_Vector *earthVelV_aupd,
193  const V3D_Vector *sunBV_au,
194  V3D_Vector *p2V);
195 #endif
196 
197 /*
198  * Global variables accessible by other modules
199  */
200 
201 #endif /*STAR_H*/
sky1.h
sky1.h - astronomical coordinate conversion routines, IAU 1980
Star_CatalogPosn::muDec_radpcy
double muDec_radpcy
μδ - Proper motion in Dec (radian/Julian century)
Definition: star.h:90
star_catalogToVectors
void star_catalogToVectors(const Star_CatalogPosn *c, V3D_Vector *pV, V3D_Vector *vV_radpcy)
This routine takes the mean equatorial polar coordinate of an object and its proper motions,...
Definition: star.c:403
general.h
general.h - definitions of general use to (standard) C programs
STAR_ERRINMUDEC
@ STAR_ERRINMUDEC
Proper motion in Declination can't be decoded.
Definition: star.h:112
Sky_DeltaTs
This structure contains relatively constant data, and is set up by one of the three functions sky_ini...
Definition: sky.h:166
Sky1_Nut1980
Nutation angles and obliquity.
Definition: sky1.h:75
STAR_ERRINDEC
@ STAR_ERRINDEC
Declination can't be decoded.
Definition: star.h:109
STAR_ERRINMURA
@ STAR_ERRINMURA
Proper motion in RA can't be decoded.
Definition: star.h:111
Star_CoordSys
Star_CoordSys
Coordinate system equator and origin.
Definition: star.h:69
star_setCatalogPosn
int star_setCatalogPosn(const char objectName[], double ra_h, double dec_deg, Star_CoordSys coordSys, double equinoxYear, double epochYear, double muRaSplat_maspa, double muDec_maspa, double annParallax_as, double radVel_kmps, Star_CatalogPosn *coordBlock)
This is one of three alternative routines for loading the information for a celestial object into a b...
Definition: star.c:763
Star_CatalogPosn::epochSpecified
bool epochSpecified
equinox and epoch were separately specified
Definition: star.h:88
Sky_TrueEquatorial
Struct used for holding an object's coordinates in equatorial apparent or Intermediate coordinates.
Definition: sky.h:106
STAR_NORA
@ STAR_NORA
Specification of Right Ascension is missing.
Definition: star.h:105
STAR_NOMURA
@ STAR_NOMURA
Specification of proper motion in RA is missing when mu_dec was provided.
Definition: star.h:115
STAR_ERRINRA
@ STAR_ERRINRA
Right Ascension can't be decoded.
Definition: star.h:106
Star_CatalogPosn::ra_rad
double ra_rad
α - Right Ascension (radian)
Definition: star.h:81
Star_CatalogPosn::parallax_rad
double parallax_rad
π - annual parallax (radian)
Definition: star.h:91
STAR_DECRANERR
@ STAR_DECRANERR
Declination out of range.
Definition: star.h:110
star_epochToStr
char * star_epochToStr(const Star_CatalogPosn *coordBlock, char epochStr[], size_t epochStrSize)
Write the epoch used for proper motion calculations out in a standard form.
Definition: star.c:698
Sky_SiteProp
Site properties.
Definition: sky.h:315
star_getTopocentric
void star_getTopocentric(double j2kUtc_d, const Sky_DeltaTs *deltas, const Sky_SiteProp *site, Sky_SiteHorizon *topo)
Calls star_getApparent() to calculate the star's position in apparent coordinates,...
Definition: star.c:356
star_annAberr
void star_annAberr(const V3D_Vector *p1V, const V3D_Vector *earthVelV_aupd, V3D_Vector *p2V)
Apply the annual aberration correction, to convert an object's coordinates from geocentric geometric ...
Definition: star.c:603
Star_CatalogPosn::muRaInclCosDec
bool muRaInclCosDec
μα term already includes the cosδ factor.
Definition: star.h:93
Star_CatalogPosn::cSys
Star_CoordSys cSys
equator and origin used for α & δ
Definition: star.h:83
APPARENT
@ APPARENT
True equator and equinox of date.
Definition: star.h:70
ICRS
@ ICRS
International Celestial Reference System.
Definition: star.h:74
star_getApparent
void star_getApparent(double j2kTT_cy, Sky_TrueEquatorial *pos)
Calculate the position of the currently selected star (or other object outside the solar system) as a...
Definition: star.c:315
star_earth
void star_earth(double t1_cy, const V3D_Matrix *npM, V3D_Vector *ebV_au, V3D_Vector *ebdotV_aupd, V3D_Vector *sbV_au)
Calculate the position and velocity of the Earth, for use in making annual parallax and aberration co...
Definition: star.c:461
Star_CoordErrors
Star_CoordErrors
Errors detected when decoding a text coordinate string or when filling a block of type Star_CatalogPo...
Definition: star.h:98
STAR_ERRINVR
@ STAR_ERRINVR
Radial Velocity can't be decoded.
Definition: star.h:120
V3D_Matrix
3x3 matrix.
Definition: vectors3d.h:51
Star_CatalogPosn::muRA_radpcy
double muRA_radpcy
μα - Proper motion in RA (radian/Julian century)
Definition: star.h:89
V3D_Vector
3x1 vector.
Definition: vectors3d.h:57
Star_CatalogPosn::epochT_cy
double epochT_cy
time zero for proper motion (Julian centuries since J2000, TT timescale)
Definition: star.h:86
FK4
@ FK4
Mean equator and equinox of Besselian epoch.
Definition: star.h:72
star_setCatalogOldStyle
int star_setCatalogOldStyle(const char objectName[], double ra_h, double dec_deg, Star_CoordSys coordSys, double equinoxYear, double epochYear, double muRa_spcy, double muDec_aspcy, double annParallax_as, double radVel_kmps, Star_CatalogPosn *coordBlock)
This is one of three alternative routines for loading the information for a celestial object into a b...
Definition: star.c:868
star_parseCoordString
int star_parseCoordString(const char inStr[], Star_CatalogPosn *coordBlock)
This is one of three alternative routines for loading the information for a celestial object into a b...
Definition: star.c:972
FK5
@ FK5
Mean equator and equinox of Julian epoch.
Definition: star.h:73
INTERMEDIATE
@ INTERMEDIATE
True equator and CIO of date.
Definition: star.h:71
sky.h
sky.h - structures and routines for astronomical observing & tracking
STAR_NOMUDEC
@ STAR_NOMUDEC
Specification of proper motion in Dec is missing when mu_ra was provided.
Definition: star.h:113
vectors3d.h
vectors3d.h - Three dimensional geometry, vectors and matrices
STAR_ERRINPARAL
@ STAR_ERRINPARAL
Parallax can't be decoded.
Definition: star.h:117
STAR_ERRINOBJ
@ STAR_ERRINOBJ
Error extracting object name from the string.
Definition: star.h:101
Star_CatalogPosn
Catalogue position of a celestial object.
Definition: star.h:79
STAR_RARANERR
@ STAR_RARANERR
Right Ascension out of range.
Definition: star.h:107
star_catalogToApp
void star_catalogToApp(const Star_CatalogPosn *c, double j2kTT_cy, const Sky1_Nut1980 *nut, V3D_Vector *appV, double *dist_au)
Convert the catalogue coordinates for a star (or other object outside the Solar System) to apparent c...
Definition: star.c:148
star_setCurrentObject
void star_setCurrentObject(const Star_CatalogPosn *c)
Copies the catalogue information in c to internal storage for later use by star_getApparent()
Definition: star.c:135
STAR_PINEEDSPM
@ STAR_PINEEDSPM
Proper motion must be specified if specifying parallax.
Definition: star.h:118
STAR_VRNEEDSPM
@ STAR_VRNEEDSPM
Proper motion and parallax must be specified if specifying Radial Velocity.
Definition: star.h:121
Star_CatalogPosn::radVel_aupcy
double radVel_aupcy
ν - radial velocity (AU/Julian century)
Definition: star.h:92
Star_CatalogPosn::dec_rad
double dec_rad
δ - Declination (radian)
Definition: star.h:82
STAR_NORMAL
@ STAR_NORMAL
Normal successful completion.
Definition: star.h:99
STAR_NODEC
@ STAR_NODEC
Specification of Declination is missing.
Definition: star.h:108
STAR_IVEPOCH
@ STAR_IVEPOCH
Invalid epoch or equinox specification.
Definition: star.h:100
Sky_SiteHorizon
Coordinates of a celestial object in the horizon frame, in both rectangular and polar forms.
Definition: sky.h:129
star_equinoxToStr
char * star_equinoxToStr(const Star_CatalogPosn *coordBlock, char equinoxStr[], size_t eqnxStrSize)
Write the coordinate system and equinox out in a standard form.
Definition: star.c:632
Star_CatalogPosn::eqnxT_cy
double eqnxT_cy
time of equinox for FK4 or FK5 positions (Julian centuries since J2000, TT timescale)
Definition: star.h:84