General Purpose Geodetic Library
SgModelEop_JMG_96_hf.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include <math.h>
24 
25 
26 #include <QtCore/QFile>
27 #include <QtCore/QStringList>
28 #include <QtCore/QTextStream>
29 
30 #include <SgModelEop_JMG_96_hf.h>
31 
32 #include <SgLogger.h>
33 #include <SgMatrix.h>
34 #include <SgVector.h>
35 
36 
37 
38 /*=======================================================================================================
39 *
40 * SgModelEop_JMG_96_hf's METHODS:
41 *
42 *======================================================================================================*/
43 //
44 // static first:
46 {
47  return "SgModelEop_JMG_96_hf";
48 };
49 
50 
51 
52 //
53 bool SgModelEop_JMG_96_hf::readFile(const QString& fileName)
54 {
55  QString str;
56  QFile f((fileName_=fileName));
57  bool isOk;
58  isOk_ = false;
59  if (!f.exists())
60  {
62  ": the file [" + fileName + "] with a priori data does not exist");
63  return false;
64  };
65  //
66  // clear the stuff:
67  numUt_ = 0;
68  numPm_ = 0;
69  if (baseModel_)
70  {
71  delete baseModel_;
72  baseModel_ = NULL;
73  };
74  utModel_ = NULL;
75  pmModel_ = NULL;
76  //
77  if (f.open(QFile::ReadOnly))
78  {
79  QTextStream s(&f);
80  int idx=0;
81  while (!s.atEnd())
82  {
83  str = s.readLine();
84  if (str.at(0)==' ')
85  {
86  if (numUt_*numPm_ == 0) // first non-comments string, determine number of arrays:
87  {
88  QStringList l = str.simplified().split(' ', QString::SkipEmptyParts);
89  if (l.size() != 2)
90  {
92  ": the file [" + fileName + "]: cannot guess numbers of arrays from the string: [" +
93  str + "]");
94  return false;
95  };
96  numUt_ = l.at(0).toInt(&isOk);
97  if (!isOk)
98  {
99  numUt_ = 0;
101  ": the file [" + fileName + "]: failed to get the array size for UT1, the string: [" +
102  str + "]");
103  return false;
104  };
105  numPm_ = l.at(1).toInt(&isOk);
106  if (!isOk)
107  {
108  numUt_ = 0;
109  numPm_ = 0;
111  ": the file [" + fileName + "]: failed to get the array size for PM, the string: [" +
112  str + "]");
113  return false;
114  };
115  // arrange some space for the data:
116  baseModel_ = new HfEopRec[numUt_ + numPm_];
120  ": the file [" + fileName + "]: allocated " + QString("").setNum(numUt_) +
121  " records for UT1 and " + QString("").setNum(numPm_) + " records for PM");
122  }
123  else
124  {
125  int n[6];
126  double a_c, a_s;
127  QStringList l = str.simplified().split(' ', QString::SkipEmptyParts);
128  if (l.size() != 10)
129  {
131  ": the file [" + fileName + "]: cannot guess format of the string: [" +
132  str + "]");
133  return false;
134  };
135  for (int i=0; i<6; i++)
136  {
137  n[i] = l.at(i).toInt(&isOk);
138  if (!isOk)
139  {
141  ": the file [" + fileName + "]: failed to acquire info (n_" + QString("").setNum(i) +
142  "), the string: [" + str + "]");
143  return false;
144  };
145  };
146  a_c = l.at(6).toDouble(&isOk);
147  if (!isOk)
148  {
150  ": the file [" + fileName + "]: failed to acquire info (a_c), the string: [" + str + "]");
151  return false;
152  };
153  a_s = l.at(7).toDouble(&isOk);
154  if (!isOk)
155  {
157  ": the file [" + fileName + "]: failed to acquire info (a_s), the string: [" + str + "]");
158  return false;
159  };
160  for (int i=0; i<6; i++)
161  baseModel_[idx].n_[i] = n[i];
162  baseModel_[idx].a_cos_ = a_c;
163  baseModel_[idx].a_sin_ = a_s;
164  idx++;
165  };
166  };
167  };
168  f.close();
169  s.setDevice(NULL);
170  };
171 
172  if (0<numUt_ && 0<numPm_)
173  isOk_ = true;
174 
175  return isOk_;
176 };
177 
178 
179 
180 //
181 // The model is from:
182 // Gipson, John M. (1996) Very long baseline interferometry determination of neglected tidal terms
183 // in high-frequency Earth orientation variation. Journal of Geophysical Research: Solid Earth, 101.
184 // 28051-28064 doi:10.1029/96jb02292
185 //
186 // note: input t is in TT timescale
187 void SgModelEop_JMG_96_hf::calcCorrections(const SgMJD& t, double& dUt1, double& dPx, double& dPy)
188 {
189  double fundArgs[6];
190  double arg, sarg, carg;
191  //
192  // zerofy values:
193  fundArgs[0] = fundArgs[1] = fundArgs[2] = fundArgs[3] = fundArgs[4] = fundArgs[5] = 0.0;
194  dUt1 = dPx = dPy = 0.0;
195 
196  if (!isOk_)
197  return;
198 
200  fundArgs[5] = t.gmst() + M_PI;
201  if (2.0*M_PI < fundArgs[5])
202  fundArgs[5] -= 2.0*M_PI;
203 
204  // Eq. (2) from the paper:
205  // dUT1:
206  for (int i=0; i<numUt_; i++)
207  {
208  arg = 0.0;
209  for (int j=0; j<6; j++)
210  arg += utModel_[i].n_[j]*fundArgs[j];
211  sincos(arg, &sarg, &carg);
212  dUt1 += utModel_[i].a_cos_*carg + utModel_[i].a_sin_*sarg;
213  };
214 
215  // Eq. (2) from the paper:
216  // polar motion:
217  for (int i=0; i<numPm_; i++)
218  {
219  arg = 0.0;
220  for (int j=0; j<6; j++)
221  arg += pmModel_[i].n_[j]*fundArgs[j];
222  sincos(arg, &sarg, &carg);
223  dPx += -pmModel_[i].a_cos_*carg + pmModel_[i].a_sin_*sarg;
224  dPy += pmModel_[i].a_cos_*sarg + pmModel_[i].a_sin_*carg;
225  };
226 };
227 /*=====================================================================================================*/
228 
229 
230 
231 
232 
233 /*=======================================================================================================
234 *
235 * FRIENDS:
236 *
237 *======================================================================================================*/
238 //
239 
240 
241 
242 /*=====================================================================================================*/
243 //
244 // aux functions:
245 //
246 
247 
248 // i/o:
249 
250 
251 /*=====================================================================================================*/
252 //
253 // constants:
254 //
255 /*=====================================================================================================*/
256 
257 
258 
259 
260 
261 
262 
263 
264 /*=====================================================================================================*/
SgLogger * logger
Definition: SgLogger.cpp:231
void calcNutationFundArgs_IersConv2003(const SgMJD &tEpoch, double args[5])
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ IO_TXT
Definition: SgLogger.h:65
Definition: SgMJD.h:59
double gmst() const
Definition: SgMJD.cpp:1264
bool readFile(const QString &)
void calcCorrections(const SgMJD &, double &dUt1, double &dPx, double &dPy)
static const QString className()