53 #define DATRW_SUHEADER_CC_VERSION \ 54 "DATRW_SUHEADER_CC V1.7" 56 #include <datrwxx/suheader.h> 59 #include <datrwxx/sucomanager.h> 74 char *ipointer=
reinterpret_cast<char *
>(&
Mheader);
76 "ERROR (SUheader::read): reading SU header",
79 "some fields upon input:\n" 88 "some fields upon return:\n" 98 const char *ipointer=
reinterpret_cast<const char *
>(&
Mheader);
100 "ERROR (SUheader::write): writing SU header");
104 <<
"os.good() returns " << os.good());
112 : Mheadercontrol(hc), Mdebug(debug)
115 "hc.spatialsampling.scalco " 160 return (static_cast<double>(
Mheader.
dt)*factor);
170 "negative d1 value (header byte offset 180) is illegal");
173 float seismicdt=
static_cast<double>(
Mheader.
dt)*1.e-6;
174 float ultrasonicdt=
static_cast<double>(
Mheader.
dt)*1.e-9;
175 float seismicres=1.-(seismicdt/
Mheader.
d1);
176 float ultrasonicres=1.-(ultrasonicdt/
Mheader.
d1);
177 seismicres=seismicres<0 ? -seismicres : seismicres;
178 ultrasonicres=ultrasonicres<0 ? -ultrasonicres : ultrasonicres;
182 "d1 value (header byte offset 180) neither matches " 183 "seismic nor ultrasonic data");
217 libtime::TAbsoluteTime date=this->
dateofshot();
220 date += this->
delay();
222 date -= this->
delay();
254 return(libtime::double2time(factor
255 *static_cast<double>(this->
absdelrt())));
278 "ERROR (SUheader::srce): coordinate units not supported");
281 retval.cs=::sff::CS_cartesian;
295 "ERROR (SUheader::info): coordinate units not supported");
298 retval.cs=::sff::CS_cartesian;
312 "ERROR (SUheader::wid2): no seismic data");
315 retval.dt=this->
dt();
317 std::ostringstream oss;
322 retval.channel=oss.str();
323 retval.station=oss.str();
329 retval.auxid=oss.str();
340 " cx: " <<
srce.cx <<
341 " cy: " <<
srce.cy <<
344 "ERROR (SUheader::set SRCE): " 345 "can only handle cartesian cooridnates");
364 " cx: " <<
info.cx <<
365 " cy: " <<
info.cy <<
368 "ERROR (SUheader::set INFO): " 369 "can only handle cartesian cooridnates");
401 std::istringstream iss(
wid2.channel);
405 std::istringstream iss(
wid2.auxid);
420 Mheader.
sec=
static_cast<short>(date.second());
430 "ERROR SUheader::settimes: ",
434 "ERROR SUheader::settimes: ",
438 "ERROR SUheader::settimes: ",
439 "SRCE time: " <<
Msrcedate.timestring());
442 "ERROR SUheader::settimes: " 443 "function called at wrong instance");
446 bool ultrasonic=
false;
452 "received non-positive sampling interval");
454 double dtfactor=1.e6;
455 double scaleddt=nearbyint(dtfactor*this->
Mwid2dt);
463 scaleddt=nearbyint(dtfactor*this->Mwid2dt);
465 "SUheader::settimes",
466 "ultrasonic scaling is forced");
471 "SUheader::settimes",
472 "seismic scaling is forced");
477 if ((!ultrasonic) && scaleddt <1.)
481 scaleddt=nearbyint(dtfactor*this->Mwid2dt);
483 "SUheader::settimes",
484 "ultrasonic scaling because of dt " 485 << scaleddt <<
"ns value");
490 "SUheader::settimes",
491 "seismic scaling because of dt " 492 << scaleddt <<
"us value");
495 if (scaleddt > USHRT_MAX)
497 std::cerr <<
"received sampling interval: " << scaleddt;
506 std::cerr << std::endl;
509 "ERROR (SUheader::set): " 510 "sampling interval cannot be represented by " 511 "a field of type unsigend short");
512 Mheader.
dt=
static_cast<unsigned short>(scaleddt);
524 double delfactor=1.e3;
525 if (ultrasonic) { delfactor=1.e6; }
526 double delvalue=std::floor(delfactor*libtime::time2double(del));
528 DATRW_assert(((delvalue >= SHRT_MIN) && (delvalue <= SHRT_MAX)),
529 "ERROR (SUheader::set): " 530 "trigger delay cannot be represented by " 531 "a field of type short.");
551 "The library uses only few header fields. Upon reading the\n" 552 "following fields are used:\n";
554 "wid2.nsamples = header.ns\n" 555 "wid2.dt = header.dt*1.e-6\n" 556 "wid2.date = srce.date+header.delrt*1.e-3\n" 557 "wid2.channel = header.tracf\n" 558 " (tracf = Trace number within original field record)\n" 559 "wid2.station = header.tracf\n" 560 "wid2.auxid = header.fldr\n" 561 " (fldr = Original field record number)\n";
563 "info.cx = header.gx*scalcof\n" 564 "info.cy = header.gy*scalcof\n" 565 "info.cz = header.gelev*scalelf\n" 566 "info.nstacks = header.nvs\n";
568 "srce.cx = header.sx*scalcof\n" 569 "srce.cy = header.sy*scalcof\n" 570 "srce.cz = header.sdepth*scalelf\n" 571 "srce.date = date(year,day,hour,minute,sec)\n";
573 "header.scalco and header.scalel are as defined for the SEG-Y " 575 "http://www.seg.org/SEGportalWEBproject/prod/SEG-Publications/Pub-Technical-Standards/Documents/seg_y_rev1.pdf\n" 576 "except when their modulus is smaller than 10 and larger than 0.\n" 577 "In this case the scaling factors scalcof and scalelf are taken to be\n" 578 "10 to the power of header.scalco or header.scalel, respectively\n";
580 "Notice that in contrast to the definition of the SeismicUn*x format\n" 581 "this library also supports high frequency sampling for ultrasonic\n" 582 "data. A special meaning of header fields was defined within the TOAST\n" 585 "Small sampling interval (smaller than 1 microsecond) as used in\n" 586 "ultrasonic recordings are to be stored in SeismicUn*x data format\n" 587 "within TOAST as follows:\n";
589 "1. Time values for ultrasonic data will be given in nanoseconds for\n" 590 " dt and microseconds for delrt.\n" 591 "2. This applies to fields\n" 592 " a) dt (byte# 117-118): sample interval\n" 593 " b) delrt (byte# 109-110): delay recording time\n";
595 "3. Time units other than microseconds or nanoseconds for dt and\n" 596 " milliseconds or microseconds for delrt are not allowed.\n" 597 "4. Field d1 (byte# 181-184) in TOAST data will be\n" 598 " a) either zero, indicating standard seismic data with a\n" 599 " micro seconds time scale or\n" 600 " b) provide the sampling interval in seconds, thus indicating\n" 601 " i) either standard seismic data, if d1 in seconds matches\n" 602 " dt if the latter is taken in microseconds or\n" 603 " ii) ultrasonic data, if d1 in seconds matches dt if the\n" 604 " latter is taken in nanoseconds and delrt is taken\n" 605 " in microseconds\n";
607 "This way it is possible to use SU tools to sort traces or similar\n" 608 "or even waveform filters. The user just has to take care to pass\n" 609 "filter frequencies in kHz rather than Hz in the case of ultrasonic\n"
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
macro function for debugging output (prototypes)
full set of coordinates.This struct holds a full set of coordinates for a SEG-Y trace header...
bool forceultrasonic
force ultrasonic headers
ScalCoo gy
receiver y coordinate
bool bestrict
if true: strictly use header definition by SeismicUnix source
ScalCoo sx
source x coordinate
short scalco
preferred scalco value
#define DATRW_Xassert(C, M, E)
Check an assertion and report by throwing an exception.
exception class declaration for libdatrwxx (prototypes)
ScalCoo gx
receiver x coordinate
Root namespace of library.
ScalCoo gelev
source y coordinate
ScalCoo sdepth
source z coordinate
#define DATRW_debug(C, N, M)
produce debug output
ScalCoo sy
source y coordinate
#define DATRW_value(V)
report value
void set(const short &s, const int &c)
set from header fields
void fixscalevalue(short &s, const bool &strict)
fix a SeismicUn*x scale value
void setvaluesin(TraceHeaderStruct &h)
set values in SU header
void getvaluesfrom(const TraceHeaderStruct &h)
read values from SU header
bool forceseismic
force seismic headers
double scalefactor(short s, const bool &strict)
convert scale value to a factor to be applied