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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
/***********************************************/
/**
* @file goceXml2Orbit.cpp
*
* @brief Read ESA XML GOCE Data.
*
* @author Torsten Mayer-Guerr
* @date 2010-10-19
*
*/
/***********************************************/
// Latex documentation
#define DOCSTRING docstring
static const char *docstring = R"(
Read ESA XML GOCE Data.
)";
/***********************************************/
#include "programs/program.h"
#include "parser/xml.h"
#include "files/fileInstrument.h"
#include "classes/earthRotation/earthRotation.h"
/***** CLASS ***********************************/
/** @brief Read ESA XML GOCE Data.
* @ingroup programsConversionGroup */
class GoceXml2Orbit
{
void readFileGoceOrbit(const FileName &fileName, OrbitArc &arc);
public:
void run(Config &config, Parallel::CommunicatorPtr comm);
};
GROOPS_REGISTER_PROGRAM(GoceXml2Orbit, SINGLEPROCESS, "read ESA XML GOCE Data", Conversion, Orbit, Instrument)
/***********************************************/
void GoceXml2Orbit::run(Config &config, Parallel::CommunicatorPtr /*comm*/)
{
try
{
FileName outName;
std::vector<FileName> fileName;
EarthRotationPtr earthRotation;
readConfig(config, "outputfileOrbit", outName, Config::MUSTSET, "", "");
readConfig(config, "earthRotation", earthRotation, Config::OPTIONAL, "file", "rotation from TRF to CRF");
readConfig(config, "inputfile", fileName, Config::MUSTSET, "", "");
if(isCreateSchema(config)) return;
logStatus<<"read input files"<<Log::endl;
OrbitArc orbit;
for(UInt i=0; i<fileName.size(); i++)
{
logStatus<<"read file <"<<fileName.at(i)<<">"<<Log::endl;
readFileGoceOrbit(fileName.at(i), orbit);
}
if(earthRotation)
{
logStatus<<"rotation from TRF to CRF"<<Log::endl;
Single::forEach(orbit.size(), [&](UInt i)
{
const Rotary3d rotation = inverse(earthRotation->rotaryMatrix(orbit.at(i).time));
const Vector3d omega = earthRotation->rotaryAxis(orbit.at(i).time);
orbit.at(i).position = rotation.rotate(orbit.at(i).position);
orbit.at(i).velocity = rotation.rotate(orbit.at(i).velocity) + crossProduct(omega, orbit.at(i).position);
});
}
logStatus<<"write orbit data to file <"<<outName<<">"<<Log::endl;
InstrumentFile::write(outName, orbit);
Arc::printStatistics(orbit);
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
/***********************************************/
void GoceXml2Orbit::readFileGoceOrbit(const FileName &fileName, OrbitArc &arc)
{
try
{
OrbitEpoch epoch;
InFile file(fileName);
XmlNodePtr rootNode = XmlNode::read(file);
XmlNodePtr sstNode = getChild(rootNode, "SST_PSO_2", TRUE);
sstNode = getChild(sstNode, "SST_PRD_2", TRUE);
sstNode = getChild(sstNode, "List_of_SP3c_Records", TRUE);
UInt epochCount = childCount(sstNode, "SP3c_Record", TRUE);
for(UInt i=0; i<epochCount; i++)
{
XmlNodePtr epochNode = getChild(sstNode, "SP3c_Record", TRUE);
UInt year, month, day, hour, min;
Double sec = 0;
XmlNodePtr timeNode = getChild(epochNode, "Time_Information", TRUE);
timeNode = getChild(timeNode, "GPS_Time", TRUE);
timeNode = getChild(timeNode, "Start", TRUE);
timeNode = getChild(timeNode, "Gregorian", TRUE);
readXml(timeNode, "Year", year, TRUE);
readXml(timeNode, "Month", month, TRUE);
readXml(timeNode, "Day_of_Month", day, TRUE);
readXml(timeNode, "Hour", hour, TRUE);
readXml(timeNode, "Minute", min, TRUE);
readXml(timeNode, "Second", sec, TRUE);
epoch.time = date2time(year, month, day, hour, min, sec);
XmlNodePtr satNode = getChild(getChild(epochNode, "List_of_Satellite_IDs", TRUE), "L15", TRUE);
XmlNodePtr posNode = getChild(satNode, "Position", TRUE);
readXml(posNode, "X", epoch.position.x(), TRUE);
readXml(posNode, "Y", epoch.position.y(), TRUE);
readXml(posNode, "Z", epoch.position.z(), TRUE);
epoch.position *= 1e3;
XmlNodePtr velNode = getChild(satNode, "Velocity", TRUE);
readXml(velNode, "X", epoch.velocity.x(), TRUE);
readXml(velNode, "Y", epoch.velocity.y(), TRUE);
readXml(velNode, "Z", epoch.velocity.z(), TRUE);
epoch.velocity *= 0.1;
arc.push_back(epoch);
}
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
// void GoceXml2Orbit::readFileGoceOrbit(const FileName &fileName, OrbitArc &arc)
// {
// try
// {
// OrbitEpoch epoch;
//
// XmlNodePtr rootNode = XmlNode::readFile(fileName);
// XmlNodePtr dataNode = getChild(rootNode, "Data_Block", TRUE);
// XmlNodePtr sstNode = getChild(dataNode, "SST_PVT_DS", TRUE);
//
// UInt epochCount = childCount(sstNode, "SST_PVT_1i", TRUE);
// for(UInt i=0; i<epochCount; i++)
// {
// XmlNodePtr epochNode = getChild(sstNode, "SST_PVT_1i", TRUE);
// Double t = 0;
// readXml(epochNode, "Tt_GPS", t, TRUE);
// epoch.time = seconds2time(t) + date2time(1980,1,6);
//
// XmlNodePtr posNode = getChild(epochNode, "SST_Pos", TRUE);
// std::string posStr;
// readXml(posNode, "Position", posStr, TRUE);
// std::stringstream ss(posStr);
// ss>>epoch.position.x()>>epoch.position.y()>>epoch.position.z();
//
// std::string velStr;
// readXml(epochNode, "SST_Vel", velStr, TRUE);
// std::stringstream ss2(velStr);
// ss2>>epoch.velocity.x()>>epoch.velocity.y()>>epoch.velocity.z();
//
// arc.push_back(epoch);
// }
// }
// catch(std::exception &e)
// {
// GROOPS_RETHROW(e)
// }
// }
/***********************************************/
|