Import Geosoft Binary
A Geosoft Binary (GBN) data file contains survey data in a binary format that can be imported directly into an Oasis montaj database. The binary file format is designed as an exchange format for large volume multi-channel airborne datasets.The GBN format allows for an ASCII file header that can be used to describe the file to a user at the operating system level.
Use the Database > Import > Geosoft Binary menu option (GBN GX) to import GBN data into an Oasis database for further processing.
Import Geosoft Binary dialog options
Import file (GBN) |
Input the Geosoft binary data file name. Script Parameter: GBN.DATA |
Load channels after import? |
If "Yes" is selected, all the channels in the database are loaded after importing the data. For large databases, it may be prudent to select "No". Script Parameter: GBN.LOADCHANNELS (1: Yes (default) 0: No) |
Application Notes
By default, data is imported into the currently selected database. If no database is "current" (e.g. if none exists) then the user is prompted to create one.
If the "Specify coordinate system on import" setting is set to "Yes" in the General Settings, and if no coordinate system is defined in the current X and Y channels, the "Georeference Database Channels" dialog is called so that the projection can be set on the X and Y.
Geosoft Binary File Structure
Oasis montaj is designed to support the Geosoft Binary (GBN) file format— an ASCII file header that describes the file to a user at the operating system level. The ASCII file header is terminated by an end-of-file character (ASCII 26), so the file can be copied to a printer or simply displayed as a text file.
The format is intended for programmers who wish to design output data files that can be easily imported into a Geosoft database. It is fully described by a C language header that is included in the GBN help listing. To make a listing file GBN.H, at the DOS prompt run VIEWGX as follows:
- VIEWGX GBN -h > gbn.h
Then, remove the non-C text lines.
// gbn.fh Geosoft Oasis montaj binary file structure.
//----------------------------------------------------------------------
An Oasis montaj database is an object oriented data structure that is too complex to create without the use of the Geosoft object libraries.
If you would like to access the database directly, this can be done from a GX using GX Developer, which also provides a mechanism for calling Geosoft libraries from your own DLLs.
The Oasis montaj binary file is a simple file structure that is intended to be used by programmers as a convenient way to import data into a Geosoft database. The Oasis montaj GBN GX will import Oasis montaj binary files into a Geosoft database.
A Oasis montaj binary data file consists of an ASCII comment header followed by an ASCII 26 (hex <1A>), followed by binary data.
Binary data consists of a series of variable length binary records. Each record begins with a single byte value that identifies the record type, followed by the record data and data in the case of data records.
Record types are:
<01> simple channel record (GBN_ChanRec)
<02> line record (GBN_ChanRec)
<03> data record (GBN_Data)
Version 2 GBN record types (Oasis montaj v4.2 and later):
<04> array channel record (GBN_ArrayChanRec)
<05> parameter (GBN_Parameter)
The length of each record depends on the record type. The length of a data record will be the length of the data record structure plus the length of the data.
IEEE numbers and Intel byte order is required.
The first 17 characters of the comment header must be:
"OASIS BINARY DATA"
Any amount of ASCII text may follow. Oasis montaj will start reading binary data at the first byte after the first <1A> byte.
The file structure is as follows:
OASIS BINARY DATA // required first 17 bytes.
comment text // As much ASCII text as
. // desired can be placed
. // in the comment header.
. //
<1A> // end of ASCII comments.
<01> 80 byte simple channel record // GBN_ChanRec structure.
<05> 192 byte parameter record // optional parameter settings
.
<04> 84 byte array channel record // GBN_ArrayChanRec structure.
// <01> or <04> repeated for
// each channel of data.
<05> 192 byte parameter record // optional parameter settings
.
.
.
<02> 28 byte line record // GBN_LineRec structure.
<05> 192 byte parameter record // optional parameter settings
.
<03> data record // GBN_Data structure + data
<03> data record // GBN_Data structure + data
.
.
.
<02> 28 byte line record // GBN_LineRec structure.
<05> 192 byte parameter record // optional parameter settings
.
<03> data record // GBN_Data structure + data
<03> data record // GBN_Data structure + data
.
.
.
<00> // end of data.
Notes:
Data records are related to the channels by channel number. If you have defined three channels, they will be numbered 0, 1 and 2. Channel data records can be in any order(i.e. 0,1,2 or 1,0,2) and you do not need to specify all channels on every line.
If the channels already exist in the database, the channel parameters are ignored.
//----------------------------------------------------------------------
// Example:
Hex values are in <hex>, other binary values are in (value, value,...).
//
// The binary type of each value can be determined from the record
// structures. For example, a channel data record (1,5,4610.0,0.1,
// 42150) in binary would be:
//
// lChanNumber = 1; // long, 4 bytes
// lBinaryType = 5; // long, 4 bytes
// dFidStart = 4610.0; // double, 8 bytes
// dFidIncrement = 0.1; // double, 8 bytes
// lLength = 42150; // long, 4 bytes
//
// In this example, 42150 double (8-byte) values must immediately
// follow the channel data record.
//
// A carriage-return line-feed <0D0A> is assumed at the end of each
// comment header line for the purpose of calculating offsets.
//
// Channel names are null terminated in a 64 character field.
//
// byte
// offset data comments
// ------ [------------------------------------------------------]-------------
// 0 [OASIS BINARY DATA ] required
// 19 [ ]
// 21 [ This is a sample Oasis montaj binary data file which ]
// 69 [ contains two lines, 100 and 110, from flight 10 flown]
// 119 [ on January 19, 1995. The data includes X, Y, GPS ] comments
// 170 [ time and 256-channel spectrometer sampled once a ]
// 222 [ second and in-phase (EM-I) and quadrature (EM-Q) ]
// 272 [ data sampled 10 times per second. ]
// 315 [ ]
// 317 [<1A> ] end comments
// 318 [<01> ("Time",4,2,10,1) ] Time channel
// 399 [<01> ("X",5,0,12,1) ] X channel
// 480 [<01> ("Y",5,0,12,1) ] Y channel
// 561 [<01> ("Mag",4,0,10,1) ] Mag channel
// 642 [<01> ("EM_I",4,0,10,0) ] EM inphase
// 723 [<01> ("EM_Q",4,0,10,0) ] EM quadrature
// 808 [<04> ("Spec",1,256,0,6,0) ] 256-channel spec.
// 804 [<02> (100,0,0,10,1995,1,19) ] line 100
// 889 [<03> (0,4,1000.0,1.0,3610) (data,data, 3610 times) ] Time data
// 15358 [<03> (1,5,1000.0,1.0,3610) (data,data, 3610 times) ] X data
// 44267 [<03> (2,5,1000.0,1.0,3610) (data,data, 3610 times) ] Y data
// 73176 [<03> (3,4,1000.0,0.1,36100) (data,data, 36100 times) ] Mag data
// 217605 [<03> (4,4,1000.0,0.1,36100) (data,data, 36100 times) ] EM I data
// 362034 [<03> (5,4,1000.0,0.1,36100) (data,data, 36100 times) ] EM Q data
// 506463 [<03> (6,1,1000.0,1.0,924160) (data,data, 924160 times)] spectrometer
//2354812 [<02> (110,0,0,10,1995,1,19) ] line 110
// etc. [<03> (0,4,4610.0,1.0,4215) (data,data, 4215 times) ] Time data
// [<03> (1,5,4610.0,1.0,4215) (data,data, 4215 times) ] X data
// [<03> (2,5,4610.0,1.0,4215) (data,data, 4215 times) ] Y data
// [<03> (3,4,4610.0,0.1,42150) (data,data, 42150 times) ] Mag data
// [<03> (4,4,4610.0,0.1,42150) (data,data, 42150 times) ] EM I data
// [<03> (5,4,4610.0,0.1,42150) (data,data, 42150 times) ] EM Q data
// [<03> (6,1,1000.0,1.0,924160) (data,data, 924160 times)] spectrometer
// [<00> ] end of data
//--------------------------------------------------------------------------
#ifndef GBN_FH
#define GBN_FH
// --- record byte headers ---
#define GBN_CHAN_REC 1
#define GBN_LINE_REC 2
#define GBN_DATA_REC 3
#define GBN_ARRAYCHAN_REC 4
#define GBN_PARAMETER_REC 5
#define GBN_EOF_REC 0
// --- establish Geosoft defines if not already set ---
#ifndef LINE_NORMAL
// --- line type defines ---
#define LINE_NORMAL 0
#define LINE_BASE 1
#define LINE_TIE 2
#define LINE_TEST 3
#define LINE_TREND 4
#define LINE_SPECIAL 5
#define LINE_RANDOM 6
// --- data types ---
#define GS_BYTE 0 // signed byte
#define GS_USHORT 1 // unsigned 2-byte integer
#define GS_SHORT 2 // signed 2-byte integer
#define GS_LONG 3 // signed 4-byte integer
#define GS_FLOAT 4 // 4-byte floating point
#define GS_DOUBLE 5 // 8-byte floating point
// A string type is indicated by the negative string length. For example,
// a 10 byte string would be type -10. String data should be NULL
// terminated.
#define GS_U1DM (char ) 255U
#define GS_S1DM (signed char ) -127
#define GS_U2DM (unsigned short) 65535U
#define GS_S2DM (short ) -32767
#define GS_S4DM (long ) -2147483647L
#define GS_R8DM (double ) -1.0E32
// --- 4-byte float dummies require a variable to prevent compiler problems ---
#ifndef GS_R4DM
float GBN_r4dm = (float) GS_R8DM
#define GS_R4DM (GBN_r4dum)
#endif
// --- display formats ---
#define GSF_NORMAL 0 // Normal decimal number format
#define GSF_EXP 1 // Exponential floating point (1.2E+23)
#define GSF_TIME 2 // Time (HH:MM:SS.SSSS)
#define GSF_DATE 3 // Date (YYYY/MM/DD)
#define GSF_GGRAPH 4 // Geographical (DEG.MM.SS.SSS)
// --- end of defines ---
#endif
// --- simple channel record ---
typedef struct {
char szName[64]; // channel name, case tolerant,
// NULL terminated
// --------------------------------------------------------------------
// If the channel does not already exist, the following 4 parameters
// are used to create the Oasis montaj channel structure. If the channel
// exists, this information is ignored.
// --------------------------------------------------------------------
long lChannelType; // channel data type, one of GS_?
long lDisplayFormat; // one of GSF_?
long lDisplayWidth; // display width in characters
long lDisplayDecimals; // digits after decimal place
} GBN_ChanRec; // record type <01>
// --- Array channel record for array elements ---
typedef struct {
char szName[64]; // channel name, case tolerant,
// NULL terminated
// --------------------------------------------------------------------
// If the channel does not already exist, the following 5 parameters
// are used to create the Oasis montaj channel structure. If the channel
// exists, this information is ignored.
// --------------------------------------------------------------------
long lChannelType; // channel data type, one of GS_?
long lArrayDepth; // number of samples per element
long lDisplayFormat; // one of GSF_?
long lDisplayWidth; // display width in characters
long lDisplayDecimals; // digits after decimal place
} GBN_ArrayChanRec; // record type <04>
// --- line record ---
typedef struct {
long lLineNumber;
long lLineVersion;
long lLineType; // one of LINE_?
long lFlight;
long lYear;
long lMonth;
long lDay;
} GBN_LineRec; // record type <02>
// --- data record ---
typedef struct {
long lChanNumber; // number from channel list, 0 is first
long lBinaryType; // incoming binary data type, one of GS_?
double dFidStart; // start fiducial number
double dFidIncrement; // fiducial increment
long lLength; // number of data elements that follow
// For type 2 channel records, lLength
// will be the number of elements times
// the lArrayDepth, and data must be
// row ordered.
} GBN_Data; // record type <03>
// ---
// Named parameters.
//
// Database lines and channels may have associated named information
// which is stored as named parameters and their text string values.
// Any number of these records may immediately follow the <01>, <02>
// or <04> records.
//
// ---
//
// Projection information.
//
// Coordinate map projections may be defined using named parameters as
// follows:
//
// Name Usage
//
// "_PJ_x" name of the X channel
// "_PJ_y" name of the Y channel
// "_PJ_name" POSC projection name
// "_PJ_ellipsoid" ellipsoid name, major axis, eccen., prime meridian
// "_PJ_projection" projection type, parameters (see GXF rev. 3)
// "_PJ_datum_transform" transform name, dX,dY,dZ,rX,rY,rZ,Scale. If not
// defined, no local datum is assumed.
// ---
typedef struct {
char szParm[64]; // parameter name, NULL terminated
char szValue[128]; // parameter value, NULL terminated
} GBN_ParameterRec; // record type <05>
//----------------------------------------------------------------------
// BINARY TYPES
//
// Some of the data types in a GBN file have special usage in OASIS
// montaj. These are:
//
// GSF_TIME 2 // Time (HH:MM:SS.SSSS)
// GSF_DATE 3 // Date (YYYY/MM/DD)
// GSF_GGRAPH 4 // Geographical (DEG.MM.SS.SSS)
//
// They are stored as either GS_FLOAT or GS_DOUBLE in a channel and can
// be display in Oasis montaj as a number of as their special format (Time,Date).
//
// The following C functions can be used to create GEOSOFT dates and times.
// Note that the GGRAPH format is just a TIME format with hours between -360 and 360.
//
//----------------------------------------------------------------------
//
// long RoundLong(double a)
// {
// if (a > 0.0)
// return((long) (a + 0.5));
// else
// return((long) (a - 0.5));
// }
//
// void
// BreakTime(double dVal, // Value to break
// long *plHour, // Hours
// short *psMin, // Minutes
// short *psSec, // Seconds
// double *pdFrac) // Fraction
// {
// double dI,dF;
// short sNeg = 0;
//
// // --- Take out the negative ---
//
// if (dVal < 0.0) { sNeg = 1; dVal = -dVal; }
//
// // --- Break into Fractional Components ---
//
// dF = modf(dVal,&dI);
//
//
// // --- Determine the Hour ---
//
// *plHour = (long) dI;
//
// // --- Determine the Minutes And Seconds/Frac ---
//
// *pdFrac = modf(dF * 3600.0,&dI);
// *psSec = (short) RoundLong(dI);
// *psMin = (short) (*psSec / 60);
// *psSec = (short) (*psSec % 60);
//
// // --- Negative ? ---
//
// return(sNeg);
// }
//
// -------------------------------------------------------------------------
//
// static const short DateNGS[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
// static const short DateLGS[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
//
// #define NORMAL_YEAR 365
// #define LEAP_YEAR 366
//
// void
// sBreakDate(double dVal, // Value to break
// short *psYear, // Year
// short *psMonth, // Month
// short *psDay) // Day
// {
// double dF,dI;
// short sDays;
// const short *psMonths;
//
// short sDay;
// short sMonth;
// short sYear;
//
// // --- Break in the Integer and Fractional Components ---
//
// if (dVal < 0.0) dVal = 0.0;
// dF = modf(dVal,&dI);
//
//
// // --- Compute the Year ---
//
// sYear = (short) dI;
// if ( (sYear % 4) == 0)
// {
// psMonths = DateLGS;
// sDays = LEAP_YEAR;
// } else {
// psMonths = DateNGS;
// sDays = NORMAL_YEAR;
// }
//
// // --- Compute the Day ---
//
// sDay = (short) RoundLong(dF * (double) sDays);
//
// // --- Compute the Month ---
//
// sMonth = 0;
// while (sDay >= psMonths[sMonth]) { sDay-= psMonths[sMonth]; sMonth++; }
//
//
// // --- Ok ---
//
// *psYear = sYear;
// *psMonth = sMonth+1;
// *psDay = sDay+1;
// }
//
// -------------------------------------------------------------------------
//
// double
// dMakeTime(long lHour, // Hour Value
// long lMin, // Minute
// double dSec) // Second
// {
// double dVal;
//
// // --- Limit the Information ---
//
// if (dSec > 30000000.0) dSec = 0.0;
// else {
// while (dSec >= 60.0) {lMin++; dSec -= 60.0;}
// if (dSec < 0.0) dSec = 0.0;
// }
// if (lMin > 500000L) lMin = 0L;
// else {
// while (lMin >= 60L) {
// if (lHour >= 0L) lHour++;
// else lHour--;
// lMin -= 60;
// }
// if (lMin < 0L) lMin = 0L;
// }
//
// // --- Compute fractional hour ---
//
// dVal = (dSec + (double) (lMin * 60L)) / 3600.0;
// if (lHour < 0) dVal = -dVal;
//
// // --- Compute final value ---
//
// return(dVal + (double) lHour);
// }
//
// //-------------------------------------------------------------------------
//
// double
// dMakeDate(short sYear, // Year
// short sMonth, // Month
// short sDay) // Day of the Month
// {
// short sDays;
// const short *psMonths;
// short i;
//
// // --- Validate the Date ---
//
// if (sYear < 0) sYear = 0;
// if ((sYear%4) == 0)
// {
// psMonths = DateLGS;
// sDays = LEAP_YEAR;
// } else {
// psMonths = DateNGS;
// sDays = NORMAL_YEAR;
// }
//
//
// // --- Get the Month ---
//
// sMonth--;
// if (sMonth < 0) sMonth = 0;
// if (sMonth > 11) sMonth = 11;
//
//
// // --- Get the Day ---
//
// sDay--;
// if (sDay < 0) sDay = 0;
// if (sDay >= psMonths[sMonth]) sDay = (short) (psMonths[sMonth]-1);
//
// // --- Add days in the previous months ---
//
// i=0;
// while (i < sMonth) sDay += psMonths[i++];
//
// // --- Compute the Value ---
//
// return((double) sYear + ((double) sDay / (double) sDays));
// }
#endif
Got a question? Visit the Seequent forums or Seequent support
© 2023 Seequent, The Bentley Subsurface Company
Privacy | Terms of Use