Message Boards Message Boards

GROUPS:

Working with SEGY file format for storing geophysical data

Posted 1 year ago
1890 Views
|
2 Replies
|
10 Total Likes
|

Preamble

Several days ago I found this question in the Community. I think it interesting theme for discussion. Because I want to show how you can using the package GeologyIO. Something of this article will repeat comments on the previous question, but I want save this post to be a stand-alone tutorial for the package and SEGY in Wolfram Language.

Installation

Download and install .paclet from this repository GeologyIO:

PacletInstall[URLDownload[
    "https://wolfr.am/EXwLqEET", 
    FileNameJoin[{CreateDirectory[], "GeologyIO-0.2.1.paclet"}]
]]

(* Out[..] := Paclet[GeologyIO, 0.2.1, <>] *)

Reading SEGY data

Now let try read the .segy-file. For demonstration in the repository exist the file "/GeologyIO/Resources/MarmousiModel.segy"

If you was installed the package, you may execute following in any notebook:

Get["GeologyIO`"]
pathMarmousi =  FileNameJoin[{$GeologyIODirectory, "Examples", "Marmousi.segy"}]; 
segyMarmousi = SEGYImport[pathMarmousi]

enter image description here

This output contains all data from .segy-file. equivalents of the last line of code:

Working with loaded data

Now we have the variable segyMarmousi. This is a object with type SEGYData. For this type in the package defined special operations. For example you can get same of elements:

segyMarmousi["TextHeader"]

(* Out[..] := <about marmousi 3200 characters> *)

Similarly, you can get other elements:

  1. TextHeader
  2. BinaryHeader
  3. TraceHeaders
  4. Traces
segyMarmousi["BinaryHeader"]
(* Out[..] := {"JobID" -> 0, "LineNumber" -> 0, ..} *)

segyMarmousi["TraceHeaders"]
(* Out[..] := {"tracl", ..} -> {{0, 1, ..}, ..} *)

segyMarmousi["Traces"]
(* Out[..] := {{0.0, 1.0, ..}, ..} *)

Optimization

To convert IBM 32 Float numbers, the compiled function is used. By default, it is compiled into bytecode, but if you have a C-compiler, you can use it. On average, this gives a 2-fold gain in the speed of data import:

SEGYImport[pathMarmousi, "CompilationTarget" -> "C"]

Delayed Loading SEGY Data

This is a very interesting thing that I realized specifically for working with large files (more RAM available). You can not store such a file in the repository.Therefore, the demonstration will be conducted on the same Marmousi model. The function SEGYImport has an additional option for calling:

(* by default loading has value "Memory" *)
usegyMarmousi = SEGYImport[pathMarmousi, "Loading" -> "Delayed"] 

Unloaded elements contain only references to sections of the indexed file, which allows not storing large amounts of data entirely in memory. You can get the data with a special loader:

SEGYLoad

Exporting SEGY Data

This was much more difficult than import, but in this package, data export to SEGY is also available. Only exported data must fully correspond to the internal structure of SEGYData. For example you can create the copy of the MarmousiModel:

SEGYExport[StringReplace[pathMarmousi, ".segy" -> "Copy.segy"], marmousiData]

(* Out[..] := <path to copy> *)

P.S. Sorry for my English. I'm ready to answer questions and add features to this article and expand the functionality of the package. Offer your use cases.

2 Replies

enter image description here - Congratulations! This post is now a Staff Pick as distinguished by a badge on your profile! Thank you, keep it coming!

Thank you for this simple and straightforward step by step loading of SEGY data. it will be very useful.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract