Lemma is an Electromagnetics API
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

datafem.cpp 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author M. Andy Kass
  8. @date 01/03/2013
  9. @version $Id$
  10. **/
  11. #include "datafem.h"
  12. namespace Lemma {
  13. std::ostream &operator<<(std::ostream &stream,
  14. const DataFEM &ob) {
  15. stream << *(Data*)(&ob);
  16. stream << "Number of Soundings: " << ob.nObs << std::endl;
  17. stream << "Number of Frequencies: " << ob.nFreq << std::endl;
  18. stream << std::setw(10) << "Number" << "\t"
  19. << std::setw(10) << "Frequency" << "\t"
  20. << std::setw(10) << "Tx Moment" << "\t"
  21. << std::setw(10) << "Tx Coil O." << "\t"
  22. << std::setw(10) << "Rx Coil O." << "\n";
  23. stream << std::setw(10) << " " << "\t"
  24. << std::setw(10) << "[Hz]" << "\t"
  25. << std::setw(10) << "[Am^2]" << "\t"
  26. << std::setw(10) << "[]" << "\t"
  27. << std::setw(10) << "[]" << "\n";
  28. for (int ii=0;ii<ob.nFreq;ii++) {
  29. stream << std::setw(10) << ii << "\t"
  30. << std::setw(10) << ob.freq(ii) << "\t"
  31. << std::setw(10) << ob.TxMom(ii) << "\t"
  32. << std::setw(10) << ob.TxOrientation(ii) << "\t"
  33. << std::setw(10) << ob.RxOrientation(ii) << "\n";
  34. }
  35. stream << " " << "\n";
  36. stream << std::setw(10) << "Number" << "\t"
  37. << std::setw(10) << "Coil Sep X" << "\t"
  38. << std::setw(10) << "Coil Sep Y" << "\t"
  39. << std::setw(10) << "Coil Sep Z" << "\t"
  40. << std::setw(10) << "Coil Scale" << "\n";
  41. stream << std::setw(10) << " " << "\t"
  42. << std::setw(10) << "[m]" << "\t"
  43. << std::setw(10) << "[m]" << "\t"
  44. << std::setw(10) << "[m]" << "\t"
  45. << std::setw(10) << "[]" << "\n";
  46. for (int ii=0;ii<ob.nFreq;ii++) {
  47. stream << std::setw(10) << ii << "\t"
  48. << std::setw(10) << ob.TxRxSep(0,ii) << "\t"
  49. << std::setw(10) << ob.TxRxSep(1,ii) << "\t"
  50. << std::setw(10) << ob.TxRxSep(2,ii) << "\t"
  51. << std::setw(10) << ob.ScaleFac(ii) << "\n";
  52. }
  53. return stream;
  54. }
  55. void DataFEM::Delete() {
  56. this->DetachFrom(this);
  57. }
  58. void DataFEM::Release() {
  59. if (this->NumberOfReferences != 0)
  60. throw DeleteObjectWithReferences(this);
  61. delete this;
  62. }
  63. DataFEM* DataFEM::New() {
  64. DataFEM* Obj = new DataFEM("DataFEM");
  65. Obj->AttachTo(Obj);
  66. return Obj;
  67. }
  68. DataFEM* DataFEM::Clone() {
  69. DataFEM* Obj = new DataFEM("DataFEM");
  70. Obj->AttachTo(Obj);
  71. //TODO Copy
  72. return Obj;
  73. }
  74. DataFEM::DataFEM(const std::string &name) : Data(name) {
  75. }
  76. DataFEM::~DataFEM() {
  77. }
  78. void DataFEM::Zero() {
  79. //TODO Zero out all the data members
  80. }
  81. Real DataFEM::Norm(Data* Data2) {
  82. return 0;
  83. //TODO Compute the norm
  84. }
  85. void DataFEM::SetSize(const int &nobs,const int &nfreq) {
  86. this->nObs = nobs;
  87. this->nFreq = nfreq;
  88. }
  89. void DataFEM::SetData(const MatrixXr &inputdata) {
  90. this->FEMDataCube = inputdata;
  91. }
  92. void DataFEM::SetUncertainties(const MatrixXr &uncertain) {
  93. this->FEMUncertainCube = uncertain;
  94. }
  95. void DataFEM::SetPositions(const Vector3Xr &positions) {
  96. this->xyz = positions;
  97. }
  98. void DataFEM::SetFreq(const VectorXr &freqs) {
  99. this->freq = freqs;
  100. }
  101. void DataFEM::SetTxOrientation(const Eigen::Matrix<ORIENTATION, Eigen::Dynamic, 1> &txorientation) {
  102. this->TxOrientation = txorientation;
  103. }
  104. void DataFEM::SetRxOrientation(const Eigen::Matrix<ORIENTATION, Eigen::Dynamic, 1> &rxorientation) {
  105. this->RxOrientation = rxorientation;
  106. }
  107. void DataFEM::SetTxMom(const VectorXr &txmom) {
  108. this->TxMom = txmom;
  109. }
  110. void DataFEM::SetTxRxSep(const Vector3Xr &txrxsep) {
  111. this->TxRxSep = txrxsep;
  112. }
  113. void DataFEM::SetScaleFac(const VectorXr &scalefac) {
  114. this->ScaleFac = scalefac;
  115. }
  116. int DataFEM::GetnFreq() {
  117. return this->nFreq;
  118. }
  119. int DataFEM::GetnObs() {
  120. return this->nObs;
  121. }
  122. MatrixXr DataFEM::GetFEMDataCube() {
  123. return this->FEMDataCube;
  124. }
  125. MatrixXr DataFEM::GetFEMUncertainCube() {
  126. return this->FEMUncertainCube;
  127. }
  128. Real DataFEM::GetDataCoeff(const int &x, const int &y) {
  129. return this->FEMDataCube.coeff(x,y);
  130. }
  131. VectorXr DataFEM::GetFreqs() {
  132. return this->freq;
  133. }
  134. Vector3Xr DataFEM::GetXYZ() {
  135. return this->xyz;
  136. }
  137. VectorXr DataFEM::GetSingleXYZ(const int &x) {
  138. return this->xyz.block(x,0,1,3);
  139. }
  140. Eigen::Matrix<ORIENTATION, Eigen::Dynamic, 1> DataFEM::GetTxOrien() {
  141. return this->TxOrientation;
  142. }
  143. Eigen::Matrix<ORIENTATION, Eigen::Dynamic, 1> DataFEM::GetRxOrien() {
  144. return this->RxOrientation;
  145. }
  146. VectorXr DataFEM::GetTxMom() {
  147. return this->TxMom;
  148. }
  149. Vector3Xr DataFEM::GetTxRxSep() {
  150. return this->TxRxSep;
  151. }
  152. VectorXr DataFEM::GetScaleFac() {
  153. return this->ScaleFac;
  154. }
  155. } // end of namespace Lemma