cube_binning_3D.py
#
Create (sparse) inline/xline cube from intersecting 2D profiles. Applying a user-defined binning method ('average', 'median', 'nearest', or 'IDW').
check_sampling_interval(df)
#
Check and return sampling interval (dt) from datafram of all scraped SEG-Y files.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
distance(p1, p2)
#
Calculate euclidian distance between to points p1 and p2 (row-wise).
Source code in pseudo_3D_interpolation\cube_binning_3D.py
find_nearest_ilxl(ilxl_reference, ilxl_data, return_index=False)
#
Find nearest ilxl of each input trace.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
points_from_extent(extent)
#
Return numpy array from extent provided as (w, e, s, n)
or (xmin, xmax, ymin, ymax)
, respectively.
Parameters:
-
extent
(tuple
) –Data extent provided as
(w, e, s, n)
or(xmin, xmax, ymin, ymax)
.
Returns:
-
ndarray
–Corner coordinates of given extent as
(lower_left, upper_left, upper_right, lower_right)
.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
extent_from_points(points)
#
Return bounding box extent from points (N, 2).
Source code in pseudo_3D_interpolation\cube_binning_3D.py
get_polygon_area(pts)
#
Calculate polygon area (in cartesian coordinates).
Parameters:
-
pts
(ndarray
) –2D input array of X and Y coordinates with shape (n_points, 2).
Returns:
-
area
(float
) –Polygon area (in coordinate units).
References#
-
Stackoverflow post https://stackoverflow.com/a/66801704 ↩
Source code in pseudo_3D_interpolation\cube_binning_3D.py
get_polygon_centroid(xy)
#
Calculate polygon centroid (in cartesian coordinates).
Parameters:
-
xy
(ndarray
) –2D input array of X and Y coordinates with shape (n_points, 2).
Returns:
-
centroid
(ndarray
) –Centroid coordinate array (x, y).
References#
-
Stackoverflow post https://stackoverflow.com/a/66801704 ↩
Source code in pseudo_3D_interpolation\cube_binning_3D.py
affine_transform_coords_to_ilxl(corner_points=None, extent=None, spacing=None, base_transform=None, inverted=False, original_coords=False, verbose=False)
#
Create Affine transformation object from (a) corner_points
or (b) extent
and spacing
.
If base_transform
is provided, it will be used to setup final transform.
Parameters:
-
corner_points
(ndarray
, default:None
) –2D array of corner points with shape (4,2): Either this variable or
extent
are required! -
extent
(tuple
, default:None
) –Tuple of extent (xmin, xmax, ymin, ymax). Either this variable or
corner_points
are required! -
spacing
(float | tuple(float, float)
, default:None
) –Grid bin size (in CRS units). Can be single value or tuple(ysize, xsize), i.e. (iline, xline).
-
base_transform
(Affine
, default:None
) –Base transformation used to set up the returned transformation.
-
inverted
(bool
, default:False
) –base_transform
is inverted (default:False
). -
original_coords
(TYPE
, default:False
) –Priginal, non-transformed coordinates provided (default:
False
). -
verbose
(bool
, default:False
) –Print verbose output (default:
False
).
Returns:
-
Affine
–Affine transformation.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
round_ilxl_extent(points)
#
Round array of cube il/xl indices to appropriate integer indice values.
- lower/left indices --> rounded up
- upper/right indices --> rounded down
Parameters:
-
points
(ndarray
) –Array of il/xl for corner points of cube.
Returns:
-
ndarray
–Rounded input array.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
pad_trace(da, delrt, twt, dt)
#
Pad seismic trace at top and bottom to fit global twt
array.
Parameters:
-
da
(array
) –Input seismic trace.
-
delrt
(int
) –Delay recording time of seismic trace (ms).
-
twt
(ndarray
) –Reference array of output two-way traveltimes (TWT).
-
dt
(float
) –Sampling rate (ms).
Returns:
-
out
(array
) –Padded seismic trace.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
adjust_extent(extent, spacing)
#
Adjust extent to fit given spacing by adding to min/max of X and Y coordinates.
Parameters:
-
extent
(tuple
) –Extent of point data as coordinate tuple
(xmin, xmax, ymin, ymax)
. -
spacing
(float | tuple(float, float)
) –Grid bin size (in CRS units). Can be single value or tuple featuring (xsize, ysize).
Returns:
-
extent_adj
(tuple
) –Adjusted extent of original data extent.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
transform_and_adjust_extent(extent_pts, spacing, transform)
#
Transform using Affine transform
and adjust cube extent according to bin spacing.
Parameters:
-
extent_pts
(tuple
) –Data extent as tuple of
(w, e, s, n)
or(xmin, xmax, ymin, ymax)
. -
spacing
(tuple
) –Bin spacing (il, xl) or (y, x).
-
transform
(Affine
) –Affine transformation to create NS-aligned geometry for input corner points.
Returns:
-
tuple
–Transformed (e.g. rotated) and adjusted extent.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
get_cube_parameter(transform_forward, transform_reverse, df_nav, bin_size, cube_corner_pts, bin_size_region=None, region_corner_pts=None, return_geometry=False, verbose=False)
#
Create cube inline/xline bin indices and associated bin center coordinates.
Based on provided forward/inverse coordinate transform objects, bin size (in coordinate units)
and given extent of output cube.
Inline/xline indices start with 1 if region_corner_pts
argument is not provided.
Parameters:
-
transform_forward
(transform
) –Forward Affine transform used as base transform for coordinate transformation.
-
transform_reverse
(transform
) –Inverse Affine transform.
-
df_nav
(DataFrame
) –Dataframe with X and Y coordinates for each seismic trace from all SEGY files.
-
bin_size
(float | tuple(float, float)
) –Size of iline/xline bins (in CRS units, e.g. meter).
-
bin_size_region
(float | tuple(float, float)
, default:None
) –Size of iline/xline bins for region (in CRS units, e.g. meter).
-
cube_corner_pts
(ndarray
) –Corner point coordinates of cube (lower_left, upper_left, upper_right, lower_right) with shape (4, 2).
-
region_corner_pts
(ndarray
, default:None
) –Optional corner point coordinates of region (lower_left, upper_left, upper_right, lower_right) with shape (4, 2). Useful if
cube
is part of a larger region and bin indices should not start with 1. -
return_geometry
(bool
, default:False
) –Return adjusted geometry for cube_corner_pts (and region_corner_pts if specified)
-
verbose
(bool
, default:False
) –Print optional information to console (default:
False
).
Returns:
-
df_bins
(DataFrame
) –Dataframe defining output cube with inline 'il' and xline 'xl' indices and bin center coordinates ('x', 'y').
-
df_ilxl
(DataFrame
) –Dataframe with inline and xline indices for each trace position provided in
df_nav
.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
|
get_segy_header_dataframe(path, dir_seismic, df_ilxl, df_bins, byte_filter=[1, 5, 9, 71, 73, 77, 109, 115, 117], suffix='sgy', parallel=False, include_files=None, return_headers=False, verbose=False)
#
Scrape SEG-Y headers and return pandas.DataFrame of selected header entries.
Parameters:
-
path
(str
) –Path of textfile with filenames of SEGY files to scrape.
-
dir_seismic
(str
) –Directory of SEGY files.
-
df_ilxl
(DataFrame
) –Dataframe of iline/xline indices for each trace position (from auxiliary navigation file).
-
df_bins
(DataFrame
) –Dataframe of cube bins featuring iline/xline indices and bin center coordinates.
-
byte_filter
(list
, default:[1, 5, 9, 71, 73, 77, 109, 115, 117]
) –List of byte indices to scrape.
-
suffix
(str
, default:'sgy'
) –SEG-Y file suffix (default:
sgy
). -
parallel
(bool
, default:False
) –Perform operation in parallel using
dask.delayed
(default:False
). -
include_files
(list
, default:None
) –List of SEG-Y files to scrape headers from (default:
None
). Useful if more SEG-Y files in specified folder/datalist. -
return_headers
(bool
, default:False
) –Whether to return DataFrame of all available traces (default: False).
-
verbose
(int
, default:False
) –Print optional information to console (default:
False
).
Returns:
-
DataFrame
–Dataframe of scraped header information with inline/xline numbers for each trace.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 |
|
get_segy_binary_header(path=None, segy_dir=None, suffix='sgy', byte_filter=None, check_all=False, return_byte_keys=False, parallel=False, verbose=False, **segyio_kwargs)
#
Scrape binary header fields of SEG-Y file(s).
Specify either single datalist (path
) or folder with SEG-Y files (segy_dir
).
Parameters:
-
path
(str
, default:None
) –File path of datalist with SEG-Y file(s). Either
path
orsegy_dir
must be specified. -
segy_dir
(str
, default:None
) –Directory of SEG-Y file(s). Either
path
orsegy_dir
must be specified. -
suffix
(str
, default:'sgy'
) –SEG-Y file suffix (default:
sgy
). -
byte_filter
(list
, default:None
) –Exclude specified byte locations from check if
check_all
is True. -
check_all
(bool
, default:False
) –Check binary header of all SEG-Y files (default:
False
). Raise warning if different values are detected. -
return_byte_keys
(bool
, default:False
) –Return byte locations as keys. The default is a descriptive label.
-
parallel
(bool
, default:False
) –Scrape SEG-Y files in parallel using
dask.delayed
(default:False
). -
verbose
(bool
, default:False
) –Print optional information to console (default:
False
). -
**segyio_kwargs
(dict
, default:{}
) –Optional kwargs for
segyio.open()
.
Raises:
-
ValueError
–If neither
path
norsegy_dir
are specified.
Warns:
-
UserWarning
–If different binary headers are found in searched SEG-Y files.
Returns:
-
list_headers
(dict
) –Binary header dictionary.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 |
|
open_seismic_netcdfs(dir_seismic, suffix='seisnc', datalist_path=None, include_files=None, kwargs_seisnc=None, parallel=True, verbose=False)
#
Open multiple seismic netCDF files and return list of SEGY datasets.
Parameters:
-
dir_seismic
(str
) –Directory of seismic files.
-
suffix
(str
, default:'seisnc'
) –File suffix (default:
seisnc
). -
datalist_path
(str
, default:None
) –Filter available seismic files based on list of SEGY files to use.
-
include_files
(list
, default:None
) –List of SEG-Y files to scrape headers from (default:
None
). Useful if more SEG-Y files in specified folder/datalist. -
kwargs_seisnc
(dict
, default:None
) –Keyword arguments for segysak.open_seisnc (default:
None
). -
parallel
(bool
, default:True
) –Open netCDF files in parallel (default:
True
). -
verbose
(bool
, default:False
) –Print optional information to console (default:
False
).
Returns:
-
datasets
(list
) –List of SEGY datasets.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
|
inlines_from_seismic(df, df_bins, datasets, out_dir, bin_size, bin_size_str, stacking_method='average', factor_dist=1.0, twt_minmax=None, encode=False, is_envelope=None, dtype_data=None, ilxl_labels=['il', 'xl'], kwargs_nc=None, verbose=False)
#
Create inline netCDF files from seismic profiles (*.seisnc). Using auxiliary information from SEGY header scrape and one of the following stacking methods:
average
median
nearest
IDW
(Inverse Distance Weighting)
Parameters:
-
df
(DataFrame
) –Dataframe of scraped SEGY header information and assigned iline/xline bin indices.
-
df_bins
(DataFrame
) –Dataframe of cube iline/xline indices and bin center coordinates.
-
datasets
(iterable[tuple, list]
) –Iterable of xr.Datasets of opened *.seisnc files on disk.
-
out_dir
(str
) –Output directory.
-
bin_size
(float | tuple(float, float)
) –Bin size in inline/xline direction (in CRS units, e.g. meter).
-
bin_size_str
(str
) –String representation of
bin_size
(suitable for filenames). -
stacking_method
(str
, default:'average'
) –Method to stack traces within single bin (default:
average
): ['average', 'median', 'nearest', 'IDW'] -
factor_dist
(float
, default:1.0
) –User-specified factor controlling the severity of weighting function: 1/(dist**factor). Larger values (>1) increase influence of closer while reducing impact of more distant traces and vis versa for smaller values (<1).
-
twt_minmax
(tuple
, default:None
) –Minimum and maximum TWT (in ms): (min, max)
-
encode
(bool
, default:False
) –Use encoding to compress output file size (default:
False
). -
is_envelope
(bool
, default:None
) –Boolean variable defining if input traces are provided as envelope (of amplitude).
-
dtype_data
(str
, default:None
) –Output data array dtype. Use input datasets dtype as default.
-
ilxl_labels
(list
, default:['il', 'xl']
) –List of iline/xline column names in
df
. -
kwargs_nc
(dict
, default:None
) –Dictionary of netCDF attributes and parameters (from YAML file).
-
verbose
(int
, default:False
) –Print optional information to console (default:
False
).
Source code in pseudo_3D_interpolation\cube_binning_3D.py
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 |
|
merge_inlines_to_cube(inlines_dir, cube_path, kwargs_mfdataset=None, kwargs_nc=None, verbose=False)
#
Merge individual inline netCDF files into single 3D cube netCDF.
Parameters:
-
inlines_dir
(str
) –Directory of inline netCDF files.
-
cube_path
(str
) –Path of cube file on disk.
-
kwargs_mfdataset
(dict
, default:None
) –Keyword arguments for xarry.open_kwargs_mfdataset (default:
None
). -
kwargs_nc
(dict
, default:None
) –Dictionary of netCDF attributes and parameters (from JSON file).
-
verbose
(int
, default:False
) –Print optional information to console (default:
False
).
Returns:
-
cube
(Dataset
) –Merged dataset from individual inline files.
Source code in pseudo_3D_interpolation\cube_binning_3D.py
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 |
|
transpose_slice_major(cube_path, cube_twt_path, kwargs_dataset=None, verbose=False)
#
Transpose cube file (inline, xline, twt) to time-major layout (twt, inline, xline). Practical for faster time/frequency slice access.
Parameters:
-
cube_path
(str
) –Path of cube file on disk.
-
cube_twt_path
(str
) –Output file path of transposed cube.
-
kwargs_dataset
(dict
, default:None
) –Keyword arguments for xarry.open_dataset (default:
None
). -
verbose
(int
, default:False
) –Print optional information to console (default:
False
).
Returns:
-
cube_file
(Dataset
) –Dataset of sparse 3D cube on disk.