1.5.1
CCC
 
segy.cpp File Reference
#include "OutputFormat/segy.h"
#include "Basic/Utilities.hpp"
#include "Basic/File.hpp"
#include "Db/Db.hpp"
#include "Db/DbGrid.hpp"
#include "geoslib_old_f.h"
#include <stdio.h>
#include <string.h>
#include <math.h>

Classes

struct  RefPt
 
struct  RefStats
 

Macros

#define MAT(i, j)   (mat[2 * (i) + (j)])
 
#define SWAP_INT16(x)   (x) = ((0x00ff & ((x))>>8) | (0xff00 & ((x))<<8))
 
#define SWAP_INT32(x)
 

Functions

static int st_to_f (int x)
 
static short int st_to_s (short int x)
 
static unsigned short int st_to_u (unsigned short int a)
 
static int st_to_i (int a)
 
static float st_ibm2ieee (const float ibm)
 
static double st_scaling (int coor, int scale)
 
static void st_print_traceHead (traceHead *Theader, int numTrace)
 
static void st_print_BFileHead (binaryFileHeader *Bheader)
 
static binaryFileHeader st_binaryFileHeader_init ()
 
static int st_readFileHeader (FILE *file, int verbOption, int *NPerTrace, double *delta)
 
static int st_read_trace (FILE *file, int codefmt, int numtrace, int nPerTrace, double delta, int verbOption, VectorDouble &values, VectorDouble &cotes)
 
static int st_surface_identify (int verbOption, Db *surfaces, const String &name_bot, bool flag_bot, int *iatt_bot, const String &name_top, bool flag_top, int *iatt_top, const String &aux_top, int *iaux_top, const String &aux_bot, int *iaux_bot)
 
static int st_get_cuts (Db *surfaces, int rank, int iatt_top, int iatt_bot, double, double, double thickmin, double *cztop, double *czbot)
 
static void st_verify_refpt (RefPt refpt[3], RefStats &refstats, int nbrefpt, double x0, double y0, double dx, double dy, double sint, double cost)
 
static void st_grid_from_3refpt (RefPt refpt[3], RefStats &refstats, double dz, Grid &def_grid)
 
static void st_grid_from_2refpt (RefPt refpt[3], RefStats &refstats, double dz, Grid &def_grid)
 
static int st_store_refpt (int nbrefpt, RefPt refpt[3], int iline, int xline, double xtrace, double ytrace)
 
static void st_print_grid (const Grid &def_grid)
 
static int st_complete_squeeze_and_stretch (int ntab, VectorDouble &tab)
 
static bool st_within_layer (double z0, double delta, double cztop, double czbot, double cote, int option, int nz, int *iz1_ret, int *iz2_ret, double *cote_ret)
 
static double st_get_average (int nz, const VectorDouble &writes)
 
static int st_identify_trace_rank (DbGrid *surfaces, double xtrace, double ytrace)
 
static void st_auxiliary (Db *surfaces, int rank, int nz, int option, double z0, double delta, double czbot, double cztop, int iaux_bot, int iaux_top, RefStats &refstats)
 
static int st_load_trace (int nPerTrace, int nz, int option, double z0, double delta, double czbot, double cztop, const VectorDouble &cotes, const VectorDouble &values, VectorDouble &writes, int *nbvalues, RefStats &refstats)
 
static void st_print_results (int nPerTrace, bool flag_surf, double delta, RefStats &refstats)
 
void st_get_trace_params (traceHead *Theader, int *iline, int *xline, double *delta, double *xtrace, double *ytrace)
 
static int st_reject_trace (int iline, int xline, int iline_min, int iline_max, int xline_min, int xline_max)
 
static void st_refstats_update (int iline, int xline, double xtrace, double ytrace, RefStats &refstats)
 
static void st_refstats_init (RefStats &refstats, double modif_high, double modif_low, double modif_scale)
 
static traceHead st_traceHead_init ()
 
SegYArg segy_array (const char *filesegy, DbGrid *surf2D, const String &top_name, const String &bot_name, const String &top_aux, const String &bot_aux, double thickmin, int option, int nz_ss, int verbOption, int iline_min, int iline_max, int xline_min, int xline_max, double modif_high, double modif_low, double modif_scale, int codefmt)
 
Grid segy_summary (const char *filesegy, DbGrid *surf2D, const String &name_top, const String &name_bot, double thickmin, int option, int nz_ss, int verbOption, int iline_min, int iline_max, int xline_min, int xline_max, double modif_high, double modif_low, double modif_scale, int codefmt)
 
int db_segy (const char *filesegy, DbGrid *grid3D, DbGrid *surf2D, const String &name_top, const String &name_bot, double thickmin, int option, int nz_ss, int verbOption, int iline_min, int iline_max, int xline_min, int xline_max, double modif_high, double modif_low, double modif_scale, int codefmt, const NamingConvention &namconv)
 

Macro Definition Documentation

◆ MAT

#define MAT (   i,
 
)    (mat[2 * (i) + (j)])

◆ SWAP_INT16

#define SWAP_INT16 (   x)    (x) = ((0x00ff & ((x))>>8) | (0xff00 & ((x))<<8))

◆ SWAP_INT32

#define SWAP_INT32 (   x)
Value:
(x) = ((0x000000ff & ((x))>>24) | \
(0x0000ff00 & ((x))>>8) | \
(0x00ff0000 & ((x))<<8) | \
(0xff000000 & ((x))<<24))
#define x

Function Documentation

◆ db_segy()

int db_segy ( const char *  filesegy,
DbGrid grid3D,
DbGrid surf2D,
const String name_top,
const String name_bot,
double  thickmin,
int  option,
int  nz_ss,
int  verbOption,
int  iline_min,
int  iline_max,
int  xline_min,
int  xline_max,
double  modif_high,
double  modif_low,
double  modif_scale,
int  codefmt,
const NamingConvention namconv 
)

Read the contents of a SEGY file

Returns
Error return code
Parameters
[in]filesegyName of the SEGY file
[in]grid3DDb containing the resulting 3-D grid
[in]surf2DDb containing the top, Bottom and Reference surfaces This file is optional
[in]name_topRank of variable containing the Top Surface (or 0)
[in]name_botRank of variable containing the Bottom Surface (or 0)
[in]thickminMinimum thickness (or 0)
[in]optionFlattening option: 0 no flattening; 1 flattening from top; -1 flattening from bottom -2 squeeze and stretch option 2 averaging from 3-D to 2-D
[in]nz_ssDeprecated argument
[in]verbOptionVerbose option
[in]iline_minMinimum Inline number included (if defined)
[in]iline_maxMaximum Inline number included (if defined)
[in]xline_minMinimum Xline number included (if defined)
[in]xline_maxMaximum Xline number included (if defined)
[in]modif_highUpper truncation (when defined)
[in]modif_lowLower truncation (when defined)
[in]modif_scaleScaling value (when defined)
[in]codefmtReading format
[in]namconvNaming convention

: In the case of Squeeze and Stretch (S&S), the number of layers

: is meaningless. It is fixed by the user, unless defined

: by the output grid (if flag_store == 1)

Remarks
For filling the 3-D grid
- 2-D characteristics of the grid are taken into account
- no attention is paid to the vertical mesh value.

◆ segy_array()

SegYArg segy_array ( const char *  filesegy,
DbGrid surf2D,
const String top_name,
const String bot_name,
const String top_aux,
const String bot_aux,
double  thickmin,
int  option,
int  nz_ss,
int  verbOption,
int  iline_min,
int  iline_max,
int  xline_min,
int  xline_max,
double  modif_high,
double  modif_low,
double  modif_scale,
int  codefmt 
)

Read the contents of a SEGY file

Returns
A SegYArg structure which contains:
- a vector of trace vectors
- a vector of trace descriptors
The Descriptor for each trace contains:
0: Absolute rank for the trace number
1: Cross-Line number
2: In-Line number
3: Coordinate along X
4: Coordinate along Y
5: Minimum Elevation
6: Maximum Elevation
7: Minimum Value
8: Maximum value
9: Thickness
10: Number of values
11: Minimum Elevation of Auxiliary surface
12: Maximum Elevation of Auxiliary surface
Parameters
[in]filesegyName of the SEGY file
[in]surf2DDb containing the top, Bottom and Reference surfaces This file is optional
[in]top_nameName of variable containing the Top Surface (or "")
[in]bot_nameName of variable containing the Bottom Surface (or "")
[in]top_auxName of auxiliary variable containing a Top (or "")
[in]bot_auxName of auxiliary variable containing a Top (or "")
[in]thickminMinimum thickness (or 0)
[in]optionFlattening option: 0 no flattening; 1 flattening from top; -1 flattening from bottom -2 squeeze and stretch option 2 averaging from 3-D to 2-D
[in]nz_ssNumber of layers for different options (see details)
[in]verbOptionVerbose option
[in]iline_minMinimum Inline number included (if defined)
[in]iline_maxMaximum Inline number included (if defined)
[in]xline_minMinimum Xline number included (if defined)
[in]xline_maxMaximum Xline number included (if defined)
[in]modif_highUpper truncation (when defined)
[in]modif_lowLower truncation (when defined)
[in]modif_scaleScaling value (when defined)
[in]codefmtReading format

In the case of Squeeze and Stretch (S&S), the number of layers

is meaningless. It is fixed by the user.

◆ segy_summary()

Grid segy_summary ( const char *  filesegy,
DbGrid surf2D,
const String name_top,
const String name_bot,
double  thickmin,
int  option,
int  nz_ss,
int  verbOption,
int  iline_min,
int  iline_max,
int  xline_min,
int  xline_max,
double  modif_high,
double  modif_low,
double  modif_scale,
int  codefmt 
)

Read the contents of a SEGY file and returns the structure SegyRead which captures the main characteristics of the SEGY grid

Parameters
[in]filesegyName of the SEGY file
[in]surf2DDb containing the top, Bottom and Reference surfaces This file is optional
[in]name_topRank of variable containing the Top Surface (or 0)
[in]name_botRank of variable containing the Bottom Surface (or 0)
[in]thickminMinimum thickness (or 0)
[in]optionFlattening option: 0 no flattening; 1 flattening from top; -1 flattening from bottom -2 squeeze and stretch option 2 averaging from 3-D to 2-D
[in]nz_ssNumber of layers for different options (see details)
[in]verbOptionVerbose option
[in]iline_minMinimum Inline number included (if defined)
[in]iline_maxMaximum Inline number included (if defined)
[in]xline_minMinimum Xline number included (if defined)
[in]xline_maxMaximum Xline number included (if defined)
[in]modif_highUpper truncation (when defined)
[in]modif_lowLower truncation (when defined)
[in]modif_scaleScaling value (when defined)
[in]codefmtReading format

: In the case of Squeeze and Stretch (S&S), the number of layers

: is meaningless. It is fixed by the user, unless defined

: by the output grid (if flag_store == 1)

◆ st_auxiliary()

static void st_auxiliary ( Db surfaces,
int  rank,
int  nz,
int  option,
double  z0,
double  delta,
double  czbot,
double  cztop,
int  iaux_bot,
int  iaux_top,
RefStats refstats 
)
static

Project the auxiliary surfaces on the system defined by the unit and store the result in the structure 'refstats'

Parameters
surfacesPointer to the Db containing the surfaces
rankRank of the trace within 'db'
nzNumber of meshes in the layer
optionStretching option
z0Elevation origin
deltaVertical mesh
czbotBottom bound
cztopTop bound
iaux_botAttribute index of the Auxiliary Bottom variable (or -1)
iaux_topAttribute index of the Auxiliary Top variable (or -1)
refstatsRefStats structure
Returns

◆ st_binaryFileHeader_init()

static binaryFileHeader st_binaryFileHeader_init ( )
static

◆ st_complete_squeeze_and_stretch()

static int st_complete_squeeze_and_stretch ( int  ntab,
VectorDouble tab 
)
static

Complete the information in the Squeeze and Stretch feature

Returns
1 if the vector only contains TEST values
Parameters
[in]ntabDimension of the vector
[in,out]tabVector

◆ st_get_average()

static double st_get_average ( int  nz,
const VectorDouble writes 
)
static

Calculate the average

◆ st_get_cuts()

static int st_get_cuts ( Db surfaces,
int  rank,
int  iatt_top,
int  iatt_bot,
double  ,
double  ,
double  thickmin,
double *  cztop,
double *  czbot 
)
static

Define the cutoffs along a vertical for a given trace

Returns
Error returned code
Parameters
[in]surfacesDb containing the top, Bottom and Reference surfaces This file is optional
[in]rankRank of the trace within 'surfaces'
[in]iatt_topRank of attribute containing the Top Surface (or 0)
[in]iatt_botArnk of the attribute containing the Bottom Surface (or 0)
[in]thickminMinimum thickness (if defined)
[out]cztopCoordinate for the Top along Z (or TEST)
[out]czbotCoordinate for the Bottom along Z (or TEST)

◆ st_get_trace_params()

void st_get_trace_params ( traceHead Theader,
int *  iline,
int *  xline,
double *  delta,
double *  xtrace,
double *  ytrace 
)

Get Trace characteristics

◆ st_grid_from_2refpt()

static void st_grid_from_2refpt ( RefPt  refpt[3],
RefStats refstats,
double  dz,
Grid def_grid 
)
static

Derive grid information from the two Reference Points

Parameters
[in]refptArray of RefPt structure pointers
[in]refstatsStructure for Statistics
[in]dzVertical mesh
[out]def_gridGrid output structure

◆ st_grid_from_3refpt()

static void st_grid_from_3refpt ( RefPt  refpt[3],
RefStats refstats,
double  dz,
Grid def_grid 
)
static

Derive grid information from the three Reference Points

Parameters
[in]refptArray of RefPt structure pointers
[in]refstatsStructure for Statistics
[in]dzVertical mesh
[out]def_gridGrid output structure

◆ st_ibm2ieee()

static float st_ibm2ieee ( const float  ibm)
static

◆ st_identify_trace_rank()

static int st_identify_trace_rank ( DbGrid surfaces,
double  xtrace,
double  ytrace 
)
static

Identify the rank of the trace within the 'Db'

Parameters
surfacesPointer to the 'Db' containing the surfaces
xtraceX-coordinate of the trace
ytraceY-coordinate of the trace
Returns
Remarks
The rank is returned as -1 if not defined

◆ st_load_trace()

static int st_load_trace ( int  nPerTrace,
int  nz,
int  option,
double  z0,
double  delta,
double  czbot,
double  cztop,
const VectorDouble cotes,
const VectorDouble values,
VectorDouble writes,
int *  nbvalues,
RefStats refstats 
)
static

Processing a Trace

◆ st_print_BFileHead()

static void st_print_BFileHead ( binaryFileHeader Bheader)
static

Internal function for printing the Binary File Header

Parameters
[in]BheaderPointer to the Binary File header

◆ st_print_grid()

static void st_print_grid ( const Grid def_grid)
static

Print the characteristics of the resulting grid

Parameters
[in]def_gridPointer to the Grid structure

◆ st_print_results()

static void st_print_results ( int  nPerTrace,
bool  flag_surf,
double  delta,
RefStats refstats 
)
static

Printout

◆ st_print_traceHead()

static void st_print_traceHead ( traceHead Theader,
int  numTrace 
)
static

Internal function for printing the Trace Header

Parameters
[in]TheaderPointer to the Trace Header contents
[in]numTraceRank of the trace

◆ st_read_trace()

static int st_read_trace ( FILE *  file,
int  codefmt,
int  numtrace,
int  nPerTrace,
double  delta,
int  verbOption,
VectorDouble values,
VectorDouble cotes 
)
static

◆ st_readFileHeader()

static int st_readFileHeader ( FILE *  file,
int  verbOption,
int *  NPerTrace,
double *  delta 
)
static

Internal function for reading the File header

Parameters
[in]filePointer to the File stream
[in]verbOptionVerbose option
[out]NPerTraceNumber of samples per trace
[out]deltaDistance between two consecutive vertical samples

◆ st_refstats_init()

static void st_refstats_init ( RefStats refstats,
double  modif_high,
double  modif_low,
double  modif_scale 
)
static

Initialize statistics

◆ st_refstats_update()

static void st_refstats_update ( int  iline,
int  xline,
double  xtrace,
double  ytrace,
RefStats refstats 
)
static

Update statistics

◆ st_reject_trace()

static int st_reject_trace ( int  iline,
int  xline,
int  iline_min,
int  iline_max,
int  xline_min,
int  xline_max 
)
static

Reject trace due to trace boundary specifications

◆ st_scaling()

static double st_scaling ( int  coor,
int  scale 
)
static

Internal function to scale the coordinate by the scaling factor

Returns
Scaled value
Parameters
[in]coorInteger value containing the input coordinate
[in]scaleInteger value giving the scale factor

◆ st_store_refpt()

static int st_store_refpt ( int  nbrefpt,
RefPt  refpt[3],
int  iline,
int  xline,
double  xtrace,
double  ytrace 
)
static

Store an additional reference point

Returns
Number of RefPt already stored
Parameters
[in]nbrefptNumber of RefPt currently allocated
[in]refptArray of RefPt structure pointers
[in]ilineInline number
[in]xlineCrossline number
[in]xtraceCoordinate of the trace along X
[in]ytraceCoordinate of the trace along y

◆ st_surface_identify()

static int st_surface_identify ( int  verbOption,
Db surfaces,
const String name_bot,
bool  flag_bot,
int *  iatt_bot,
const String name_top,
bool  flag_top,
int *  iatt_top,
const String aux_top,
int *  iaux_top,
const String aux_bot,
int *  iaux_bot 
)
static

Identify Bottom and Top surfaces (if present)

Returns
Error returned code
Parameters
[in]verbOptionVerbose Option
[in]surfacesDb containing the top, Bottom and Reference surfaces This file is optional
[in]name_botName of variable containing the Bottom Surface (or empty)
[in]flag_botFlag for defining a Bottom surface
[in]name_topName of variable containing the Top Surface (or empty)
[in]flag_topFlag for defining a Top surface
[in]aux_topName of the Auxiliary Top variable (optional)
[in]aux_botName of the Auxiliary Bottom variable (optional)
[out]iatt_topAttribute index for the Top surface (or -1)
[out]iatt_botAttribute index for the Bottom surface (or -1)
[out]iaux_topAttribute index for the Top Auxiliary variable (or -1)
[out]iaux_botAttribute index for the Bottom Auxiliary variable (or -1)

◆ st_to_f()

static int st_to_f ( int  x)
static

Routines for reading / decoding information stored in SEGY file

◆ st_to_i()

static int st_to_i ( int  a)
static

◆ st_to_s()

static short int st_to_s ( short int  x)
static

◆ st_to_u()

static unsigned short int st_to_u ( unsigned short int  a)
static

◆ st_traceHead_init()

static traceHead st_traceHead_init ( )
static

◆ st_verify_refpt()

static void st_verify_refpt ( RefPt  refpt[3],
RefStats refstats,
int  nbrefpt,
double  x0,
double  y0,
double  dx,
double  dy,
double  sint,
double  cost 
)
static

Check that calculations are correct

Parameters
[in]refptArray of RefPt structure pointers
[in]refstatsStructure for Statistics
[in]nbrefptNumber of reference points
[in]x0Origin of the grid along X
[in]y0Origin of the grid along Y
[in]dxMesh of the grid along X
[in]dyMesh of the grid along Y
[in]sintSine of the rotation angle
[in]costCosine of the rotation angle
Remarks
The internal flag debug must be set to 1 to perform this task

◆ st_within_layer()

static bool st_within_layer ( double  z0,
double  delta,
double  cztop,
double  czbot,
double  cote,
int  option,
int  nz,
int *  iz1_ret,
int *  iz2_ret,
double *  cote_ret 
)
static

Get the vertical limits in indices Check if the target elevation 'cote' belongs to the layer If True, returns the starting and ending index

Parameters
z0Origin of the Elevations
deltaElevation increment
cztopTop bound
czbotBottom bound
coteTarget elevation
optionStretching option
nzNumber of meshes of the layer
iz1_retReturned starting index
iz2_retReturned ending index
cote_retReturelevation (expressed in the layer system (possibly stretched)
Returns
True if the target elevation belongs to the layer