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
|
/***********************************************/
/**
* @file planetOrbit.cpp
*
* @brief Orbits of sun, moon, and planets.
*
* @author Torsten Mayer-Guerr
* @date 2011-04-12
*
*/
/***********************************************/
// Latex documentation
#define DOCSTRING docstring
static const char *docstring = R"(
Creates an \file{orbit file}{instrument} of sun, moon, or planets.
The orbit is given in the celestial reference frame (CRF)
or alternatively in the terrestrial reference frame (TRF)
if \configClass{earthRotation}{earthRotationType} is provided.
)";
/***********************************************/
#include "programs/program.h"
#include "files/fileInstrument.h"
#include "classes/timeSeries/timeSeries.h"
#include "classes/earthRotation/earthRotation.h"
#include "classes/ephemerides/ephemerides.h"
/***** CLASS ***********************************/
/** @brief Orbits of sun, moon, and planets.
* @ingroup programsGroup */
class PlanetOrbit
{
public:
void run(Config &config, Parallel::CommunicatorPtr comm);
};
GROOPS_REGISTER_PROGRAM(PlanetOrbit, SINGLEPROCESS, "orbits of sun, moon and, planets", Orbit, Instrument)
/***********************************************/
void PlanetOrbit::run(Config &config, Parallel::CommunicatorPtr /*comm*/)
{
try
{
FileName fileNameOrbit;
TimeSeriesPtr timeSeries;
EarthRotationPtr earthRotation;
EphemeridesPtr ephemerides;
Ephemerides::Planet planet;
std::string choice;
readConfig(config, "outputfileOrbit", fileNameOrbit, Config::MUSTSET, "", "");
readConfig(config, "planet", planet, Config::MUSTSET, "", "");
readConfig(config, "timeSeries", timeSeries, Config::MUSTSET, "", "");
readConfig(config, "ephemerides", ephemerides, Config::MUSTSET, "", "");
readConfig(config, "earthRotation", earthRotation, Config::OPTIONAL, "", "transform orbits into TRF");
if(isCreateSchema(config)) return;
// =============================================
logStatus<<"computing"<<Log::endl;
std::vector<Time> times = timeSeries->times();
OrbitArc orbit;
Single::forEach(times.size(), [&](UInt i)
{
OrbitEpoch epoch;
epoch.time = times.at(i);
ephemerides->ephemeris(times.at(i), planet, epoch.position, epoch.velocity);
if(earthRotation)
{
const Rotary3d rotEarth = earthRotation->rotaryMatrix(times.at(i));
const Vector3d omega = earthRotation->rotaryAxis(times.at(i));
epoch.velocity = rotEarth.rotate(epoch.velocity - crossProduct(omega, epoch.position));
epoch.position = rotEarth.rotate(epoch.position);
}
orbit.push_back(epoch);
});
logStatus<<"write orbit data to file <"<<fileNameOrbit<<">"<<Log::endl;
InstrumentFile::write(fileNameOrbit, orbit);
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
/***********************************************/
|