File: bcvel.c

package info (click to toggle)
iraf-rvsao 2.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 16,456 kB
  • sloc: ansic: 963; lisp: 651; fortran: 397; makefile: 27
file content (207 lines) | stat: -rw-r--r-- 7,095 bytes parent folder | download
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
static char SccsID[] = "@(#)bcvel.c	2.1\t04/22/99";

/* Routines to return heliocentric and barycentric velocity
 * 
 */

#include <stdio.h>
#include <sys/time.h>
#include <math.h>

#include "trig.h"
#include "poly.h"

static double secliptic = 0.3978166;  /* sine and cosine of obliquity  */
static double cecliptic = 0.9174650;  /* of ecliptic (23 deg. 27 min.) */

/* Heliocentric velocity correction, km/sec */
/*
 *   *****  NEW CALCULATION BASED ON BARVEL, July 1990  *****
 *   *                                                      *
 *   *  This velocity should be better than 0.6 meters/sec  *
 *   *                                                      *
 *   ********************************************************
 */
void
bcv_vel(jdn, rastar, decstar, epoch, longitude, latitude, elevation, bcv, hcv)
     double jdn;               /* Julian day of observation */
     double rastar, decstar;   /* Star coordinate, radians */
     double epoch;             /* Star coords epoch, in Years */
     double longitude;         /* in radians west of 0 */
     double latitude;          /* in radians */
     double elevation;         /* observatory altitude, meters */
     double *bcv;              /* RETURNED = barycentric velocity */
     double *hcv;              /* RETURNED = heliocentric velocity */
{
    float bcvf, hcvf;
    void bcvcalc_();  /* FORTRAN routine for doing velocities */

    bcvcalc_(&jdn, &longitude, &latitude, &elevation, 
	     &rastar, &decstar, &epoch, &bcvf, &hcvf);
    *bcv = (double)bcvf;
    *hcv = (double)hcvf;

    return;
}

void
sun_coords(jdn, rasun, decsun)
     double jdn;
     double *rasun, *decsun;  /* RETURN - coords in radians */
{
    double lsun, mlsun, masun;
    double lperisun;
    double epoch;
    double sun3long();
    
    lsun = sun3long(jdn, &mlsun, &masun);
    lperisun = mlsun - masun + M_PI;   /* longitude of perihelion */

    *rasun = atan(tan(lsun) * cecliptic);
    /* Restore to 4 quad, based on lsun */
    if(lsun <= M_PI_2)             /* no-op */ ;
    else if(lsun <= 1.5 * M_PI)    *rasun += M_PI;
    else                           *rasun += M_PI * 2;
      
    *decsun = asin(sin(lsun) * secliptic);
    return;
}

/* SKY obs. Heliocentric velocity correction, km/sec;
 *   The sky correction uses the position of the Sun, not the
 *   RA and Dec the telescope is pointing at.
 */
void
skybcv_vel(jdn, longitude, latitude, elevation, bcv, hcv)
     double jdn;               /* Julian day of observation */
     double longitude;         /* in radians west of 0 */
     double latitude;          /* in radians */
     double elevation;         /* observatory altitude, meters */
     double *bcv;              /* RETURNED = barycentric velocity */
     double *hcv;              /* RETURNED = heliocentric velocity */
{
    float bcvf, hcvf;
    double rasun, decsun;       /* Sun coordinate, radians */
    double epoch;
    void sun_coords(), bcvcalc_();

    sun_coords(jdn, &rasun, &decsun);

    /* epoch for solar coordinates is epoch of date */
    epoch =  (jdn - 2415020.0 - 0.313)/365.24219572 + 1900.0;

    bcvcalc_(&jdn, &longitude, &latitude, &elevation, 
	     &rasun, &decsun, &epoch, &bcvf, &hcvf);
    *bcv = (double)bcvf;
    *hcv = (double)hcvf;

    return;
}


/* OLD ROUTINE, WITH JULY 1990 CORRECTIONS, Good to about 30 meters/sec.
 * N.B. - removed the corrections for archival comparisons, August 1990.
 *    the routine is now offset by about +40 meters/sec, so is good to
 *    about 70 meters/sec.
 */
double 
hcvel(jdn, rastar, decstar, longitude, latitude, dvorb, dvrot)
     double jdn;               /* Julian day of observation */
     double rastar, decstar;   /* Star coordinate, radians, CURRENT EPOCH */
     double longitude;         /* in radians west of 0 */
     double latitude;          /* in radians */
     double *dvorb;   /* RETURN if non-NULL = orbital part */
     double *dvrot;   /* RETURN if non-NULL = rotational part */
{
    double rsidtime(), sun3long();
    double sra  = sin(rastar),  cra  = cos(rastar);
    double sdec = sin(decstar), cdec = cos(decstar);
    double lsun, mlsun, masun;
    double lperisun;
    double dvo, dvr;
    
    lsun = sun3long(jdn, &mlsun, &masun);
    lperisun = mlsun - masun + M_PI;   /* longitude of perihelion */

    /* NOTE - this constant should be 29.79, but since this routine has been
     * superseeded by skybcv_vel, the old value is left in as a check
     * against NOVA-derived files.
     */
    dvo = 29.75 * 
         (sin(lsun) * cdec * cra -
          (sdec * secliptic + cdec * cecliptic * sra) * cos(lsun))
       - 0.49736 *
         (sin(lperisun) * cdec * cra -
          (sdec * secliptic + cdec * sra * cecliptic) * cos(lperisun));

    dvr = -0.46509 * cos(latitude) * cdec * 
      sin(rsidtime(jdn, longitude, 0) - rastar);

    if(dvorb != (double *)NULL)  *dvorb = dvo;
    if(dvrot != (double *)NULL)  *dvrot = dvr;

    return(dvo + dvr);
}

/* OLD ROUTINE, WITH JULY 1990 CORRECTIONS, Good to about 30 meters/sec
 * N.B. - removed the corrections for archival comparisons, August 1990.
 *    the routine is now offset by about +40 meters/sec, so is good to
 *    about 70 meters/sec.
 */

/* SKY obs. Heliocentric velocity correction, km/sec;
 *   The sky correction uses the position of the Sun, not the
 *   RA and Dec the telescope is pointing at.
 */
double 
skyvel(jdn, longitude, latitude, dvorb, dvrot)
     double jdn;               /* Julian day of observation */
     double longitude;         /* in radians west of 0 */
     double latitude;          /* in radians */
     double *dvorb;   /* RETURN if non-NULL = orbital part */
     double *dvrot;   /* RETURN if non-NULL = rotational part */
{
    double rsidtime(), sun3long();
    double rasun, decsun;       /* Sun coordinate, radians */
    double sra,  cra;
    double sdec, cdec;
    double lsun, mlsun, masun;
    double lperisun;
    double dvo, dvr;
    
    lsun = sun3long(jdn, &mlsun, &masun);
    lperisun = mlsun - masun + M_PI;   /* longitude of perihelion */

    rasun = atan(tan(lsun) * cecliptic);
    /* Restore to 4 quad, based on lsun */
    if(lsun <= M_PI_2)       /* no-op */ ;
    else if(lsun <= 1.5 * M_PI)    rasun += M_PI;
    else                           rasun += M_PI * 2;
      
    decsun = asin(sin(lsun) * secliptic);
    
    sra  = sin(rasun);
    cra  = cos(rasun);
    sdec = sin(decsun);
    cdec = cos(decsun);

    /* NOTE - this constant should be 29.79, but since this routine has been
     * superseeded by skybcv_vel, the old value is left in as a check
     * against NOVA-derived files.
     */
    dvo = 29.75 * 
         (sin(lsun) * cdec * cra -
          (sdec * secliptic + cdec * cecliptic * sra) * cos(lsun))
       - 0.49736 *
         (sin(lperisun) * cdec * cra -
          (sdec * secliptic + cdec * sra * cecliptic) * cos(lperisun));

    dvr = -0.46509 * cos(latitude) * cdec * 
      sin(rsidtime(jdn, longitude, 0) - rasun);

    if(dvorb != (double *)NULL)  *dvorb = dvo;
    if(dvrot != (double *)NULL)  *dvrot = dvr;

    return(dvo + dvr);
}