Message Boards Message Boards


Working with SEGY file format for storing geophysical data

Posted 5 years ago
2 Replies
10 Total Likes


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.


Download and install .paclet from this repository GeologyIO:

    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:

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:


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

Similarly, you can get other elements:

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

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

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


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:


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.

POSTED BY: Kirill Belov
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!

POSTED BY: Moderation Team

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

POSTED BY: Oluseun Sanuade
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract