Skip to content

Commit 082ad62

Browse files
authored
Merge branch 'main' into slice_stride
2 parents f987a54 + 7190507 commit 082ad62

16 files changed

+1207
-51
lines changed

examples/real_data_example/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ target_link_libraries(real_data_example PRIVATE
3232
mdio
3333
${mdio_INTERNAL_DEPS}
3434
${mdio_INTERNAL_S3_DRIVER_DEPS}
35-
PNG::PNG
35+
${mdio_INTERNAL_GCS_DRIVER_DEPS}
3636
indicators
3737
)

examples/real_data_example/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This tool allows users to extract specific slices from 3D seismic data stored in
3232
- `--xline_range`: Crossline range in format {crossline,start,end,step} (default: "{crossline,500,700,1}")
3333
- `--depth_range`: Optional depth range in format {depth,start,end,step}
3434
- `--variable_name`: Name of the seismic variable to extract (default: "seismic")
35-
- `--print_dataset`: Print the dataset URL and return without processing
35+
- `--print_dataset`: Print the dataset metadata and return without processing
3636

3737
### Example
3838

examples/real_data_example/src/real_data_example.cc

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "interpolation.h"
2525
#include "progress.h"
2626
#include "seismic_numpy.h"
27-
#include "seismic_png.h"
2827
#include "tensorstore/tensorstore.h"
2928

3029
#define MDIO_RETURN_IF_ERROR(...) TENSORSTORE_RETURN_IF_ERROR(__VA_ARGS__)
@@ -39,7 +38,7 @@ ABSL_FLAG(std::string, depth_range, "",
3938
"Optional depth range in format {depth,start,end,step}");
4039
ABSL_FLAG(std::string, variable_name, "seismic",
4140
"Name of the seismic variable");
42-
ABSL_FLAG(bool, print_dataset, false, "Print the dataset URL and return");
41+
ABSL_FLAG(bool, print_dataset, false, "Print the dataset metadata and return");
4342
ABSL_FLAG(std::string, dataset_path,
4443
"s3://tgs-opendata-poseidon/full_stack_agc.mdio",
4544
"The path to the dataset");
@@ -126,5 +125,11 @@ int main(int argc, char* argv[]) {
126125
auto desc2 = ParseRange(crossline_range);
127126
auto desc3 = ParseRange(depth_range);
128127

129-
return Run<float>(desc1, desc2, desc3).ok() ? 0 : 1;
130-
}
128+
auto runResult = Run<float>(desc1, desc2, desc3);
129+
if (!runResult.ok()) {
130+
std::cerr << "Error: " << runResult.ToString() << std::endl;
131+
return 1;
132+
}
133+
134+
return 0;
135+
}
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
cmake_minimum_required(VERSION 3.24)
2+
project(SeismicReader VERSION 1.0.0 LANGUAGES CXX)
3+
4+
# Set the C++ standard to C++17
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
# Specify MDIO installation directory (set by bootstrap.sh)
9+
set(MDIO_INSTALL_DIR "${CMAKE_SOURCE_DIR}/inst")
10+
11+
# Add library directories
12+
link_directories(
13+
${MDIO_INSTALL_DIR}/lib
14+
${MDIO_INSTALL_DIR}/lib/drivers
15+
)
16+
17+
# CURL is built and installed by the MDIO installer; no need for separate find_package.
18+
19+
# Define MDIO linker flags - corrected format to match SCons configuration
20+
set(MDIO_LINK_FLAGS
21+
"-Wl,-rpath,${MDIO_INSTALL_DIR}/lib,-rpath,${MDIO_INSTALL_DIR}/lib/drivers,--whole-archive,-L${MDIO_INSTALL_DIR}/lib,-L${MDIO_INSTALL_DIR}/lib/drivers,\
22+
-lnlohmann_json_schema_validator,\
23+
-ltensorstore_driver_zarr_bzip2_compressor,\
24+
-ltensorstore_driver_zarr_driver,\
25+
-ltensorstore_driver_zarr_spec,\
26+
-ltensorstore_driver_zarr_zlib_compressor,\
27+
-ltensorstore_driver_zarr_zstd_compressor,\
28+
-ltensorstore_driver_zarr_blosc_compressor,\
29+
-ltensorstore_kvstore_gcs_http,\
30+
-ltensorstore_kvstore_gcs_gcs_resource,\
31+
-ltensorstore_kvstore_gcs_validate,\
32+
-ltensorstore_kvstore_gcs_http_gcs_resource,\
33+
-ltensorstore_kvstore_s3,\
34+
-ltensorstore_kvstore_s3_aws_credentials_resource,\
35+
-ltensorstore_kvstore_s3_credentials_default_credential_provider,\
36+
-ltensorstore_kvstore_s3_credentials_environment_credential_provider,\
37+
-ltensorstore_kvstore_s3_credentials_file_credential_provider,\
38+
-ltensorstore_kvstore_s3_credentials_ec2_credential_provider,\
39+
-ltensorstore_kvstore_s3_s3_metadata,\
40+
-ltensorstore_kvstore_s3_s3_resource,\
41+
-ltensorstore_driver_json,\
42+
-ltensorstore_internal_cache_cache_pool_resource,\
43+
-ltensorstore_internal_data_copy_concurrency_resource,\
44+
-ltensorstore_kvstore_file,\
45+
-ltensorstore_internal_file_io_concurrency_resource,\
46+
-ltensorstore_internal_cache_kvs_backed_chunk_cache,\
47+
-labsl,\
48+
-lblosc,\
49+
-ltensorstore,\
50+
-lre2,\
51+
-lriegeli,\
52+
-ltinyxml2_tinyxml2,\
53+
-lcurl,\
54+
-lopenssl,\
55+
--no-whole-archive,\
56+
-lpthread,\
57+
-lm"
58+
)
59+
60+
# Debug: Print out the MDIO_LINK_FLAGS
61+
message(STATUS "MDIO_LINK_FLAGS: ${MDIO_LINK_FLAGS}")
62+
63+
# Create the executable target. (Assumes main.cpp exists in your project.)
64+
add_executable(read main.cc)
65+
66+
# Append the linker flags to the target's link flags.
67+
set_target_properties(read PROPERTIES LINK_FLAGS "${MDIO_LINK_FLAGS}")
68+
69+
# Add compile definitions
70+
target_compile_definitions(read PRIVATE HAVE_MDIO MAX_NUM_SLICES=32)
71+
72+
# Add MDIO and third-party include directories for target 'read'
73+
# Collect all immediate subdirectories from the MDIO include directory.
74+
file(GLOB CHILD_DIRS LIST_DIRECTORIES true "${MDIO_INSTALL_DIR}/include/*")
75+
76+
# Also include the top-level include directory so that headers like "mdio/mdio.h" are found.
77+
list(INSERT CHILD_DIRS 0 "${MDIO_INSTALL_DIR}/include")
78+
79+
# Remove any unwanted directories (for example, the gtest-src directory)
80+
foreach(dir ${CHILD_DIRS})
81+
get_filename_component(basename ${dir} NAME)
82+
if(basename MATCHES "gtest-src")
83+
list(REMOVE_ITEM CHILD_DIRS "${dir}")
84+
endif()
85+
endforeach()
86+
87+
# Append additional directories that the installer uses but might not be one-level deep.
88+
list(APPEND CHILD_DIRS
89+
"${MDIO_INSTALL_DIR}/include/nlohmann_json-src/include"
90+
"${MDIO_INSTALL_DIR}/include/half-src/include"
91+
)
92+
93+
target_include_directories(read PRIVATE ${CHILD_DIRS})
94+
95+
# Debug: Print out the include directories for target 'read'
96+
get_target_property(READ_INCLUDES read INCLUDE_DIRECTORIES)
97+
message(STATUS "Target 'read' include directories: ${READ_INCLUDES}")

examples/seismic_reader/README.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Seismic data reader
2+
3+
The purpose of this example is to demonstrate one method of integrating the **MDIO** C++ library into a seismic data reader into an existing project.
4+
5+
Due to the variety of target build systems and differing complexities of integrating the library with existing CMake projects, this example will also expose a way to build MDIO and its dependencies as a set of shared and linkable libraries and integrate it that way.
6+
7+
## Table of contents
8+
- [Concepts demonstrated](#concepts-demonstrated)
9+
- [Overview](#overview)
10+
- [Running](#running)
11+
- [Glossary](#glossary)
12+
13+
## Concepts demonstrated
14+
- Index-based slicing
15+
- Value-based slicing
16+
- Dimension coordinates
17+
- Coordinates
18+
- Caching
19+
20+
Chunk-aligned opreations were briefly discussed but not examined in great detail for this example.
21+
22+
## Overview
23+
24+
This example assumes that you are able to build the main branch of **MDIO**.
25+
26+
This example will perform the following steps:
27+
28+
1. Clone the installer to this directory.
29+
2. Run the installer, building and installing several archives and shared files.
30+
3. Link the installed files in the `CMakeLists.txt`.
31+
4. Demonstrate opening a Dataset with a configurable cache.
32+
5. Demonstrate acquiring the corner points for the UTM grid on the Open Poseidon dataset from S3.
33+
- Calculates the latitude and longitude coordinates for the corner points.
34+
- Provides a web link to display the surface area on a map.
35+
6. Demonstrate acquiring the inline and crossline extents.
36+
7. Demonstrate an index-based slice for chunk-aligned, tracewise processing.
37+
- Calculates basic statistics for a small section of the dataset.
38+
- Tracks the highest (peak) and lowest (trough) amplitudes and their actual inline/crossline coordinate pairs.
39+
8. Demonstrate a value-based slice for more targeted analysis.
40+
- Corolates the cdp-x and cdp-y coordinate pair for the peak and trough values.
41+
- Provides a web link to display each one's location on a map.
42+
43+
## Running
44+
45+
```bash
46+
$ ./bootstrap.sh
47+
$ cd build
48+
$ cmake ..
49+
$ make -j
50+
```
51+
52+
The bootstrap shell script will build and install the mdio-cpp library as a set of shared and static objects.
53+
54+
It will then set up the build directory if it completes without error.
55+
56+
After the program has finished building it can be run with `./read`.
57+
58+
## Glossary
59+
- Dimension coordinate: A 1-dimensional Variable that describes a dimension of the dataset.
60+
- Coordinate: A Variable that helps describe data outside of its natural (logical) domain. May be greater than 1-dimensional.
61+
- Slicing: The act of subsetting a dataset along one or more dimension coordinates. A subset of a dataset is still considered a dataset.
62+
- Index-based slicing (*isel*): Subsetting a dataset based on the logical indices of its *dimension coordinate*(s).
63+
- Value-based slicing (*sel*): Subsetting a dataset based on the values contained by its *dimension coordinate*(s).
64+
- Chunk-aligned: Slicing the data along its logical chunk boundries for efficient I/O performance.

examples/seismic_reader/bootstrap.sh

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# bootstrap.sh
3+
#
4+
# This script bootstraps the MDIO installation.
5+
# It clones the mdio-cpp-installer repository and installs MDIO
6+
# into the current directory (in the "inst" folder).
7+
#
8+
# Instruction from the installer:
9+
# $ ./install.sh [install_directory] [mdio_tag]
10+
# (the mdio_tag is ignored)
11+
# The hidden --curl flag is also used.
12+
13+
# Define installation directory as the "inst" folder in the current directory
14+
INST_DIR="$(pwd)/inst"
15+
16+
echo "Installing MDIO in: $INST_DIR"
17+
18+
# Clone the installer repo if it does not already exist
19+
if [ ! -d "mdio-cpp-installer" ]; then
20+
echo "Cloning mdio-cpp-installer repository..."
21+
git clone https://github.com/BrianMichell/mdio-cpp-installer.git || {
22+
echo "Failed to clone repository."; exit 1;
23+
}
24+
fi
25+
26+
# Change into the installer directory
27+
cd mdio-cpp-installer || {
28+
echo "Failed to change directory into mdio-cpp-installer."; exit 1;
29+
}
30+
31+
# Make sure the installer script is executable
32+
chmod +x install.sh
33+
34+
# Run the installer: Pass the installation directory, a dummy tag,
35+
# and the hidden "--curl" flag.
36+
echo "Running MDIO installer..."
37+
./install.sh "$INST_DIR" dummy_tag --curl || {
38+
echo "MDIO installation failed."; exit 1;
39+
}
40+
41+
echo "MDIO installation completed successfully."
42+
43+
# Return to the original directory
44+
cd ..
45+
46+
mkdir build

0 commit comments

Comments
 (0)