celestia/src/celephem/jpleph.h

96 lines
2.0 KiB
C
Raw Permalink Normal View History

// jpleph.h
//
// Copyright (C) 2004, Chris Laurel <claurel@shatters.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// Load JPL's DE200, DE405, and DE406 ephemerides and compute planet
// positions.
#ifndef _CELENGINE_JPLEPH_H_
#define _CELENGINE_JPLEPH_H_
#include <iostream>
#include <vector>
#include <Eigen/Core>
enum JPLEphemItem
{
JPLEph_Mercury = 0,
JPLEph_Venus = 1,
JPLEph_EarthMoonBary = 2,
JPLEph_Mars = 3,
JPLEph_Jupiter = 4,
JPLEph_Saturn = 5,
JPLEph_Uranus = 6,
JPLEph_Neptune = 7,
JPLEph_Pluto = 8,
JPLEph_Moon = 9,
JPLEph_Sun = 10,
JPLEph_Earth = 11,
JPLEph_SSB = 12,
};
#define JPLEph_NItems 12
struct JPLEphCoeffInfo
{
unsigned int offset;
unsigned int nCoeffs;
unsigned int nGranules;
};
struct JPLEphRecord
{
JPLEphRecord() = default;
~JPLEphRecord();
double t0{ 0.0 };
double t1{ 0.0 };
double* coeffs{ nullptr };
};
class JPLEphemeris
{
private:
JPLEphemeris() = default;
public:
~JPLEphemeris() = default;
Eigen::Vector3d getPlanetPosition(JPLEphemItem, double t) const;
static JPLEphemeris* load(std::istream&);
unsigned int getDENumber() const;
double getStartDate() const;
double getEndDate() const;
Add support for more JPL compatible ephemerides Original patch was posted to https://celestia.space/forum/viewtopic.php?f=4&t=17282 ==================================== Here comes the original description: ==================================== Before this update, the celestia code supports only JPL Big Endian ephemerides DE406/DE405/DE200. The big endian ephemeris DE406 comes in chunk of 300 years. If you want to concatenate several pieces, using the software provided by JPL (which does not handle endianess), you need a big endian platform. The little endian DE406 comes in one piece of 6000 years, so you don't even need to concatenate this one. This commit adds the following: - support for both endianess with autodetection of endianess - support for all JPL DE ephemeris (from DE200) with autodetection of record size. - support for JPL DE compatible ephemeris such as the INPOP ephemeris from Paris observatory (only the ephemeris files in the legacy JPL DE compatible format and with timescale TDB, not the INPOP native format, or the TCB files). http://www.imcce.fr/inpop/download10e.php The method to autodetect ephemeris type, record size and endianess is based on the CALCEPH software. It would probably be better if possible to wrap around the CALCEPH library (so that it would also support INPOP native format) but this would be more work. In addition to the ephemeris number and the start and end date, the record size and endianess are also printed to the log (which you get by pressing the tilde key). If the ephemeris is an INPOP ephemeris, then the ephemeris number is not printed to the log: it just says "INPOP". It has been tested with: - DE406 big endian - DE406 little endian - DE405 big endian - DE423 little endian - INPOP10A little endian on Linux/x86_64. However, no accurate regression testing has been performed. It has only been tested visually that the planets orbits do not look wrong and that the log is reporting the correct endianess, record size and ephemeris name.
2021-06-06 10:33:05 -06:00
bool getByteSwap() const;
unsigned int getRecordSize() const;
private:
JPLEphCoeffInfo coeffInfo[JPLEph_NItems];
JPLEphCoeffInfo librationCoeffInfo;
double startDate;
double endDate;
double daysPerInterval;
double au;
double earthMoonMassRatio;
unsigned int DENum; // ephemeris version
unsigned int recordSize; // number of doubles per record
Add support for more JPL compatible ephemerides Original patch was posted to https://celestia.space/forum/viewtopic.php?f=4&t=17282 ==================================== Here comes the original description: ==================================== Before this update, the celestia code supports only JPL Big Endian ephemerides DE406/DE405/DE200. The big endian ephemeris DE406 comes in chunk of 300 years. If you want to concatenate several pieces, using the software provided by JPL (which does not handle endianess), you need a big endian platform. The little endian DE406 comes in one piece of 6000 years, so you don't even need to concatenate this one. This commit adds the following: - support for both endianess with autodetection of endianess - support for all JPL DE ephemeris (from DE200) with autodetection of record size. - support for JPL DE compatible ephemeris such as the INPOP ephemeris from Paris observatory (only the ephemeris files in the legacy JPL DE compatible format and with timescale TDB, not the INPOP native format, or the TCB files). http://www.imcce.fr/inpop/download10e.php The method to autodetect ephemeris type, record size and endianess is based on the CALCEPH software. It would probably be better if possible to wrap around the CALCEPH library (so that it would also support INPOP native format) but this would be more work. In addition to the ephemeris number and the start and end date, the record size and endianess are also printed to the log (which you get by pressing the tilde key). If the ephemeris is an INPOP ephemeris, then the ephemeris number is not printed to the log: it just says "INPOP". It has been tested with: - DE406 big endian - DE406 little endian - DE405 big endian - DE423 little endian - INPOP10A little endian on Linux/x86_64. However, no accurate regression testing has been performed. It has only been tested visually that the planets orbits do not look wrong and that the log is reporting the correct endianess, record size and ephemeris name.
2021-06-06 10:33:05 -06:00
bool swapBytes;
std::vector<JPLEphRecord> records;
};
#endif // _CELENGINE_JPLEPH_H_