Commit 038eaefb authored by Alexander Lapshin's avatar Alexander Lapshin

+ rnb interpolation

parent c349d077
#include "interpolate.h"
#include "Propagator.h"
#include "GreenwichFrame.h"
#include <algorithm>
static double get_step(const double period, const double ecc)
......@@ -38,17 +37,13 @@ XInterpolator::XInterpolator(const SInitOrbit& orbit, const TimeJD& beg, const T
create(orbit, beg, end, calc_rnb);
}
XInterpolator::XInterpolator(
const std::vector<IRes>& vec,
const std::vector<std::tuple<double, double, double>>& rnb
)
XInterpolator::XInterpolator(std::vector<IRes> xyz)
{
std::vector<IRes> svec = vec;
std::sort(svec.begin(), svec.end(), [](const IRes& a, const IRes& b) {
return (a.get_date() < b.get_date());
std::sort(xyz.begin(), xyz.end(), [](const IRes& a, const IRes& b) {
return a.get_date() < b.get_date();
});
create(svec, rnb);
create(xyz);
}
void XInterpolator::propagate_dir(
......@@ -57,8 +52,7 @@ void XInterpolator::propagate_dir(
const TimeJD& end,
const int dir,
const bool calc_rnb,
std::vector<IRes>& xyz,
std::vector<std::tuple<double, double, double>>& rnb
std::vector<IRes>& xyz
)
{
const bool variates = orbit.GetCovMtx().HasMtx() && orbit.GetMotionModel().GetType() == ST_PROP && calc_rnb;
......@@ -84,10 +78,13 @@ void XInterpolator::propagate_dir(
else {
SInitOrbit norb;
prop.Propagate(date, norb);
xyz.emplace_back(norb.GetPhasePointJ2000().CoordsVel, date, age, orbit.GetId());
std::map<std::string, double> covrnb = norb.GetCovMtx().GetCovRnbMap(norb.GetPhasePointJ2000().CoordsVel);
rnb.emplace_back(covrnb["RR"], covrnb["NN"], covrnb["BB"]);
xyz.emplace_back(
norb.GetPhasePointJ2000().CoordsVel,
Vect3(covrnb["RR"], covrnb["NN"], covrnb["BB"]),
date,
age,
orbit.GetId());
}
date = ShiftDate(date, dir * step);
......@@ -100,16 +97,15 @@ void XInterpolator::propagate(
const TimeJD& end,
const int dir,
const bool calc_rnb,
std::vector<IRes>& xyz,
std::vector<std::tuple<double, double, double>>& rnb
std::vector<IRes>& xyz
)
{
if (dir != 0) {
propagate_dir(orbit, beg, end, dir, calc_rnb, xyz, rnb);
propagate_dir(orbit, beg, end, dir, calc_rnb, xyz);
}
else {
propagate_dir(orbit, ShiftDate(orbit.GetDate(), +get_step(orbit) / 2.0), end, +1, calc_rnb, xyz, rnb);
propagate_dir(orbit, ShiftDate(orbit.GetDate(), -get_step(orbit) / 2.0), beg, -1, calc_rnb, xyz, rnb);
propagate_dir(orbit, ShiftDate(orbit.GetDate(), +get_step(orbit) / 2.0), end, +1, calc_rnb, xyz);
propagate_dir(orbit, ShiftDate(orbit.GetDate(), -get_step(orbit) / 2.0), beg, -1, calc_rnb, xyz);
}
std::sort(xyz.begin(), xyz.end(), [](const IRes& a, const IRes& b) {
......@@ -122,8 +118,8 @@ void XInterpolator::calc_positions(
const TimeJD& beg,
const TimeJD& end,
const bool calc_rnb,
std::vector<IRes>& xyz,
std::vector<std::tuple<double, double, double>>& rnb)
std::vector<IRes>& xyz
)
{
const int n = 100;
const int step = get_step(orbit);
......@@ -132,13 +128,13 @@ void XInterpolator::calc_positions(
const TimeJD end_ext = ShiftDate(end, +n * step);
if (orbit.GetDate() <= beg_ext) {
propagate(orbit, beg_ext, end_ext, 1, calc_rnb, xyz, rnb);
propagate(orbit, beg_ext, end_ext, 1, calc_rnb, xyz);
}
else if (orbit.GetDate() >= end_ext) {
propagate(orbit, end_ext, beg_ext, -1, calc_rnb, xyz, rnb);
propagate(orbit, end_ext, beg_ext, -1, calc_rnb, xyz);
}
else {
propagate(orbit, beg_ext, end_ext, 0, calc_rnb, xyz, rnb);
propagate(orbit, beg_ext, end_ext, 0, calc_rnb, xyz);
}
}
......@@ -193,15 +189,11 @@ void finalize(ei& ephi)
void XInterpolator::create(const SInitOrbit& orbit, const TimeJD& beg, const TimeJD& end, const bool calc_rnb)
{
std::vector<IRes> xyz;
std::vector<std::tuple<double, double, double>> rnb;
calc_positions(orbit, beg, end, calc_rnb, xyz, rnb);
create(xyz, rnb);
calc_positions(orbit, beg, end, calc_rnb, xyz);
create(xyz);
}
void XInterpolator::create(
const std::vector<IRes>& xyz,
const std::vector<std::tuple<double, double, double>>& rnb)
void XInterpolator::create(const std::vector<IRes>& xyz)
{
m_beg = xyz.front().get_date();
m_end = xyz.back().get_date();
......@@ -215,25 +207,14 @@ void XInterpolator::create(
finalize(m_ephi);
m_positions = xyz;
if(!rnb.empty()) {
init(m_rnb_ephi, rnb.size());
for(int i=0; i < static_cast<int>(rnb.size()); i++){
const auto& xyz_p = xyz[i];
const auto& rnb_p = rnb[i];
const Vect6 v(
std::get<0>(rnb_p),
std::get<1>(rnb_p),
std::get<2>(rnb_p),
0,
0,
0
);
fill(v, xyz_p.get_date().GetDays(), xyz_p.get_date().GetFraction(), m_rnb_ephi);
if (!xyz.empty() && xyz.front().has_rnb()) {
init(m_rnb_ephi, xyz.size());
for (const auto& p : xyz) {
fill(Vect6(p.get_rnb(), Vect3()), p.get_date().GetDays(), p.get_date().GetFraction(), m_rnb_ephi);
}
finalize(m_rnb_ephi);
m_rnb = rnb;
}
}
......
......@@ -11,9 +11,7 @@ class XInterpolator
public:
XInterpolator();
XInterpolator(const SInitOrbit& orbit, const TimeJD& beg, const TimeJD& end, bool calc_rnb);
XInterpolator(
const std::vector<IRes>& vec,
const std::vector<std::tuple<double, double, double>>& rnb);
XInterpolator(std::vector<IRes> xyz);
Vect6 get_pos(const TimeJD& date, bool tks = false) const;
TimeJD get_beg() const { return m_beg; }
TimeJD get_end() const { return m_end; }
......@@ -22,32 +20,26 @@ public:
const TimeJD& beg,
const TimeJD& end,
bool calc_rnb,
std::vector<IRes>& xyz,
std::vector<std::tuple<double, double, double>>& rnb);
std::vector<IRes>& xyz);
void export_data() const;
std::vector<IRes> m_positions;
std::vector<std::tuple<double, double, double>> m_rnb;
private:
void create(const SInitOrbit& orbit, const TimeJD& beg, const TimeJD& end, bool calc_rnb);
void create(
const std::vector<IRes>& xyz,
const std::vector<std::tuple<double, double, double>>& rnb);
void create(const std::vector<IRes>& xyz);
static void propagate(
const SInitOrbit& orbit,
const TimeJD& beg,
const TimeJD& end,
int dir,
const bool calc_rnb,
std::vector<IRes>& xyz,
std::vector<std::tuple<double, double, double>>& rnb);
bool calc_rnb,
std::vector<IRes>& xyz);
static void propagate_dir(
const SInitOrbit& orbit,
const TimeJD& beg,
const TimeJD& end,
const int dir,
bool calc_rnb,
std::vector<IRes>& xyz,
std::vector<std::tuple<double, double, double>>& rnb);
std::vector<IRes>& xyz);
TimeJD m_beg;
TimeJD m_end;
ei m_ephi;
......
......@@ -14,6 +14,18 @@ IRes::IRes(const Vect6& vec, const TimeJD& date, const double age, std::string o
{
}
IRes::IRes(const Vect6& vec, const Vect3& rnb, const TimeJD& date, double age, std::string orbitid, bool addon)
:
m_orbitid(std::move(orbitid)),
m_vec(vec),
m_rnb(rnb),
m_date(date),
m_age(age),
m_addon(addon),
m_has_rnb(true)
{
}
void IRes::load(const jsonval& parent)
{
double x, y, z;
......
......@@ -5,19 +5,25 @@
#include <string>
#include "json_functions.h"
class IRes {
class IRes
{
public:
IRes();
IRes(const Vect6& vec, const TimeJD& date, double age, std::string orbitid, bool addon = false);
IRes(const Vect6& vec, const Vect3& rnb, const TimeJD& date, double age, std::string orbitid, bool addon = false);
void load(const jsonval& parent);
TimeJD get_date() const { return m_date; }
Vect6 get_pos() const { return m_vec; }
const Vect6& get_pos() const { return m_vec; }
const Vect3& get_rnb() const { return m_rnb; }
bool is_addon() const { return m_addon; }
double get_age() const { return m_age; }
bool has_rnb() const { return m_has_rnb; }
private:
std::string m_orbitid;
Vect6 m_vec;
Vect3 m_rnb;
TimeJD m_date;
double m_age;
bool m_addon;
bool m_has_rnb{false};
};
......@@ -60,7 +60,7 @@ void OrbBlock::init_by_orbit(const bool calc_rnb)
void OrbBlock::init_by_data()
{
m_ip = new XInterpolator(m_data.get_vecs(), m_data.get_rnb());
m_ip = new XInterpolator(m_data.get_vecs());
}
void OrbBlock::load(const jsonval& parent)
......
......@@ -37,7 +37,6 @@ public:
const std::string& get_next_orbitid() const { return m_next_orbitid; }
double get_min_distance() const { return m_mind; }
const std::vector<IRes>& get_vecs() const { return m_vecs; }
const std::vector<std::tuple<double, double, double>>& get_rnb() const { return m_rnb; }
private:
std::string m_orbitid;
std::string m_next_orbitid;
......@@ -46,5 +45,4 @@ private:
TimeJD m_end;
double m_mind;
std::vector<IRes> m_vecs;
std::vector<std::tuple<double, double, double>> m_rnb;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment