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

◆ fixscalevalue()

void datrw::su::fixscalevalue ( short &  s,
const bool &  strict = true 
)

fix a SeismicUn*x scale value

fix a SeismicUn*x scale value

some code out there produces SU data with scale values understood as exponents of ten; SEGY defines the scale value to be taken as numerator or denominator of the scaling factor with values -10000, -1000, -100, -10, 1, 10, 100, 1000, 10000 only; here we allow for the non-standard setting indicated by the absolute value of scale being larger than 1 and smaller than 10

Parameters
sscale value to be fixed (input and output parameter)
strictif true: abort if scale does not match original definition

Definition at line 498 of file sucomanager.cc.

References DATRW_assert, DATRW_report_assert, and datrw::su::subformat::key::strict.

Referenced by outputmodifiers(), datrw::su::SUheader::read(), datrw::su::ScalCoo::ScalCoo(), scalefactor(), scaletopower(), datrw::su::ScalCoo::set(), and datrw::su::SUheader::setdefaults().

499  {
500  /*
501  * a scale value of 0 is not defined for the trace header in the SEGY
502  * standard; since Geode data acquisitions produce SEGY data with scalel
503  * set to 0, we have to deal with this value
504  */
505  DATRW_report_assert(s != 0,
506  "WARNING (ScalCoo::set): incorrect scale\n"
507  "The value for the scalco and scalel field\n"
508  "violates the SEG-Y trace header definition.\n"
509  "value: " << s << "; will be set to 1");
510  DATRW_assert(!((strict) && (s==0)),
511  "Violation of SeismicUn*x format definition!");
512  // make a copy to allow modification
513  if (s==0) { s=1; }
514  int sabs=s > 0 ? s : -s;
515  if ((sabs < 10) && (s != 1))
516  {
517  /*
518  * some code out there produces SU data with scale values understood
519  * as exponents of ten; SEGY defines the scale value to be taken as
520  * numerator or denominator of the scaling factor with values -10000,
521  * -1000, -100, -10, 1, 10, 100, 1000, 10000 only; here we allow for
522  * the non-standard setting indicated by the absolute value of scale
523  * being larger than 1 and smaller than 10
524  */
525  DATRW_report_assert(((sabs < 10) && (s != 1)),
526  "WARNING (ScalCoo::set): non-standard scale\n"
527  "The value for the scalco and scalel field\n"
528  "violates the SEG-Y trace header definition.\n"
529  "value: " << s);
531  "Violation of SeismicUn*x format definition!");
532  /*
533  * 10 to a power larger than 4 cannot be represented by a short int
534  */
535  DATRW_assert((sabs<5),
536  "ERROR (ScalCoo::set): "
537  "scale value does not fit in short int field");
538  s= s > 0 ? std::pow(10,sabs) : -std::pow(10,sabs);
539  }
540  } // void fixscalevalue(short& s, const bool& strict=true)
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:92
STL namespace.
const char *const strict
strictly interpret header as defined in SeismicUnix source
Definition: suformat.cc:65
#define DATRW_report_assert(C, M)
Check an assertion and report only.
Definition: error.h:120
Here is the caller graph for this function: