Wrote scripts to plot Pluto distance, comparing NOVAS vs TOP2013.

The data plot confirms there is some kind of high-frequency error
that causes excessive local minima/maxima that fools the apside
finder.
This commit is contained in:
Don Cross
2020-07-06 14:47:07 -04:00
parent d89b9a19d5
commit 28749fd671
5 changed files with 106 additions and 1 deletions

1
generate/.gitignore vendored
View File

@@ -2,6 +2,7 @@ generate_c_docs
generate
lnxp1600p2200.405
hygdata_v3.csv
pluto_*.csv
TOP2013.dat
temp/
html/

View File

@@ -90,6 +90,7 @@ static int LocalSolarEclipseTest(void);
static int LocalSolarEclipseTest1(void);
static int LocalSolarEclipseTest2(void);
static int Transit(void);
static int DistancePlot(astro_body_t body, double ut1, double ut2, const char *filename);
typedef int (* unit_test_func_t) (void);
@@ -179,6 +180,29 @@ int main(int argc, const char *argv[])
goto success;
}
}
if (argc == 6)
{
if (!strcmp(verb, "distplot"))
{
/* ctest distplot name tt1 tt2 */
astro_body_t body;
double ut1, ut2;
body = Astronomy_BodyCode(argv[2]);
if (body == BODY_INVALID)
FAIL("Invalid body name '%s'\n", argv[2]);
if (1 != sscanf(argv[3], "%lf", &ut1))
FAIL("Invalid tt1 value '%s'\n", argv[3]);
if (1 != sscanf(argv[4], "%lf", &ut2))
FAIL("Invalid tt2 value '%s'\n", argv[4]);
CHECK(DistancePlot(body, ut1, ut2, argv[5]));
goto success;
}
}
}
FAIL("ctest: Invalid command line arguments.\n");
@@ -3210,3 +3234,37 @@ fail:
}
/*-----------------------------------------------------------------------------------------------------------*/
static int DistancePlot(astro_body_t body, double ut1, double ut2, const char *filename)
{
const int npoints = 100000;
int error = 1;
int i;
double ut;
astro_time_t time, j2000;
astro_func_result_t dist;
FILE *outfile = NULL;
outfile = fopen(filename, "wt");
if (outfile == NULL)
FAIL("DistancePlot: Cannot open output file: %s\n", filename);
j2000 = Astronomy_MakeTime(2000, 1, 1, 12, 0, 0.0);
fprintf(outfile, "\"tt\",\"distance\"\n");
for (i=0; i < npoints; ++i)
{
ut = ut1 + (((double)i)/((double)(npoints-1)) * (ut2 - ut1));
time = Astronomy_AddDays(j2000, ut);
dist = Astronomy_HelioDistance(body, time);
CHECK_STATUS(dist);
fprintf(outfile, "%0.16lf,%0.16lg\n", time.tt, dist.value);
}
error = 0;
fail:
if (outfile != NULL) fclose(outfile);
return error;
}
/*-----------------------------------------------------------------------------------------------------------*/

View File

@@ -1809,7 +1809,7 @@ static int DistancePlot(const char *name, double tt1, double tt2)
double pos[3];
double tt, dist;
int i;
const int npoints = 1000;
const int npoints = 100000;
CHECK(OpenEphem());

7
generate/plot_pluto Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
rm -f pluto_{novas,top}.csv
./build || exit $?
./generate distplot Pluto -50000 +50000 > pluto_novas.csv || exit $?
./ctbuild || exit $?
./ctest distplot Pluto -200000 +200000 pluto_top.csv || exit $?
./plotdist.py pluto_novas.csv pluto_top.csv || exit $?

39
generate/plotdist.py Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python3
import sys
import re
import matplotlib.pyplot as plt
def LoadCsv(inFileName):
xlist = []
ylist = []
with open(inFileName, 'rt') as infile:
lnum = 0
for line in infile:
line = line.strip()
lnum += 1
if lnum > 1:
token = line.split(',')
if len(token) < 2:
raise Exception('Invalid CSV line {} in file {}'.format(lnum, inFileName))
xlist.append(float(token[0]))
ylist.append(float(token[1]))
return xlist, ylist
def PlotData(novasFileName, topFileName):
novas_tlist, novas_rlist = LoadCsv(novasFileName)
top_tlist, top_rlist = LoadCsv(topFileName)
plt.plot(novas_tlist, novas_rlist, 'b.')
plt.plot(top_tlist, top_rlist, 'r.')
plt.show()
plt.close('all')
return 0
if __name__ == '__main__':
if len(sys.argv) != 3:
print('USAGE: plotdist.py novas_dist.csv top_dist.csv')
sys.exit(1)
sys.exit(PlotData(sys.argv[1], sys.argv[2]))