diff --git a/src/SEG-Y/SEGYImport.cpp b/src/SEG-Y/SEGYImport.cpp index 86e67b261c0b4dbe850ab47d97f501fc3862a99e..5d94a26aeab736e1ef4af961bb4073de755e977d 100644 --- a/src/SEG-Y/SEGYImport.cpp +++ b/src/SEG-Y/SEGYImport.cpp @@ -292,10 +292,8 @@ HeaderFieldFromJson(Json::Value const& jsonHeaderField) } bool -ParseHeaderFormatFile(OpenVDS::File const& file, std::map& traceHeaderFields, SEGY::Endianness& headerEndianness) +ParseHeaderFormatFile(OpenVDS::File const& file, std::map& 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(fileInfoFileName), ""); options.add_option("", "b", "brick-size", "The brick size for the volume data store.", cxxopts::value(brickSize)->default_value("64"), ""); options.add_option("", "f", "force", "Continue on upload error.", cxxopts::value(force), ""); + options.add_option("", "", "ignore-warnings", "Ignore warnings about import parameters.", cxxopts::value(ignoreWarnings), ""); options.add_option("", "", "bucket", "AWS S3 bucket to upload to.", cxxopts::value(bucket), ""); options.add_option("", "", "source-bucket", "AWS S3 bucket to download from.", cxxopts::value(sourceBucket), ""); options.add_option("", "", "region", "AWS region of bucket to upload to.", cxxopts::value(region), ""); @@ -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 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 channelDescriptors = createChannelDescriptors(fileInfo, valueRange);