Log I/O
Loading...
Searching...
No Matches
BitFileReader Class Referencesealed

Class for reading BIT log files. More...

Public Member Functions

 BitFileReader (FileInfo file)
 Create a BIT reader for the specified disk file.
 
 BitFileReader (Stream inputStream)
 Create a BIT file reader for the specified stream.
 
IList< BitFileRead (bool shouldReadBulkData=true)
 Read all BIT files from the stream.
 
void ReadData (IList< BitFile > bitFiles)
 Read data from a set of BIT files where the metadata has already been read.
 

Static Public Member Functions

static double IsBitFile (FileInfo file, byte[] content)
 Get the probability that the specified file is a BIT file.
 

Detailed Description

Class for reading BIT log files.

Typical usage:

    BitFileReader reader = new BitFileReader(new FileInfo("path/to/file.BIT"));
    IList<BitFile> bitFiles = reader.Read(true);

If the curve data is not needed, it is possible to read only the metadata from the disk file. The curve data may be filled in later:

    BitFileReader reader = new BitFileReader(new FileInfo("path/to/file.BIT"));
    IList<BitFile> bitFiles = reader.Read(false);

    reader.ReadData(bitFiles);

Note that even if only metadata is read, all sub-files and curve information are properly established as this information comes from metadata. Only the curve values will be missing.

Author
Petroware AS

Constructor & Destructor Documentation

◆ BitFileReader() [1/2]

BitFileReader ( Stream inputStream)

Create a BIT file reader for the specified stream.

Parameters
inputStreamStream to read. Non-null.
Exceptions
ArgumentNullExceptionIf inputStream is null.

◆ BitFileReader() [2/2]

BitFileReader ( FileInfo file)

Create a BIT reader for the specified disk file.

Parameters
fileDisk file to read. Non-null.
Exceptions
ArgumentNullExceptionIf file is null.

Member Function Documentation

◆ IsBitFile()

static double IsBitFile ( FileInfo file,
byte[] content )
static

Get the probability that the specified file is a BIT file.

The check can be done with or without considering the content of the file. In the latter case, only the file name (typically its extension) is considered. In the former case a portion from the start of the file is used to match for known patterns. By passing the portion as an argument, the client code can read this once and then pass it to different classifiers in order to determine its most likely type.

Getting a portion of a file can be done by:

    FileInfo file = ...;
    BinaryReader reader = new BinaryReader(file.OpenRead());
    byte[] content = new byte[2000]; //say
    reader.Read(content, 0, content.Length);
    reader.Close();
Parameters
fileFile to check. Null to classify on content only.
contentA number of bytes from the start of the file. Null to classify on file name only.
Returns
Probability that the file is a BIT file. [0.0,1.0].

◆ Read()

IList< BitFile > Read ( bool shouldReadBulkData = true)

Read all BIT files from the stream.

Parameters
shouldReadBulkDataIndicate if bulk data should be read. False to read header data only.
Returns
List of the logical BIT files contained in the source.

◆ ReadData()

void ReadData ( IList< BitFile > bitFiles)

Read data from a set of BIT files where the metadata has already been read.

This will preserve the existing BitFile structure in case a BIT file is read in two operations:

    // Read metadata
    IList<BitFile> bitFiles = reader.Read(false);

    // Read the curve data
    reader.ReadData(bitFiles);

There is nothing to gain in performance with this approach so in case the result is not cached, the following will be equivalent:

    // Read metadata
    List<BitFile> bitFiles = reader.Read(false);

    // Read the curve data
    bitFiles = reader.Read(true);
Parameters
bitFilesBIT files to populate with curve data.
Exceptions
ArgumentNullExceptionIf bitFiles is null.
ArgumentExceptionIf bitFiles is incompatible with the present disk file.

The documentation for this class was generated from the following file: