Write `traces` and `trace_headers` using the segyio C interface
ahadji05 opened this issue · comments
I want to create some functionality in my C code that allows to model data and store them in SEG-Y files for usage later. I couldn't find an example that demonstrates how to write files from scratch, and I find it difficult to get started with it. I would appreciate any help that could give me a point to start working on this, e.g. a minimal example/script that shows how to write a trace
and a trace_header
, or so.
I have the following data-structure in my C code, which I want to store into a SEG-Y:
typedef struct wavefield {
float xmin, xmax, dx; // receivers across X-axis
float ymin, ymax, dy; // receivers across Y-axis
float tmin, tmax, dt; // time-range and sample interval
float *data; // pointer to data
float srcx, srcy; // source position
int nx, ny, nt; // dimensions
int ldx, ldy, ldt; // leading dimensions ( ldx==1, ldy==nx, ldt==ny*nx )
} wavefield;
my goal is to implement an interface like this:
void create_writeable_segyfile( segy_file *fp, const char *name );
void write_trace_header( segy_file *fp, wavefield *wf, int trace_index );
void write_trace( segy_file *fp, wavefield *wf, int trace_index );
Any piece of code, hint, or link where to look further would be much appreciated:)
The flip endianness application might give you some insight into how to write a new file using the C api
https://github.com/equinor/segyio/blob/master/applications/flip-endianness.cpp