mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-05-19 06:17:03 -04:00
Starting to implement ValidateTop2013().
Adding infrastructure for loading TOP2013 models of planets and calculating them. Will start with a unit test to verify I'm calculating the formulas correctly.
This commit is contained in:
@@ -12,7 +12,7 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
${CC} ${BUILDOPT} -Wall -Werror -o generate -I novas -I vsop \
|
||||
${CC} ${BUILDOPT} -Wall -Werror -o generate -I novas -I vsop -I top2013 -I . \
|
||||
generate.c \
|
||||
earth.c \
|
||||
astro_vector.c \
|
||||
@@ -20,6 +20,7 @@ ${CC} ${BUILDOPT} -Wall -Werror -o generate -I novas -I vsop \
|
||||
codegen.c \
|
||||
ephfile.c \
|
||||
vsop/vsop.c \
|
||||
top2013/top2013.c \
|
||||
novas/novas.c \
|
||||
novas/novascon.c \
|
||||
novas/nutation.c \
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "ephfile.h"
|
||||
#include "novas_body.h"
|
||||
#include "vsop.h"
|
||||
#include "top2013.h"
|
||||
|
||||
int Verbose;
|
||||
#define DEBUG(...) do{if(Verbose)printf(__VA_ARGS__);}while(0)
|
||||
@@ -92,6 +93,7 @@ static int UnitTestChebyshev(void);
|
||||
static int DistancePlot(const char *name, double tt1, double tt2);
|
||||
static int ImproveVsopApsides(vsop_model_t *model);
|
||||
static int DeltaTimePlot(const char *outFileName);
|
||||
static int ValidateTop2013(int planet);
|
||||
|
||||
#define MOON_PERIGEE 0.00238
|
||||
#define MERCURY_APHELION 0.466697
|
||||
@@ -142,6 +144,9 @@ int main(int argc, const char *argv[])
|
||||
if (argc == 2 && !strcmp(argv[1], "pluto"))
|
||||
return GeneratePluto();
|
||||
|
||||
if (argc == 3 && !strcmp(argv[1], "validate_top2013"))
|
||||
return ValidateTop2013(atoi(argv[2]));
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "apsis"))
|
||||
return GenerateApsisTestData();
|
||||
|
||||
@@ -191,6 +196,15 @@ static int PrintUsage(void)
|
||||
"generate dtplot outfile.csv\n"
|
||||
" Generate a CSV plot of the Delta-T extrapolator.\n"
|
||||
"\n"
|
||||
"generate validate_top2013 planet\n"
|
||||
" Validates code for calculating outer planet positions using TOP2013.\n"
|
||||
" The 'planet' parameter is one of the following:\n"
|
||||
" 5 = Jupiter\n"
|
||||
" 6 = Saturn\n"
|
||||
" 7 = Uranus\n"
|
||||
" 8 = Neptune\n"
|
||||
" 9 = Pluto\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
return 1;
|
||||
@@ -1837,3 +1851,19 @@ fail:
|
||||
if (outfile != NULL) fclose(outfile);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------------*/
|
||||
|
||||
static int ValidateTop2013(int planet)
|
||||
{
|
||||
int error = 1;
|
||||
top_model_t model;
|
||||
|
||||
TopInitModel(&model);
|
||||
|
||||
CHECK(TopLoadModel(&model, "TOP2013.dat", planet));
|
||||
|
||||
fail:
|
||||
TopFreeModel(&model);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ Download()
|
||||
|
||||
Download https://github.com/cosinekitty/ephemeris/raw/master/lnxp1600p2200.405 lnxp1600p2200.405 ephemeris.sha256 ephemeris.md5
|
||||
Download https://github.com/cosinekitty/ephemeris/raw/master/top2013/TOP2013.dat TOP2013.dat top2013.sha256 top2013.md5
|
||||
Download https://raw.githubusercontent.com/astronexus/HYG-Database/master/hygdata_v3.csv hygdata_v3.csv hygdata_v3.sha256 hygdata_v3.sha256
|
||||
Download https://raw.githubusercontent.com/astronexus/HYG-Database/master/hygdata_v3.csv hygdata_v3.csv hygdata_v3.sha256 hygdata_v3.md5
|
||||
|
||||
rm -f constellation/test_input.txt
|
||||
./make_constellation_data.py || Fail "Error creating constellation test data."
|
||||
|
||||
44
generate/top2013/top2013.c
Normal file
44
generate/top2013/top2013.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
top2013.c - Don Cross - 2020-06-30
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "codegen.h"
|
||||
#include "top2013.h"
|
||||
|
||||
|
||||
void TopInitModel(top_model_t *model)
|
||||
{
|
||||
memset(model, 0, sizeof(top_model_t));
|
||||
}
|
||||
|
||||
|
||||
void TopFreeModel(top_model_t *model)
|
||||
{
|
||||
int f, s;
|
||||
for (f=0; f < TOP_NCOORDS; ++f)
|
||||
for (s=0; s < model->formula[f].nseries_total; ++s)
|
||||
free(model->formula[f].series[s].terms);
|
||||
|
||||
TopInitModel(model);
|
||||
}
|
||||
|
||||
|
||||
int TopLoadModel(top_model_t *model, const char *filename, int planet)
|
||||
{
|
||||
int error = 1;
|
||||
FILE *infile = NULL;
|
||||
|
||||
TopInitModel(model);
|
||||
infile = fopen(filename, "rt");
|
||||
if (infile == NULL)
|
||||
FAIL("TopLoadModel: cannot open file: %s\n", filename);
|
||||
|
||||
error = 0;
|
||||
fail:
|
||||
if (infile != NULL) fclose(infile);
|
||||
return error;
|
||||
}
|
||||
53
generate/top2013/top2013.h
Normal file
53
generate/top2013/top2013.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
top2013.h - Don Cross - 2020-06-30
|
||||
|
||||
Loads and calculates planetary positions using TOP2013 analytic models.
|
||||
See: https://en.wikipedia.org/wiki/VSOP_(planets)
|
||||
*/
|
||||
#ifndef __DDC_TOP2013_H
|
||||
#define __DDC_TOP2013_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double k; /* mu coefficient */
|
||||
double c; /* cosine coefficient */
|
||||
double s; /* sine coefficient */
|
||||
double p; /* period expressed in years */
|
||||
}
|
||||
top_term_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nterms_total;
|
||||
int nterms_calc;
|
||||
top_term_t *terms;
|
||||
}
|
||||
top_series_t;
|
||||
|
||||
#define TOP_MAX_SERIES 13
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nseries_total;
|
||||
int nseries_calc;
|
||||
top_series_t series[TOP_MAX_SERIES];
|
||||
}
|
||||
top_formula_t;
|
||||
|
||||
|
||||
#define TOP_NCOORDS 6
|
||||
|
||||
typedef struct
|
||||
{
|
||||
top_formula_t formula[TOP_NCOORDS];
|
||||
}
|
||||
top_model_t;
|
||||
|
||||
|
||||
void TopInitModel(top_model_t *model);
|
||||
void TopFreeModel(top_model_t *model);
|
||||
int TopLoadModel(top_model_t *model, const char *filename, int planet);
|
||||
|
||||
|
||||
#endif /* __DDC_TOP2013_H */
|
||||
Reference in New Issue
Block a user