DATRW++ library: seismic data I/O with multiple formats

◆ scaletopower()

void datrw::su::ScalCoo::scaletopower ( const int &  p)

scale to given scaling factor as defined by decimal power

Definition at line 238 of file sucomanager.cc.

References coo, DATRW_assert, DATRW_report_assert, power(), datrw::su::powertoscale(), and scale.

Referenced by datrw::su::Coordinates::equalizescaling(), and set().

239  {
240  int pd=this->power()-p;
241  int vnew, vcmp;
242  if (pd<0)
243  {
244  int fac=std::pow(10,-pd);
245  vnew=static_cast<int>(std::floor(this->coo/fac));
246  vcmp=static_cast<int>(std::floor(vnew*fac));
247  }
248  else
249  {
250  int fac=std::pow(10,pd);
251  vnew=std::floor(this->coo*fac);
252  vcmp=static_cast<int>(std::floor(vnew/fac));
253  }
254  DATRW_report_assert(vcmp==this->coo,
255  "WARNING ScalCoo::scaletopower will truncate "
256  "coordinate value\n"
257  "value was "
258  << helper::MyOutputFormat() << this->coo <<
259  " value will be " << vcmp);
260  this->coo = vnew;
261  this->scale=powertoscale(p);
262  DATRW_assert(this-scale != 0,
263  "ERROR (ScalCoo::scaletopower): illegal scale value!");
264  } // void ScalCoo::scaletopower(const int& p)
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:92
int coo
coordinate
Definition: sucomanager.h:171
short scale
scale like scalco
Definition: sucomanager.h:169
short powertoscale(const int &p)
convert a decimal power to a SeismicUn*x scale value
Definition: sucomanager.cc:474
int power() const
return decimal power of scaling factor
Definition: sucomanager.cc:230
#define DATRW_report_assert(C, M)
Check an assertion and report only.
Definition: error.h:120
Here is the call graph for this function:
Here is the caller graph for this function: