lasgo

package module
v0.5.3-0...-4c87966 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 12 Imported by: 0

README

las-go is a GoLang library/package for parsing .Las file (Geophysical well log files).

Currently supports only version 2.0 of LAS Specification. For more information about this format, see the Canadian Well Logging Society product page.

How to use

  • Installing

    GO GET

      go get github.com/laslibs/las-go
    
  • Test

      go test ./...
    
  • Usage

    import (
      lasgo "github.com/laslibs/las-go"
    )
    
  • Read data

    Use Las.Data() to get a 2-dimensional slice containing the readings of each log

        func main() {
        las, err := lasgo.Las("sample/A10.las")
        if err != nil {
          panic(err)
        }
        fmt.Println(las.Data())
      /**
         [[2650.0 177.825 -999.25 -999.25],
          [2650.5 182.5 -999.25-999.25]
          [2651.0180.162 -999.25 -999.25]
          [2651.5 177.825 -999.25 -999.25]
          [2652.0 177.825 -999.25 -999.25] ...]
        */
       }
    
  • Get the log headers

        // ...
        headers := las.Header();
        fmt.Println(headers);
        // [DEPTH GR NPHI RHOB]
        // ...
    
  • Get the log headers descriptions as map[string]string

        //...
        headerAndDesc := las.headerAndDesc()
        fmt.Println(headerAndDesc)
        // [DEPTH: DEPTH GR: Gamma Ray NPHI: Neutron Porosity RHOB: Bulk density]
        // ...
    
  • Get a particular column, say Gamma Ray log

        // ...
        gammaRay := las.Column("GR");
        fmt.Println(gammaRay);
        // [-999.25 -999.25 -999.25 -999.25 -999.25 122.03 123.14 ...]
        // ...
    
  • Get the Well Parameters

    Presents a way of accessing the details of individual well parameters.
    The details include the following:
      1. description - Description/ Full name of the well parameter
      2. unit - Its unit of measurement
      3. value - Value measured
    
      // ...
      well := las.WellParams()
      start := well["STRT"].value // 1670.0
      stop := well["STOP"].value // 1669.75
      null_value := well["NULL"].value //  -999.25
      // Any other well parameter present in the file, can be gotten with the same syntax above
      // ...
    
  • Get the Curve Parameters

    Presents a way of accessing the details of individual log columns.
    The details include the following:
      1. description - Description/ Full name of the log column
      2. unit - Unit of the log column measurements
      3. value - API value of the log column
    
      // ...
      curve := las.CurveParams()
      NPHI := curve["NPHI"].description // Neutron Porosity
      RHOB := curve["RHOB"].description // Bulk density
      // This is the same for all log column present in the file
      // ...
    
  • Get the Parameters of the well

    The details include the following:
      1. description - Description/ Full name of the log column
      2. unit - Unit of the log column measurements
      3. value - API value of the log column
    
      // ...
      param := await las.LogParams(); // BOTTOM HOLE TEMPERATURE
      BHT := param["BHT"].description // BOTTOM HOLE TEMPERATURE
      BHTValaue := param["BHT"].value // 35.5
      BHTUnits := param["BHT"].unit // DEGC
      // This is the same for all well parameters present in the file
      // ...
    
  • Get the number of rows and columns

        // ...
        numRows := las.RowCount() // 4
        numColumns := las.ColumnCount() // 3081
        // ...
    
  • Get the version and wrap

        // ...
        version := las.Version() // 2.0
        wrap := las.Wrap() // true
        // ...
    
  • Get other information

        // ...
        other := myLas.Other()
        fmt.Println(other)
        // Note: The logging tools became stuck at 625 metres causing the data between 625 metres and 615 metres to be invalid.
        // ...
    
  • Export to CSV

    This writes a csv file to the current working directory, with headers of the well and data section
        //...
        las.ToCSV("result")
        //...
    

    result.csv

    DEPT RHOB GR NPHI
    0.5 -999.25 -999.25 -0.08
    1.0 -999.25 -999.25 -0.08
    1.5 -999.25 -999.25 -0.04
    ... ... ... ...
    1.3 -999.25 -999.25 -0.08

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataOptions

type DataOptions struct {
	// ConcreteStruct can be set to any concrete struct (not a pointer).
	// When set, the mapstructure package is used to convert the returned
	// results automatically from a map to a struct. The `dbq` struct tag
	// can be used to map column names to the struct's fields.
	//
	// See: https://godoc.org/github.com/mitchellh/mapstructure
	ConcreteStruct interface{}

	// DecoderConfig is used to configure the decoder used by the mapstructure
	// package. If it's not supplied, a default StructorConfig is assumed. This means
	// WeaklyTypedInput is set to true and no DecodeHook is provided.
	//
	// See: https://godoc.org/github.com/mitchellh/mapstructure
	DecoderConfig *StructorConfig

	// ConcurrentPostUnmarshal can be set to true if PostUnmarshal must be called concurrently.
	ConcurrentPostUnmarshal bool
}

DataOptions is used to modify the default behavior.

type LasType

type LasType struct {
	// contains filtered or unexported fields
}

LasType is the main type definition

func Las

func Las(path string) (*LasType, error)

Las creates an instance of LasType

func (*LasType) Column

func (l *LasType) Column(key string) []string

Column returns entry of an individual log, say gamma ray

func (*LasType) ColumnCount

func (l *LasType) ColumnCount() (count int)

ColumnCount - Returns the number of columns in a .las file

func (*LasType) CurveParams

func (l *LasType) CurveParams() map[string]WellProps

CurveParams - Returns Curve Parameters

func (*LasType) Data

func (l *LasType) Data() [][]string

Data returns the data section in the file

func (*LasType) DataStruct

func (l *LasType) DataStruct(opt *DataOptions) []interface{}

DataStruct just like Data but returns output in specified struct format

func (*LasType) Header

func (l *LasType) Header() ([]string, error)

Header - returns the header in the las file

func (*LasType) HeaderAndDesc

func (l *LasType) HeaderAndDesc() map[string]string

HeaderAndDesc return the name and description of each log entry

func (*LasType) LogParams

func (l *LasType) LogParams() map[string]WellProps

LogParams - Returns Log Parameters

func (*LasType) Other

func (l *LasType) Other() string

Other returns extra information stored in ~other section

func (*LasType) RowCount

func (l *LasType) RowCount() (count int)

RowCount - Returns the number of rowa in a .las file

func (*LasType) ToCSV

func (l *LasType) ToCSV(filename string)

ToCSV creates a csv file using data and header

func (*LasType) Version

func (l *LasType) Version() (version string)

Version - returns the version of the las file

func (*LasType) WellParams

func (l *LasType) WellParams() map[string]WellProps

WellParams - Returns Overrall Well Parameters

func (*LasType) Wrap

func (l *LasType) Wrap() (wrap bool)

Wrap - returns the version of the las file

type PostUnmarshaler

type PostUnmarshaler interface {

	// PostUnmarshal is called for each row after all results have been fetched.
	// You can use it to further modify the values of each ConcreteStruct.
	PostUnmarshal(ctx context.Context, row, count int) error
}

PostUnmarshaler allows you to further modify all results after unmarshaling. The ConcreteStruct pointer must implement this interface to make use of this feature.

type StructorConfig

type StructorConfig struct {

	// DecodeHook, if set, will be called before any decoding and any
	// type conversion (if WeaklyTypedInput is on). This lets you modify
	// the values before they're set down onto the resulting struct.
	//
	// If an error is returned, the entire decode will fail with that
	// error.
	DecodeHook mapstructure.DecodeHookFunc

	// If WeaklyTypedInput is true, the decoder will make the following
	// "weak" conversions:
	//
	//   - bools to string (true = "1", false = "0")
	//   - numbers to string (base 10)
	//   - bools to int/uint (true = 1, false = 0)
	//   - strings to int/uint (base implied by prefix)
	//   - int to bool (true if value != 0)
	//   - string to bool (accepts: 1, t, T, TRUE, true, True, 0, f, F,
	//     FALSE, false, False. Anything else is an error)
	//   - empty array = empty map and vice versa
	//   - negative numbers to overflowed uint values (base 10)
	//   - slice of maps to a merged map
	//   - single values are converted to slices if required. Each
	//     element is weakly decoded. For example: "4" can become []int{4}
	//     if the target type is an int slice.
	//
	WeaklyTypedInput bool
}

StructorConfig is used to expose a subset of the configuration options provided by the mapstructure package.

See: https://godoc.org/github.com/mitchellh/mapstructure#DecoderConfig

type WellProps

type WellProps struct {
	// contains filtered or unexported fields
}

WellProps contains basic definition of a single well measurement

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL