mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
NRLib: Fixed missing precision in LAS file export
This commit is contained in:
parent
e8cf23b341
commit
38be5baca1
21
ThirdParty/NRLib/nrlib/well/laswell.cpp
vendored
21
ThirdParty/NRLib/nrlib/well/laswell.cpp
vendored
@ -450,6 +450,19 @@ void LasWell::AddLog(const std::string & name,
|
||||
}
|
||||
|
||||
|
||||
int calculatePrecision(double value)
|
||||
{
|
||||
double absVal = fabs(value);
|
||||
if (1e-16 < absVal && absVal < 1.0e3){
|
||||
int logVal = static_cast<int>(log(absVal));
|
||||
int numDigitsAfterPoint = abs(logVal - 6);
|
||||
return numDigitsAfterPoint;
|
||||
}
|
||||
else{
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
void LasWell::WriteToFile(const std::string & filename,
|
||||
const std::vector<std::string> & comment_header)
|
||||
{
|
||||
@ -518,13 +531,17 @@ void LasWell::WriteToFile(const std::string & filename,
|
||||
file.precision(3);
|
||||
for (size_t i = 0; i < logs[0]->size(); ++i) {
|
||||
for (size_t j = 0; j < logs.size(); ++j) {
|
||||
file << (*logs[j])[i] << " ";
|
||||
// Calculate a sensible precision. LAS does not support scientific notation
|
||||
double value = (*logs[j])[i];
|
||||
int numDigitsAfterPoint = calculatePrecision(value);
|
||||
|
||||
file.precision(numDigitsAfterPoint);
|
||||
file << value << " ";
|
||||
}
|
||||
file << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LasWell::WriteLasLine(std::ofstream & file,
|
||||
const std::string & mnemonic,
|
||||
const std::string & units,
|
||||
|
Loading…
Reference in New Issue
Block a user