Skip to content

Commit

Permalink
Added functions to update trace header NSamp and SampRate
Browse files Browse the repository at this point in the history
  • Loading branch information
kerim371 committed May 22, 2024
1 parent 3d2c09e commit e0504d2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/h5geo/h5seis.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ class H5Seis : public H5BaseObject
/// If you plan to get `CDP-DSREG` data, you have to call H5Seis::addPKeySort("CDP") first.
virtual bool addPKeySort(const std::string& pKeyName) = 0;

/// \brief Set trace header samp rate from binary header
virtual bool updateTraceHeaderSampRate() = 0;
/// \brief Set trace header number of samples from binary header
virtual bool updateTraceHeaderNSamp() = 0;

/// \brief Open H5SeisContainer where current seismic resides
virtual H5SeisContainer* openSeisContainer() = 0;

Expand Down
3 changes: 3 additions & 0 deletions include/h5geo/private/h5seisimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ class H5SeisImpl : public H5BaseObjectImpl<H5Seis>
virtual bool removePKeySort(const std::string& pKeyName) override;
virtual bool addPKeySort(const std::string& pKeyName) override;

virtual bool updateTraceHeaderSampRate() override;
virtual bool updateTraceHeaderNSamp() override;

virtual H5SeisContainer* openSeisContainer() override;

virtual std::optional<h5gt::DataSet> getTextHeaderD() override;
Expand Down
31 changes: 30 additions & 1 deletion src/h5geo/h5seisimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1596,8 +1596,11 @@ bool H5SeisImpl::generatePRESTKGeometry(
rec_z,
orientation,
moveRec);
if (status)
if (status){
this->updateTraceHeaderSampRate();
this->updateTraceHeaderNSamp();
this->updateTraceHeaderLimits();
}

return status;
}
Expand Down Expand Up @@ -1656,6 +1659,8 @@ bool H5SeisImpl::generateSTKGeometry(
this->writeTraceHeader(key, geom[key]);

this->setDataType(h5geo::SeisDataType::STACK);
this->updateTraceHeaderSampRate();
this->updateTraceHeaderNSamp();
this->updateTraceHeaderLimits();
return true;
}
Expand Down Expand Up @@ -1830,6 +1835,30 @@ bool H5SeisImpl::addPKeySort(const std::string& pKeyName){
return true;
}

bool H5SeisImpl::updateTraceHeaderSampRate(){
// set sampRate
double sampRate = std::abs(this->getSampRate());
h5geo::Domain domain = this->getDomain();
if (domain == h5geo::Domain::TWT ||
domain == h5geo::Domain::OWT){
double tmp = std::abs(this->getSampRate("microsecond"));
if (!std::isnan(tmp))
sampRate = tmp;
} else if (domain == h5geo::Domain::TVD ||
domain == h5geo::Domain::TVDSS) {
double tmp = std::abs(this->getSampRate("cm"));
if (!std::isnan(tmp))
sampRate = tmp;
}
Eigen::VectorXd v = Eigen::VectorXd::Ones(this->getNTrc())*sampRate;
return this->writeTraceHeader("SI", v, 0);
}

bool H5SeisImpl::updateTraceHeaderNSamp(){
Eigen::VectorXd v = Eigen::VectorXd::Ones(this->getNTrc())*this->getNSamp();
return this->writeTraceHeader("NSMP", v, 0);
}

H5SeisContainer* H5SeisImpl::openSeisContainer(){
h5gt::File file = getH5File();
return h5geo::createSeisContainer(
Expand Down

0 comments on commit e0504d2

Please sign in to comment.