/*
* This can be used to get a rough idea of the HF propagation delay
* between two points (usually between you and the radio station).
* The usage is
*
* propdelay latitudeA longitudeA latitudeB longitudeB
*
* where points A and B are the locations in question. You obviously
* need to know the latitude and longitude of each of the places.
* The program expects the latitude to be preceded by an 'n' or 's'
* and the longitude to be preceded by an 'e' or 'w'. It understands
* either decimal degrees or degrees:minutes:seconds. Thus to compute
* the delay between the WWVH (21:59:26N, 159:46:00W) and WWV (40:40:49N,
* 105:02:27W) you could use:
*
* propdelay n21:59:26 w159:46 n40:40:49 w105:02:27
*
* By default it prints out a summer (F2 average virtual height 350 km) and
* winter (F2 average virtual height 250 km) number. The results will be
* quite approximate but are about as good as you can do with HF time anyway.
* You might pick a number between the values to use, or use the summer
* value in the summer and switch to the winter value when the static
* above 10 MHz starts to drop off in the fall. You can also use the
* -h switch if you want to specify your own virtual height.
*
* You can also do a
*
* propdelay -W n45:17:47 w75:45:22
*
* to find the propagation delays to WWV and WWVH (from CHU in this
* case), a
*
* propdelay -C n40:40:49 w105:02:27
*
* to find the delays to CHU, and a
*
* propdelay -G n52:03:17 w98:34:18
*
* to find delays to GOES via each of the three satellites.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include "ntp_stdlib.h"
extern double sin (double);
extern double cos (double);
extern double acos (double);
extern double tan (double);
extern double atan (double);
extern double sqrt (double);
/*
* waveangle - compute the wave angle for the given distance, virtual
* height and number of hops.
*/
static double
waveangle(
double dg,
double h,
int n
)
{
double theta;
double delta;
/*
* finddelay - find the propagation delay
*/
static int
finddelay(
double lat1,
double long1,
double lat2,
double long2,
double h,
double *delay
)
{
double dg; /* great circle distance */
double delta; /* wave angle */
int n; /* number of hops */
dg = greatcircle(lat1, long1, lat2, long2);
if (debug)
printf("great circle distance %g km %g miles\n", dg, dg/MILE);
n = 1;
while ((delta = waveangle(dg, h, n)) < 0.0) {
if (debug)
printf("tried %d hop%s, no good\n", n, n>1?"s":"");
n++;
}
if (debug)
printf("%d hop%s okay, wave angle is %g\n", n, n>1?"s":"",
delta / RADPERDEG);
/*
* satfinddelay - calculate the one-way delay time between a ground station
* and a satellite
*/
static void
satfinddelay(
double lat1,
double long1,
double lat2,
double long2,
double *delay
)
{
double dg; /* great circle distance */
dg = greatcircle(lat1, long1, lat2, long2);
*delay = satpropdelay(dg);
}
/*
* satpropdelay - calculate the one-way delay time between a ground station
* and a satellite
*/
static double
satpropdelay(
double dg
)
{
double k1, k2, dist;
double theta;
double td;