File: localLevelFrame2StarCamera.cpp

package info (click to toggle)
groops 0%2Bgit20250907%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 11,140 kB
  • sloc: cpp: 135,607; fortran: 1,603; makefile: 20
file content (89 lines) | stat: -rw-r--r-- 3,456 bytes parent folder | download | duplicates (2)
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
/***********************************************/
/**
* @file localLevelFrame2StarCamera.cpp
*
* @brief Compute rotation matrix from local level frame (north, east, down) to TRF and save as StarCamera file.
*
* @author Sebastian Strasser
* @date 2017-06-28
*/
/***********************************************/

// Latex documentation
#define DOCSTRING docstring
static const char *docstring = R"(
Compute rotation (\file{StarCamera file}{instrument}) from local level frame (ellipsoidal north, east, down)
to TRF for positions given in \configFile{inputfileInstrument}{instrument} (first 3 data columns).
)";

/***********************************************/

#include "programs/program.h"
#include "files/fileInstrument.h"

/***********************************************/

/** @brief Rotation from local level frame (ellipsoidal north, east, down) to TRF.
* @ingroup programsGroup */
class LocalLevelFrame2StarCamera
{
public:
  void run(Config &config, Parallel::CommunicatorPtr comm);
};

GROOPS_REGISTER_PROGRAM(LocalLevelFrame2StarCamera, PARALLEL, "Rotation from local level frame (ellipsoidal north, east, down) to TRF.", Instrument, Simulation)
GROOPS_RENAMED_PROGRAM(SimulateLocalLevelFrame, LocalLevelFrame2StarCamera, date2time(2018, 7, 4))

/***********************************************/

void LocalLevelFrame2StarCamera::run(Config &config, Parallel::CommunicatorPtr comm)
{
  try
  {
    Double a, f;
    FileName fileNameStarCamera;
    FileName fileNameInstrument;
    Bool constantOrigin;

    readConfig(config, "outputfileStarCamera", fileNameStarCamera, Config::MUSTSET,  "",  "rotation matrix from local level frame (ellipsoidal north, east, down) to TRF");
    readConfig(config, "inputfileInstrument",  fileNameInstrument, Config::MUSTSET,  "",  "origin of local level frame");
    readConfig(config, "constantOriginPerArc", constantOrigin,     Config::DEFAULT,  "0", "use constant origin for all epochs of an arc (median position)");
    readConfig(config, "R",                    a,                  Config::DEFAULT,  STRING_DEFAULT_GRS80_a, "reference radius for ellipsoidal coordinates");
    readConfig(config, "inverseFlattening",    f,                  Config::DEFAULT,  STRING_DEFAULT_GRS80_f, "reference flattening for ellipsoidal coordinates, 0: spherical coordinates");
    if(isCreateSchema(config)) return;

    logStatus<<"compute local level frame rotation"<<Log::endl;
    Ellipsoid ellipsoid(a, f);
    InstrumentFile epochFile(fileNameInstrument);
    std::vector<Arc> arcList(epochFile.arcCount());
    Parallel::forEach(arcList, [&](UInt arcNo)
    {
      Arc      arc = epochFile.readArc(arcNo);
      Matrix   A   = arc.matrix();
      Vector3d origin(median(A.column(1)), median(A.column(2)), median(A.column(3)));

      StarCameraArc scaArc;
      for(UInt k=0; k<A.rows(); k++)
      {
        // Local (north, east, down) -> global TRF
        StarCameraEpoch epoch;
        epoch.time   = arc.at(k).time;
        epoch.rotary = localNorthEastDown((constantOrigin ? origin : Vector3d(A.slice(k,1,1,3))), ellipsoid);
        scaArc.push_back(epoch);
      }
      return scaArc;
    }, comm);

    if(Parallel::isMaster(comm))
    {
      logStatus<<"write star camera data to file <"<<fileNameStarCamera<<">"<<Log::endl;
      InstrumentFile::write(fileNameStarCamera, arcList);
    }
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

/***********************************************/