Commit afd957f1 authored by Alexander Lapshin's avatar Alexander Lapshin

.

parent c2284a41
......@@ -141,4 +141,17 @@ bool OpticDelayMeasurement::PrepareDstFrame(const IFrame& fr)
return true;
}
bool OpticDelayMeasurement::PrepareDstFrame_gr(const IFrame& fr)
{
SetWrkFrame(J2000Frame());
if (!DetectRecieverPos(GetTime(), fr, RecPosFr)) {
return false;
}
RecPosFrInit = true;
return true;
}
///////////////////////////////////////////////////////////////////////////////
......@@ -13,8 +13,7 @@
#include "OpticMeasurement.h"
///////////////////////////////////////////////////////////////////////////////
class OpticDelayMeasurement : public OpticMeasurement
{
class OpticDelayMeasurement : public OpticMeasurement {
public:
// Конструктор по умолчанию
OpticDelayMeasurement();
......@@ -40,6 +39,7 @@ public:
};
bool PrepareDstFrame(const IFrame& fr);
bool PrepareDstFrame_gr(const IFrame& fr);
protected:
// Точность, с которой определяется время распространения сигнала
double TimePrec;
......
......@@ -10,6 +10,7 @@
#include "Consts.h"
#include "LocalJ2000Frame.h"
#include <iostream>
#include "GreenwichFrame.h"
///////////////////////////////////////////////////////////////////////////////
// Конструктор по умолчанию
......@@ -271,6 +272,78 @@ bool OpticMeasurement::Simulate(int matrixSize, ITraject& trj, TimeJD& t, const
return true;
}
//-----------------------------------------------------------------------------
// Метод осуществляет моделирование измерения для космического объекта,
// движение которого описывается с помощью переменной trj.
//-----------------------------------------------------------------------------
bool OpticMeasurement::Simulate_gr(int matrixSize, ITraject& trj, TimeJD& t, const IFrame& fr, Vect6* f, DVector* v, DMatrix* m, DVector* del) const
{
Vect6 pv;
if (f == 0 && (v != 0 || m != 0 || del != 0)) {
f = &pv;
}
//J2000Frame wrkfrm;
GreenwichFrame wrkfrm;
if (!DetectPosition(trj, t, (const IFrame *)&wrkfrm, f)) {
return false;
}
PhasePoint6D pp(wrkfrm, *f, t);
pp.Convert(fr);
*f = pp.CoordsVel;
if (v == 0 && m == 0 && del == 0) {
return true;
}
DVector ang(2);
Vect6 crd;
FrameConverter.Convert(*f, crd);
double r2 = crd.Len();
ang(1) = r2 > 0 ? asin(crd.z / r2) : 0.0;
ang(0) = (crd.x != 0 || crd.y != 0) ? atan2(crd.y, crd.x) : 0.0; // <-- [-PI,+PI]
ang(0) = Angle2Pi(ang(0));
if (v != 0) {
*v = ang;
}
if (del != 0) {
Diff(*del, NULL, &ang);
}
if (m != 0) {
double ra2 = crd.Len2();
double ras2 = crd.x * crd.x + crd.y * crd.y;
double ras = sqrt(ras2);
Vect3 dalfaa, ddeltaa, dalfaf, ddeltaf;
dalfaa[0] = -crd.y / ras2;
dalfaa[1] = crd.x / ras2;
dalfaa[2] = 0.0;
ddeltaa[0] = -crd.x * crd.z / (ras * ra2);
ddeltaa[1] = -crd.y * crd.z / (ras * ra2);
ddeltaa[2] = ras / ra2;
FrameConverter3D inv;
FrameConverter.Converter3D.Invert(inv);
dalfaf = dalfaa;
dalfaf.MulLeft(inv.Rotation);
ddeltaf = ddeltaa;
ddeltaf.MulLeft(inv.Rotation);
m->Init(2, matrixSize);
m->Init(0.0);
unsigned i;
for (i = 0; i < 3; i++) {
(*m)(0, i) = dalfaf[i];
(*m)(1, i) = ddeltaf[i];
}
}
return true;
}
//-----------------------------------------------------------------------------
// Вычисление невязок между измерениями
// Если m1 или m2 == NULL, принмается текущее измерение
......
......@@ -57,6 +57,7 @@ public:
// del - вектор невязок измеряемых параметров. Если этот параметр равен 0,
// вектор невязок не вычисляется
virtual bool Simulate(int matrixSize, ITraject& trj, TimeJD& t, const IFrame& fr, Vect6* f = 0, DVector* v = 0, DMatrix* m = 0, DVector* del = 0) const;
virtual bool Simulate_gr(int matrixSize, ITraject& trj, TimeJD& t, const IFrame& fr, Vect6* f = 0, DVector* v = 0, DMatrix* m = 0, DVector* del = 0) const;
virtual void Diff(DVector& d, const DVector* m1 = NULL, const DVector* m2 = NULL) const;
......
......@@ -95,6 +95,31 @@ static bool loadjson(const jsonval& parent, const std::string& key, std::vector<
return true;
}
static bool loadjson(const jsonval& parent, const std::string& key, std::vector<size_t>& vec, const bool exist = true, bool* loaded = nullptr)
{
jsonval::ConstMemberIterator itr;
if (!extract_value(parent, key, exist, loaded, itr)) {
return false;
}
const jsonval& a = itr->value;
if (!a.IsArray()) {
throw Exp() << "error: element is not an array";
}
for (jsonval::ConstValueIterator it = a.Begin(); it != a.End(); ++it) {
if (it->IsInt()) {
vec.push_back(it->GetInt());
}
else {
throw Exp() << "error: unsupported type";
}
}
return true;
}
static bool loadjson(const jsonval& parent, const std::string& key, std::vector<int>& vec, const bool exist = true, bool* loaded = nullptr)
{
jsonval::ConstMemberIterator itr;
......@@ -161,15 +186,15 @@ bool loadjson(const jsonval& parent, std::string key, std::vector<T>& vec, const
for (rapidjson::SizeType i = 0; i < a.Size(); i++) {
T item;
loadjson(a[i], item);
vec.push_back(item);
item.load(a[i]);
vec.emplace_back(item);
}
return true;
}
template <typename T, typename Tid>
bool loadjson(const jsonval& parent, std::string key, std::map<Tid, T>& map, const bool exist = true, bool* loaded = nullptr)
bool loadjson(const jsonval& parent, const std::string key, std::map<Tid, T>& map, const bool exist = true, bool* loaded = nullptr)
{
jsonval::ConstMemberIterator itr;
if (!extract_value(parent, key, exist, loaded, itr)) {
......@@ -184,7 +209,7 @@ bool loadjson(const jsonval& parent, std::string key, std::map<Tid, T>& map, con
for (rapidjson::SizeType i = 0; i < a.Size(); i++) {
T item;
loadjson(a[i], item);
item.load(a[i]);
map[item.getId()] = item;
}
......
......@@ -82,6 +82,10 @@ void Site::load(const jsonval& parent)
converter.Lam = sgc.GetLon();
converter.H = sgc.GetAlt();
converter.GetXYZ(m_coordinates);
m_lat_deg = sgc.GetLat()*rad2deg;
m_lon_deg = sgc.GetLon()*rad2deg;
m_alt_m = sgc.GetAlt()*1E6;
}
}
......
......@@ -19,12 +19,18 @@ public:
bool IsNeedAberrationCorrection() const { return m_needAberrationCorrection; }
double GetSigmaAlpha() const { return m_sigmaAlpha; }
double GetSigmaDelta() const { return m_sigmaDelta; }
double get_lat_deg() const { return m_lat_deg; }
double get_lon_deg() const { return m_lon_deg; }
double get_alt_m() const { return m_alt_m; }
private:
bool m_needAberrationCorrection;
double m_sigmaAlpha;
double m_sigmaDelta;
Vect3 m_coordinates;
TSiteId m_id;
double m_lat_deg;
double m_lon_deg;
double m_alt_m;
};
typedef std::vector<Site> Sites;
......
......@@ -3,22 +3,10 @@
#include "Converter.h"
#include "TM.h"
#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include "globals.h"
/*void IncJ(double& JD, double sec);
double MoveJ(double JD, double sec);
double LocalTimeToJ(int Cyear, int Cmonth, int Cday,int Chour,int Cminute,int Csecond, int Cms);
double LocalTimeToJTz(int Cyear, int Cmonth, int Cday,int Chour,int Cminute,int Csecond, int Cms, double tz);
double LocalTimeSTToJ(Time st);
double LocalTimeSTToJTz(Time st, double tz);
double SystemTimeToJ(int Cyear, int Cmonth, int Cday,double Chour,int Cminute,int Csecond, int Cms);
double TimeInterval(double J1, double J2);
void JToSystemTime(double J,int &Cyear,int &Cmonth,int &Cday,int& Chour,int& Cminute,int& Csecond,int& Cms);
std::string PrintFullTime(double J, double tz);
*/
#include "TextFunctions.h"
static void GetPrecK(int msprec, int& k1, int& k2)
{
......@@ -113,7 +101,7 @@ static int mthdays(int month, int year)
return days[leap][month];
}
static std::string DateToStr(int year, int month, int day, int hour, int minute, int second, double fraction, int prec)
static std::string DateToStr(int year, int month, int day, int hour, int minute, int second, double fraction, int prec, bool year_first = false)
{
int d = hour;
int m = minute;
......@@ -155,6 +143,7 @@ static std::string DateToStr(int year, int month, int day, int hour, int minute,
std::ostringstream ss;
if(!year_first) {
ss << std::setfill('0');
ss << std::setw(2) << day << "/";
ss << std::setw(2) << month << "/";
......@@ -162,6 +151,15 @@ static std::string DateToStr(int year, int month, int day, int hour, int minute,
ss << std::setw(2) << d << ":";
ss << std::setw(2) << m << ":";;
ss << std::setw(2) << s;
}else {
ss << std::setfill('0');
ss << std::setw(4) << year << "/";
ss << std::setw(2) << month << "/";
ss << std::setw(2) << day << " ";
ss << std::setw(2) << d << ":";
ss << std::setw(2) << m << ":";;
ss << std::setw(2) << s;
}
if (prec > 0) {
ss << ".";
......@@ -451,7 +449,7 @@ static TimeGD ToGD(double jd)
{
int Cyear, Cmonth, Cday, Chour, Cminute, Csecond, Cms;
JToSystemTime(jd, Cyear, Cmonth, Cday, Chour, Cminute, Csecond, Cms);
return TimeGD(Cday, Cmonth, Cyear, Chour, Cminute, Csecond, Cms / 1000.0);
return {Cday, Cmonth, Cyear, Chour, Cminute, Csecond, Cms / 1000.0};
}
static double date2jd(const std::string& date)
......@@ -468,3 +466,21 @@ static std::string jd2date(double jd, int prec = 3)
JToSystemTime(jd, year, month, day, hour, minute, second, ms);
return DateToStr(year, month, day, hour, minute, second, ms / 1000.0, prec);
}
static std::string calc_nightid(const TimeJD& date, const double lon_deg)
{
const double jd = date.GetDays() + date.GetFraction() + lon_deg / 15 / 24 - 0.5;
int year;
unsigned short int month;
unsigned short int day;
unsigned short int hour;
unsigned short int minutes;
unsigned short int seconds;
double fraction;
convertTimeJG((int)jd, jd - (int)jd, year, month, day, hour, minutes, seconds, fraction);
std::string str = DateToStr(year, month, day, hour, minutes, seconds, fraction, 3, true);
str = str.substr(0, 10);
string_replace(str, "/", "");
return str;
}
......@@ -3,17 +3,6 @@
#include "GreenwichFrame.h"
#include <algorithm>
template <bool dir, typename vartype>
struct cmppos : public std::binary_function<vartype, vartype, bool> {
bool operator()(vartype s1, vartype s2) const
{
const TimeJD& v1 = s1.get_date();
const TimeJD& v2 = s2.get_date();
return (v1 == v2) ? false : (v1 < v2) ^ dir;
}
};
static double get_step(const double period, const double ecc)
{
if (ecc < 0.1) {
......@@ -51,7 +40,12 @@ XInterpolator::XInterpolator(const SInitOrbit& orbit, const TimeJD& beg, const T
XInterpolator::XInterpolator(const std::vector<IRes>& vec)
{
create(vec);
std::vector<IRes> svec = vec;
std::sort(svec.begin(), svec.end(), [](const IRes& a, const IRes& b) {
return (a.get_date() < b.get_date());
});
create(svec);
}
void XInterpolator::propagate_dir(const SInitOrbit& orbit, const TimeJD& beg, const TimeJD& end, const int dir, std::vector<IRes>& result)
......@@ -161,39 +155,6 @@ void finalize(ei& ephi)
}
}
/*void Interpolator::filter_addons()
{
std::vector<IRes> filtered;
std::sort(m_positions.begin(), m_positions.end(), cmpfunc3<false, IRes>());
int first_real;
for (int it = 0; it < m_positions.size(); it++){
if(!m_positions[it].is_addon()){
first_real = it;
break;
}
filtered.push_back(m_positions[it]);
}
int last_real;
for (int it = m_positions.size() - 1; it >= 0; it--){
if(!m_positions[it].is_addon()){
last_real = it;
break;
}
filtered.push_back(m_positions[it]);
}
for (int it = first_real; it <= last_real; it++){
if(!m_positions[it].is_addon()){
filtered.push_back(m_positions[it]);
}
}
std::sort(filtered.begin(), filtered.end(), cmpfunc3<false, IRes>());
m_positions = filtered;
}*/
void XInterpolator::create(const SInitOrbit& orbit, const TimeJD& beg, const TimeJD& end)
{
std::vector<IRes> positions;
......@@ -210,13 +171,7 @@ void XInterpolator::create(const std::vector<IRes>& positions)
init(m_ephi, positions.size());
for (const auto& p : positions) {
Vect6 pos = p.get_pos();
TimeJD date = p.get_date();
PhasePoint6D itrf(static_cast<const IFrame&>(J2000Frame()), pos, date);
//itrf.Convert(GreenwichFrame());
//double jdi = date.GetDays();
//double jdf = date.GetFraction();
fill(itrf.CoordsVel, date.GetDays(), date.GetFraction(), m_ephi);
fill(p.get_pos(), p.get_date().GetDays(), p.get_date().GetFraction(), m_ephi);
}
finalize(m_ephi);
......
......@@ -4,7 +4,6 @@
#include "TM.h"
#include "ephi.h"
#include "DVectors.h"
#include "Propagator.h"
#include "ires.h"
class XInterpolator
......
#include "ires.h"
#include <utility>
#include "json_functions_bno.h"
IRes::IRes() = default;
IRes::IRes(const Vect6& vec, const TimeJD& date, const double age, std::string orbitid, const bool addon)
:
......@@ -10,3 +13,22 @@ IRes::IRes(const Vect6& vec, const TimeJD& date, const double age, std::string o
m_addon(addon)
{
}
void IRes::load(const jsonval& parent)
{
double x, y, z;
loadjson(parent, "x_km", x);
loadjson(parent, "y_km", y);
loadjson(parent, "z_km", z);
double vx = 0, vy = 0, vz = 0;
loadjson(parent, "vx_km/s", vx, false);
loadjson(parent, "vy_km/s", vy, false);
loadjson(parent, "vz_km/s", vz, false);
loadjson(parent, "date", m_date);
loadjson(parent, "orbitid", m_orbitid, false);
loadjson(parent, "age_days", m_age, false);
m_vec = Vect6(x / 1E3, y / 1E3, z / 1E3, vx, vy, vz);
}
......@@ -3,14 +3,13 @@
#include "DVectors.h"
#include "TM.h"
#include <string>
#include "json_functions.h"
class IRes
{
class IRes {
public:
IRes()
{
};
IRes();
IRes(const Vect6& vec, 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; }
bool is_addon() const { return m_addon; }
......
......@@ -3,8 +3,8 @@
#include "TextFunctions.h"
OrbBlock::OrbBlock()
:
m_ip(nullptr)
:
m_ip(nullptr)
{
}
......
......@@ -7,7 +7,7 @@
class OrbBlock {
public:
OrbBlock();;
OrbBlock();
OrbBlock(const SInitOrbit& orbit, const TimeJD& beg, const TimeJD& end);
OrbBlock(const SInitOrbit& orbit, const TimeJD& beg, const TimeJD& end, double mind, std::string next_orbitid);
~OrbBlock();
......
......@@ -15,10 +15,9 @@ public:
virtual void SetTime(const TimeJD& t)
{
};
virtual const TimeJD& GetTime() const { return m_dummy; };
}
virtual const TimeJD& GetTime() const { return TimeJD(); };
virtual IPredict* GetPredictor() { return 0; }
private:
const OrbBlocksStore& m_orbit_processor;
TimeJD m_dummy;
};
#include "trj_inter_x.h"
#include "GreenwichFrame.h"
TrjInterX::TrjInterX(const XInterpolator& itp)
: m_itp(itp)
{
}
bool TrjInterX::Predict(const TimeJD& t, const IFrame& fr, Vect6& f)
{
PhasePoint6D pp(GreenwichFrame(), m_itp.get_pos(t, true), t);
pp.Convert(fr);
f = pp.CoordsVel;
return true;
}
bool TrjInterX::PredictMatrix(const TimeJD& t, const IFrame& fr, Vect6& f, DMatrix& m)
{
return true;
}
bool TrjInterX::Move(const TimeJD& t, DVector& u)
{
return true;
}
bool TrjInterX::Init(const DVector& u0)
{
return true;
}
#pragma once
#include "ITraject.h"
#include "interpolate.h"
class TrjInterX : public ITraject {
public:
TrjInterX(const XInterpolator& itp);
virtual bool Predict(const TimeJD& t, const IFrame& fr, Vect6& f);
virtual bool PredictMatrix(const TimeJD& t, const IFrame& fr, Vect6& f, DMatrix& m);
virtual bool Move(const TimeJD& t, DVector& u);
virtual unsigned Size() const { return 6; }
virtual bool Init(const DVector& u0);
virtual void SetTime(const TimeJD& t)
{
}
virtual const TimeJD& GetTime() const { return TimeJD(); }
virtual IPredict* GetPredictor() { return 0; }
private:
const XInterpolator& m_itp;
};
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