8 #include "coordConv/physConst.h"
11 const float RadPerArcsec = coordConv::RadPerDeg / coordConv::ArcsecPerDeg;
13 #define MaxTermNameLen 9
18 int errCode = tcsMinit(&
_model);
21 }
else if (errCode == 1) {
22 throw std::runtime_error(
"Insufficient room for all terms");
24 throw std::runtime_error(
"Unknown error");
29 int retVal = tcsIntpm(filePath.c_str(), &
_model);
32 }
else if (retVal == -1) {
33 throw std::runtime_error(
"Unable to initialize model");
34 }
else if (retVal == -2) {
35 throw std::runtime_error(
"Unable to open input file");
36 }
else if (retVal == -3) {
37 throw std::runtime_error(
"I/O error or premature EOF");
38 }
else if (retVal == -4) {
39 throw std::runtime_error(
"Unrecognized record");
40 }
else if (retVal == -5) {
41 throw std::runtime_error(
"Unable to add term to model");
43 throw std::runtime_error(
"Unknown error");
47 std::string
const &termName,
51 throw std::runtime_error(
"Invalid term name: too long");
56 }
else if (retVal == -2) {
57 throw std::runtime_error(
"No room left in model");
58 }
else if (retVal == -1) {
59 throw std::runtime_error(
"Unrecognized term");
60 }
else if (retVal == 0) {
61 throw std::runtime_error(
"No room in repertoire for new generic term");
63 throw std::runtime_error(
"Unknown error");
67 for (
int i = 0; i < MAXTRM; ++i) {
76 std::vector<std::string> termNames;
77 for (
int i = 0; i < MAXTRM; ++i) {
78 int termInd =
_model.model[i] - 1;
79 if (termInd < 0)
break;
80 termNames.push_back(
_model.coeffn[termInd]);
86 std::string
const &termName
89 throw std::runtime_error(
"Invalid term name: too long");
93 int retVal = tcsQnatrm(
94 const_cast<char *>(termName.c_str()),
95 const_cast<TPMOD *>(&
_model),
100 throw std::runtime_error(
"Term not found in model");
106 std::string
const &termName,
113 }
else if (retVal == -1) {
114 throw std::runtime_error(
"Term not found in model");
116 throw std::runtime_error(
"Unknown error");
120 std::ostringstream os;
126 std::vector<std::string> termNames = telMod.
getTermNames();
128 std::ios_base::fmtflags f = os.flags(std::ios::right | std::ios::fixed | std::ios::showpos);
129 std::streamsize p = os.precision(4);
131 os <<
"# TelMod telescope pointing model" << std::endl;
132 os <<
"# (the first two lines are ignored)" << std::endl;
133 for (std::vector<std::string>::const_iterator nameIter = termNames.begin(); nameIter != termNames.end(); ++nameIter) {
134 double val = telMod.
getTerm(*nameIter);
135 os <<
" " << std::setw(9) << std::setiosflags(std::ios::right) << *nameIter
136 << std::setw(9) << val << std::setiosflags(std::ios::left) << std::endl;
138 os <<
"END" << std::endl;
void setTerm(std::string const &termName, double termValue)
double getTerm(std::string const &termName) const
std::ostream & operator<<(std::ostream &os, ChebyshevPolynomial const &cheby)
std::vector< std::string > getTermNames() const
int addTerm(std::string const &termName, double termValue)
void loadPath(std::string const &filePath)