Commit 1db595f2 authored by Morten Ofstad's avatar Morten Ofstad
Browse files

Merge branch feature/morten.ofstad/CheckForExcessOfEmptyTraces with...

Merge branch feature/morten.ofstad/CheckForExcessOfEmptyTraces with refs/heads/master into refs/merge-requests/77/train
parents 0ed94d07 3ae08624
Pipeline #901 passed with stages
in 8 minutes and 19 seconds
......@@ -292,10 +292,8 @@ HeaderFieldFromJson(Json::Value const& jsonHeaderField)
}
bool
ParseHeaderFormatFile(OpenVDS::File const& file, std::map<std::string, SEGY::HeaderField>& traceHeaderFields, SEGY::Endianness& headerEndianness)
ParseHeaderFormatFile(OpenVDS::File const& file, std::map<std::string, SEGY::HeaderField>& traceHeaderFields, SEGY::Endianness& headerEndianness, OpenVDS::Error &error)
{
OpenVDS::Error error;
int64_t fileSize = file.Size(error);
if (error.code != 0)
......@@ -359,7 +357,8 @@ ParseHeaderFormatFile(OpenVDS::File const& file, std::map<std::string, SEGY::Hea
}
catch (Json::Exception e)
{
std::cerr << "Failed to parse JSON header format file: " << e.what();
error.code = -1;
error.string = e.what();
return false;
}
......@@ -947,6 +946,7 @@ main(int argc, char* argv[])
std::string fileInfoFileName;
int brickSize;
bool force = false;
bool ignoreWarnings = false;
std::string bucket;
std::string sourceBucket;
std::string region;
......@@ -970,6 +970,7 @@ main(int argc, char* argv[])
options.add_option("", "i", "file-info", "A JSON file (generated by the --scan option) containing information about the input SEG-Y file.", cxxopts::value<std::string>(fileInfoFileName), "<file>");
options.add_option("", "b", "brick-size", "The brick size for the volume data store.", cxxopts::value<int>(brickSize)->default_value("64"), "<value>");
options.add_option("", "f", "force", "Continue on upload error.", cxxopts::value<bool>(force), "");
options.add_option("", "", "ignore-warnings", "Ignore warnings about import parameters.", cxxopts::value<bool>(ignoreWarnings), "");
options.add_option("", "", "bucket", "AWS S3 bucket to upload to.", cxxopts::value<std::string>(bucket), "<string>");
options.add_option("", "", "source-bucket", "AWS S3 bucket to download from.", cxxopts::value<std::string>(sourceBucket), "<string>");
options.add_option("", "", "region", "AWS region of bucket to upload to.", cxxopts::value<std::string>(region), "<string>");
......@@ -1051,7 +1052,13 @@ main(int argc, char* argv[])
return EXIT_FAILURE;
}
ParseHeaderFormatFile(headerFormatFile, g_traceHeaderFields, headerEndianness);
ParseHeaderFormatFile(headerFormatFile, g_traceHeaderFields, headerEndianness, error);
if (error.code != 0)
{
fmt::print(stderr, "Could not read header format file {}: {}\n", headerFormatFileName, error.string);
return EXIT_FAILURE;
}
}
// get the canonical field name for the primary and secondary key
......@@ -1194,18 +1201,6 @@ main(int argc, char* argv[])
persistentID = fmt::format("{:X}", fileInfo.m_persistentID);
}
// Determine value range
OpenVDS::FloatRange
valueRange;
analyzeSegment(dataProvider, fileInfo, findRepresentativeSegment(fileInfo), 99.9f, valueRange, error);
if (error.code != 0)
{
std::cerr << error.string;
return EXIT_FAILURE;
}
// Create layout descriptor
enum OpenVDS::VolumeDataLayoutDescriptor::BrickSize
......@@ -1235,6 +1230,37 @@ main(int argc, char* argv[])
std::vector<OpenVDS::VolumeDataAxisDescriptor> axisDescriptors = createAxisDescriptors(fileInfo);
// Check for excess of empty traces
int64_t
traceCountInVDS = 1;
for(int axis = 1; axis < (int)axisDescriptors.size(); axis++)
{
traceCountInVDS *= axisDescriptors[axis].GetNumSamples();
}
if(traceCountInVDS >= fileInfo.m_traceCount * 2)
{
fmt::print(stderr, "Warning: There is more than {:.1f}% empty traces in the VDS, this usually indicates using the wrong header format for the input dataset.\n", double(traceCountInVDS - fileInfo.m_traceCount) * 100.0 / double(traceCountInVDS));
if(!ignoreWarnings)
{
fmt::print(stderr, "Use --ignore-warnings to force the import to go ahead.\n");
return EXIT_FAILURE;
}
}
// Determine value range
OpenVDS::FloatRange
valueRange;
analyzeSegment(dataProvider, fileInfo, findRepresentativeSegment(fileInfo), 99.9f, valueRange, error);
if (error.code != 0)
{
std::cerr << error.string;
return EXIT_FAILURE;
}
// Create channel descriptors
std::vector<OpenVDS::VolumeDataChannelDescriptor> channelDescriptors = createChannelDescriptors(fileInfo, valueRange);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment