File: gnssProcessingStepForEachReceiverSeparately.h

package info (click to toggle)
groops 0%2Bgit20240830%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 11,052 kB
  • sloc: cpp: 134,939; fortran: 1,569; makefile: 20
file content (137 lines) | stat: -rw-r--r-- 5,571 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
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
/***********************************************/
/**
* @file gnssProcessingStepForEachReceiverSeparately.h
*
* @brief GNSS processing step: ForEachReceiverSeparately.
*
* @author Torsten Mayer-Guerr
* @date 2021-09-05
*
*/
/***********************************************/

#ifndef __GROOPS_GNSSPROCESSINGSTEPFOREACHRECEIVERSEPARATELY__
#define __GROOPS_GNSSPROCESSINGSTEPFOREACHRECEIVERSEPARATELY__

// Latex documentation
#ifdef DOCSTRING_GnssProcessingStep
static const char *docstringGnssProcessingStepForEachReceiverSeparately = R"(
\subsection{ForEachReceiverSeparately}\label{gnssProcessingStepType:forEachReceiverSeparately}
Perform these processing steps for each \configClass{selectReceivers}{platformSelectorType} separately.
All non-receiver related parameters parameters are disabled in these processing steps (see .

This step can be used for individual precise point positioning (PPP) of all stations.
During \reference{GNSS satellite orbit determination and network analysis}{cookbook.gnssNetwork:processing} this step is used after the
initial processing of the core network to process all other stations individually. In that case provide the same station list as
\configFile{inputfileExcludeStationList}{stringList} in this step that was used as \configFile{inputfileStationList}{stringList} in the
\configClass{selectReceivers}{gnssProcessingStepType:selectReceivers} step where the core network was selected.
)";
#endif

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

#include "config/config.h"
#include "classes/platformSelector/platformSelector.h"
#include "gnss/gnssProcessingStep/gnssProcessingStep.h"

/***** CLASS ***********************************/

/** @brief GNSS processing step: ForEachReceiverSeparately.
* @ingroup gnssProcessingStepGroup
* @see GnssProcessingStep */
class GnssProcessingStepForEachReceiverSeparately : public GnssProcessingStepBase
{
  PlatformSelectorPtr selectReceivers;
  std::string         variableReceiver;
  Config              configProcessingSteps;

public:
  GnssProcessingStepForEachReceiverSeparately(Config &config);
  void process(GnssProcessingStep::State &state) override;
  Bool expectInitializedParameters() const override {return FALSE;}
};

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

inline GnssProcessingStepForEachReceiverSeparately::GnssProcessingStepForEachReceiverSeparately(Config &config)
{
  try
  {
    GnssProcessingStepPtr processingSteps;

    readConfig(config, "selectReceivers",  selectReceivers,  Config::MUSTSET,  "",        "");
    readConfig(config, "variableReceiver", variableReceiver, Config::OPTIONAL, "station", "variable is set for each receiver");
    readConfigLater(config, "processingStep", processingSteps, configProcessingSteps, Config::MUSTSET, "", "steps are processed consecutively");
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

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

inline void GnssProcessingStepForEachReceiverSeparately::process(GnssProcessingStep::State &state)
{
  try
  {
    Parallel::barrier(state.normalEquationInfo.comm);
    logStatus<<"=== for each receiver separately ============================"<<Log::endl;
    auto estimateSingleReceiver = state.gnss->selectReceivers(selectReceivers);
    for(auto recv : state.gnss->receivers)
      if(!recv->useable())
        estimateSingleReceiver.at(recv->idRecv()) = FALSE;
    logInfo<<"  "<<std::count(estimateSingleReceiver.begin(), estimateSingleReceiver.end(), TRUE)<<" receivers selected"<<Log::endl;
    if(Parallel::size(state.normalEquationInfo.comm) > 1)
      logInfo<<"  Only results of a subset of stations are displayed in the following"<<Log::endl;

    // Save old state
    auto normalEquationInfoOld = state.normalEquationInfo;

    // self comm
    state.normalEquationInfo.comm = Parallel::createCommunicator({Parallel::myRank(state.normalEquationInfo.comm)}, state.normalEquationInfo.comm);
    state.normalEquationInfo.isEachReceiverSeparately = TRUE;

    for(UInt idRecv=0; idRecv<state.gnss->receivers.size(); idRecv++)
      if(estimateSingleReceiver.at(idRecv) && state.gnss->receivers.at(idRecv)->isMyRank())
      {
        logStatus<<"=== select single receiver ("<<state.gnss->receivers.at(idRecv)->name()<<") ==========================="<<Log::endl;
        VariableList varList;
        varList.setVariable(variableReceiver, state.gnss->receivers.at(idRecv)->name());

        std::fill(state.normalEquationInfo.estimateReceiver.begin(), state.normalEquationInfo.estimateReceiver.end(), FALSE);
        state.normalEquationInfo.estimateReceiver.at(idRecv) = TRUE;
        state.changedNormalEquationInfo = TRUE;

        try
        {
          GnssProcessingStepPtr processingSteps;
          configProcessingSteps.read(processingSteps, varList);
          processingSteps->process(state);
        }
        catch(std::exception &e)
        {
          logError<<state.gnss->receivers.at(idRecv)->name()<<": disabled due to exception in single receiver loop:"<<Log::endl;
          logError<<e.what()<<Log::endl;
          state.gnss->receivers.at(idRecv)->disable(e.what());
        }
      } // for(idRecv)

    // restore old state
    std::swap(state.normalEquationInfo, normalEquationInfoOld);
    state.changedNormalEquationInfo = TRUE;

    // synchronize transceivers
    state.gnss->synchronizeTransceivers(state.normalEquationInfo.comm);

    Parallel::barrier(state.normalEquationInfo.comm);
  }
  catch(std::exception &e)
  {
    GROOPS_RETHROW(e)
  }
}

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

#endif