header.py
#
Utility functions for SEG-Y header manipulations.
scale_coordinates(segyfile, src_coords_bytes=(73, 77))
#
Scale coordinates with SourceGroupScalar
from seismic header.
Returns arrays of scaled X and Y coordinates.
Parameters:
-
segyfile
(SegyFile
) –Input SEG-Y file object.
-
src_coords_bytes
(tuple
, default:(73, 77)
) –Byte position of coordinates in trace header (default: (73, 77)).
Returns:
-
x
(ndarray
) –Array of X coordinates.
-
y
(ndarray
) –Array of Y coordinates.
-
CoordinateUnits
(int
) –Identifier for coordinate units.
Source code in pseudo_3D_interpolation\functions\header.py
unscale_coordinates(X, Y, coords_bytes=(73, 77), coords_units=1, scale_factor=-100)
#
Convert X/Y coordinates to int32 using scale factor for SEG-Y writing. Returns arrays of 32-bit integer X and Y coordinates.
Parameters:
-
X
(ndarray
) –Input X coordinates.
-
Y
(ndarray
) –Input Y coordinates.
-
coords_bytes
(tuple
, default:(73, 77)
) –Byte position of coordinates (default:
(73, 77)
). -
coords_units
(int
, default:1
) –SEG-Y specific coordinate unit identifier (default:
1
). -
scale_factor
(int
, default:-100
) –Coordinate scaler for conversion from int to actual format (default:
-100
).
Returns:
-
ndarray(s)
–Unscaled X and Y coordinate arrays.
Source code in pseudo_3D_interpolation\functions\header.py
set_coordinates(segyfile, X, Y, crs_dst, dst_coords_bytes=(73, 77), coordinate_units=1, scaler=-100)
#
Set X and Y coordinates using given input arrays.
Parameters:
-
segyfile
(SegyFile
) –Loaded SEG-Y file object.
-
X
(array
) –Transformed X coordinates.
-
Y
(array
) –Transformed Y coordinates.
-
crs_dst
(CRS
) –Output CRS (of given coordinate arrays).
-
dst_coords_bytes
(tuple
, default:(73, 77)
) –Tuple of starting byte of X and Y coordinates in seismic trace header (default:
(73,77)
). -
coordinate_units
–Integer code for coordinate units (default:
1
i.e. meter). -
scaler
(int
, default:-100
) –Coordinate scaler for conversion from int to actual format (default:
-100
).
Source code in pseudo_3D_interpolation\functions\header.py
check_coordinate_scalar(coord_scalar, xcoords=None, ycoords=None)
#
Check input coordinate scalar.
Return coordinate scalar (coord_scalar
) and its mulitplier (coord_scalar_mult
).
Parameters:
-
coord_scalar
(int
) –Input coordinate scalar (-1000, -100, -10, 0, 10, 100, 1000, or 'auto').
Returns:
-
coord_scalar
(int
) –Coordinate scalar to apply.
-
coord_scalar_mult
(float
) –Factor to scale coordinates.
Source code in pseudo_3D_interpolation\functions\header.py
wrap_text(txt, width=80)
#
whitespac_indices(s)
#
find_empty_line(txt, splitter='\n')
#
Return individual lines of textual header and index of first empty line.
Source code in pseudo_3D_interpolation\functions\header.py
find_line_by_str(lines, search_str='PROCESSING')
#
Return indices for lines starting with search string.
Source code in pseudo_3D_interpolation\functions\header.py
add_processing_info_header(txt, info_str, prefix=None, header=True, header_line=25, overwrite=True, newline=False)
#
Add processing information annotation to textual header string.
The info will be added to a line starting with prefix
if provided
and line is not filled.
Parameters:
-
txt
(str
) –Textual header string read from SEG-Y file.
-
info_str
(str
) –String to add to header.
-
prefix
(str
, default:None
) –Line prefix where to insert
info
(default:None
). -
header
((bool, str)
, default:True
) –If
True
: update header string with default header line Ifstr
: use provided string for header line -
header_line
–Line in textual header where to insert header line (default:
25
). -
overwrite
–Overwrite existing text in specified header line and following lines (default:
True
). -
newline
–Force text to be added to newline instead of appending to existing one (default:
False
).
Returns:
-
str
–Updated textual header string.
Source code in pseudo_3D_interpolation\functions\header.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
find_header_line(lines, header)
#
Return index of header in list of lines.
Source code in pseudo_3D_interpolation\functions\header.py
set_header_line(lines, header, line=25, overwrite=True)
#
Set custom header line to textual header line 'C25'.
Parameters:
-
lines
(str
) –String of textual header lines.
-
header
(str or bool
) –Header string to set to line.
-
line
(int
, default:25
) –Header line selcetion (default:
25
). -
overwrite
(bool
, default:True
) –Overwrite existing text in specified header line and following lines (default:
True
).
Returns:
-
str
–Updated textual header.
-
int
–Line number of header.
Source code in pseudo_3D_interpolation\functions\header.py
get_textual_header(path)
#
Read SEG-Y file and return textual header as string.
Source code in pseudo_3D_interpolation\functions\header.py
write_textual_header(path, txt, **kwargs_segy)
#
Write textual header string to SEG-Y file.