glasio

package module
v0.0.0-...-5da5292 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

README

golang las library

(c) softlandia@gmail.com

download: go get -u github.com/softlandia/glasio
install: go install

The library makes it easy to read or write data in LAS format. The main reason for the development was the need to read and standardize a large number of LAS files obtained from various sources

Features:

  1. The encoding is determined automatically
  2. On reading perform validation of the key parameters and integrity of the structure LAS file
  3. Messages are generated for all inconsistencies:
    • zero value of important parameters
    • depth step change in data section
    • lack of curves section
    • conversion errors to a numerical value
    • mismatch of the step parameter declared in the header to the actual
    • duplication of curve names
  4. Excluding critical errors, the library allows you to read the file and get data
  5. Saving a file ensures the integrity of the structure and its readability for most other programs
  6. It is possible to specify a dictionary of standard mnemonics; when reading a file, messages about curves that do not match the specified ones will be generated
  7. It is possible to specify a dictionary of automatic substitution of mnemonics, respectively, curves with the given names will be renamed

Wrapped (WRAP) las files are not supported

dependences

  • github.com/softlandia/cpd
  • github.com/softlandia/xlib

examples

simple

  • make empty LAS file
  • reads sample file "expand_points_01.las", write md file with messages
  • saves the recovered LAS file "expand_points_01+.las"

repaire

  • reads all LAS files in current folder
  • saves the recovered files to the same folder

lasin

  • reads LAS file
  • print warning

tests

coverage 91%
The "data" folder contains files for testing, no remove/change/add

technical info

how type Las store data

access to main parameters:
las.VERS()
las.WRAP()
las.STEP()
las.STRT()
las.STOP()
las.NULL()
las.WELL()

number of points and curves:
las.NumPoints() - number of points len(las.Logs) - number of curves

access to curves and data:
las.Logs[0].D[0] - first depth
las.Logs[1].V[100] - value of first curve on 101 depth step
las.Logs[2].Name - name of second curve
las.Logs[2].Unit - unit of second curve
las.Logs[2].Mnemonic - mnemonic of second curve, the value is determined if the dictionary was applied

if las file contains duplication of any parameter, then use the first in curve section used all curves name. The subsequent duplicated parameter is renamed.

warnings generated when reading a LAS file

warning format

extended:

x, y, "message text"
x - section number
y - line number of input file

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ExpPoints - первоначальный размер слайсов для хранения данных Logs.D и Logs.V
	// ожидаемое количество точек данных, до чтения мы не можем знать сколько точек будет фактически прочитано
	// данные увеличиваются при необходимости и обрезаются после окончания чтения
	ExpPoints int = 1000
	// StdNull - пустое значение
	StdNull float64 = -999.25
	// MaxWarningCount - слишком много сообщений писать смысла нет
	MaxWarningCount int = 20
)
View Source
var (
	RecordSeparator = "\n"
	FieldSeparator  = ","
)

separators for output Warnings to string

Functions

func ParseCurveStr

func ParseCurveStr(s string) (f [3]string)

ParseCurveStr - parse input string to 3 separated string " пс повт . мВ : 7 кр сам"

^^^^^^^   ^^        ^^^^^^^^
name      unit      description

f[2] - description f[1] - unit f[0] - name

func ParseParamStr

func ParseParamStr(s string) (f [4]string)

ParseParamStr - parse string from las file return slice with 4 string and error if occure before process input string 2 or more space replace on 1 space sample "NULL . -9999.00 : Null value" f[0] - name f[1] - unit f[2] - value f[3] - description

func PrepareParamStr

func PrepareParamStr(s string) string

PrepareParamStr - prepare string to parse, replace many space to one, replace tab to space, replace combination of separator to one

Types

type Check

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

Check - конкретная проверка, обязан реализовать функцию doCheck()

type CheckRes

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

CheckRes - результаты проверки, получааем из функции doCheck() если проверка не прошла, то res будет false и в warning будет положено предупреждение для логов в критических случаях err != nil и в себе содержит сообщение, при этом warning содержит соответствующее предупреждение для логов если err == nil то это не критичная проверка

func (CheckRes) String

func (cr CheckRes) String() string

type CheckResults

type CheckResults map[string]CheckRes

CheckResults - map с результатами всех проверок

type Checker

type Checker map[string]Check

Checker - ПРОВЕРЩИК, содержит в себе всех отдельных проверщиков, методом check() вызавает последовательно всех своих проверщиков, результаты отправляет в Logger

func NewStdChecker

func NewStdChecker() Checker

NewStdChecker - создание нового ПРОВЕРЩИКА las файла. WRAP = ON section ~Curve is empty STEP == 0 NULL == 0 STRT == STOP WELL is empty

type HeaderParam

type HeaderParam struct {
	Val      string // parameter value
	Name     string // name of parameter: STOP, WELL, SP - curve name also, also matches the key used in storage
	IName    string
	Unit     string // unit of parameter
	Mnemonic string
	Desc     string // description of parameter
	// contains filtered or unexported fields
}

HeaderParam - class to store parameter from any section universal type for store any header parameters use for store parameters from sections ~V, ~W and other for curves used inherited type LasCurve

func NewCurveHeaderParam

func NewCurveHeaderParam(s string, i int) *HeaderParam

NewCurveHeaderParam - create new object LasParam STRT. m 10.0 : start field[0] field[1] field[2] field[3]

func NewHeaderParam

func NewHeaderParam(s string, i int) *HeaderParam

NewHeaderParam - create new object LasParam STRT. m 10.0 : start field[0] field[1] field[2] field[3]

type HeaderSection

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

HeaderSection - contain parameters of Well section

func NewCurSection

func NewCurSection() HeaderSection

NewCurSection - create section ~C

func NewOthSection

func NewOthSection() HeaderSection

NewOthSection - create section ~O

func NewParSection

func NewParSection() HeaderSection

NewParSection - create section ~P

func NewVerSection

func NewVerSection() HeaderSection

NewVerSection - create section ~V

func NewWelSection

func NewWelSection() HeaderSection

NewWelSection - create section ~W

type Las

type Las struct {
	FileName string    // file name from load
	File     *os.File  // the file from which we are reading
	Reader   io.Reader // reader created from File, provides decode from codepage to UTF-8

	Logs     LasCurves          // store all logs
	LogDic   *map[string]string // external dictionary of standart log name - mnemonics
	VocDic   *map[string]string // external vocabulary dictionary of log mnemonic
	Warnings TLasWarnings       // slice of warnings occure on read or write

	VerSec,
	WelSec,
	CurSec,
	ParSec,
	OthSec HeaderSection
	// contains filtered or unexported fields
}

Las - class to store las file input code page autodetect at read file the code page is converted to UTF at save file code page converted to specifyed in Las.oCodepage TODO add pointer to cfg TODO при создании объекта las есть возможность указать кодировку записи, нужна возможность указать явно кодировку чтения

func LoadLasHeader

func LoadLasHeader(fileName string) (*Las, error)

LoadLasHeader - utility function, if need read only header without data read header as is not repaire any parameters: step, stop, etc...

func NewLas

func NewLas(outputCP ...cpd.IDCodePage) *Las

NewLas - make new object Las class autodetect code page at load file code page to save by default is cpd.CP1251

func (*Las) Dept

func (las *Las) Dept() []float64

Dept - return slice of DEPT curve (first column)

func (*Las) GetMnemonic

func (las *Las) GetMnemonic(logName string) string

GetMnemonic - return Mnemonic from dictionary by Log Name, if Mnemonic not found return "" if Dictionary is nil, then return ""

func (*Las) GetRows

func (las *Las) GetRows() []string

GetRows - get internal field 'rows'

func (*Las) GetStepFromData

func (las *Las) GetStepFromData() float64

GetStepFromData - return step from data section read 2 line from section ~A and determine step close file return Null if error occure

func (*Las) GetStrtFromData

func (las *Las) GetStrtFromData() float64

GetStrtFromData - return strt from data section read 1 line from section ~A and determine strt close file return Null if error occurs

func (*Las) IsEmpty

func (las *Las) IsEmpty() bool

IsEmpty - test to not initialize object

func (*Las) IsStepEmpty

func (las *Las) IsStepEmpty() bool

IsStepEmpty - return true if parameter Step not exist in file

func (*Las) IsStopEmpty

func (las *Las) IsStopEmpty() bool

IsStopEmpty - return true if parameter Stop not exist in file

func (*Las) IsStrtEmpty

func (las *Las) IsStrtEmpty() bool

IsStrtEmpty - return true if parameter Strt not exist in file

func (*Las) IsWraped

func (las *Las) IsWraped() bool

IsWraped - return true if WRAP == YES

func (*Las) Load

func (las *Las) Load(reader io.Reader) (int, error)

Load - load las from reader you can make reader from string or other containers and send as input parameters

func (*Las) LoadDataSec

func (las *Las) LoadDataSec(m int) (int, error)

LoadDataSec - read data section from rows

func (*Las) LoadHeader

func (las *Las) LoadHeader() (int, error)

LoadHeader - read las file and load all section before ~A

returns the row number with which the data section begins, until return nil in any case

1. читаем строку 2. если коммент или пустая в игнор 3. если начало секции, определяем какой 4. если началась секция данных заканчиваем 5. читаем одну строку (это один параметер из известной нам секции)

func (*Las) NULL

func (las *Las) NULL() float64

NULL - return null value of las file as float64 if parameter NULL in las file not exist, then return StdNull (by default -999.25)

func (*Las) NumPoints

func (las *Las) NumPoints() int

NumPoints - return actually number of points in data

func (*Las) Open

func (las *Las) Open(fileName string) (int, error)

Open - read las file

func (*Las) ReadRows

func (las *Las) ReadRows() int

ReadRows - reads to buffer 'rows' and return total count of read lines

func (*Las) STEP

func (las *Las) STEP() float64

STEP - return depth step value of las file as float64 if parameter not exist, then return StdNull (by default -999.25)

func (*Las) STOP

func (las *Las) STOP() float64

STOP - return depth stop value of las file as float64 if parameter STOP in las file not exist, then return StdNull (by default -999.25)

func (*Las) STRT

func (las *Las) STRT() float64

STRT - return depth start value of las file as float64 if parameter NULL in las file not exist, then return StdNull (by default -999.25)

func (*Las) Save

func (las *Las) Save(fileName string, useMnemonic ...bool) error

Save - save to file rewrite if file exist if useMnemonic == true then on save using std mnemonic on ~Curve section TODO las have field filename of readed las file, after save filename must update or not? warning occure on write for what file?

func (*Las) SaveToBuf

func (las *Las) SaveToBuf(useMnemonic bool) ([]byte, error)

SaveToBuf - save to file rewrite if file exist if useMnemonic == true then on save using std mnemonic on ~Curve section ir return err != nil then fatal error, returned slice is not full corrected

func (*Las) SaveWarning

func (las *Las) SaveWarning(fileName string) error

SaveWarning - save to file all warning

func (*Las) SaveWarningToFile

func (las *Las) SaveWarningToFile(oFile *os.File) int

SaveWarningToFile - store all warning to file, file not close. return count warning written

func (*Las) SaveWarningToWriter

func (las *Las) SaveWarningToWriter(writer *bufio.Writer) int

SaveWarningToWriter - store all warning to writer, return count lines written to

func (*Las) SetNull

func (las *Las) SetNull(null float64)

SetNull - change parameter NULL in WELL INFO section and in all logs

func (*Las) VERS

func (las *Las) VERS() float64

VERS - return version of las file as float64 if parameter VERS in las file not exist, then return 2.0

func (*Las) WELL

func (las *Las) WELL() string

WELL - return well name if parameter WELL in las file not exist, then return "--"

func (*Las) WRAP

func (las *Las) WRAP() string

WRAP - return wrap parameter of las file if parameter not exist, then return "NO"

type LasCurve

type LasCurve struct {
	HeaderParam
	Index int
	D     []float64
	V     []float64
}

LasCurve - class to store one log in Las

func NewLasCurve

func NewLasCurve(s string, las *Las) LasCurve

NewLasCurve - create new object LasCurve s - string from las header las - pointer to container

func (*LasCurve) Cmp

func (o *LasCurve) Cmp(curve LasCurve) (res bool)

Cmp - compare current curve with another не сравниваются хранящиеся числовые данные (сам каротаж), только описание кривой, также не сравнивается индекс for deep comparison with all data points stored in the container use DeepCmp

func (*LasCurve) SetLen

func (o *LasCurve) SetLen(n int)

SetLen - crop logs to actually len new len must be > 0 and < exist length

func (LasCurve) String

func (o LasCurve) String() string

String - return LasCurve as string

type LasCurves

type LasCurves []LasCurve

LasCurves - container to store all curves of las file .Cmp(curves *LasCurves) bool - compare two curves containers

func (LasCurves) Captions

func (curves LasCurves) Captions() string

Captions - return string represents all curve names with separators for las file use as comment string after section ~A

func (LasCurves) Cmp

func (curves LasCurves) Cmp(otheCurves LasCurves) (res bool)

Cmp - compare current curves container with another сравниваются:

количество кривых в контейнере
два хеша от строк с именами всех кривых

func (LasCurves) IsPresent

func (curves LasCurves) IsPresent(curveName string) bool

IsPresent - return true if curveName is already present in container

func (LasCurves) UniqueName

func (curves LasCurves) UniqueName(curveName string) string

UniqueName - make new unique name of curve if it duplicated

type Logger

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

Logger - store log info about the one las, fills up info from las.open() and las.check()

func LasCheck

func LasCheck(filename string) *Logger

LasCheck - read and check las file, return object with all warnings считывает файл и собирает все сообщения в один объект это базовая проверка las файла, прелесть в том что здесь собираются сообщения от прочтения файла

func LasDeepCheck

func LasDeepCheck(filename, mnemonicFile, vocdicFile string) (*Logger, error)

LasDeepCheck - read and check las file, curve name checked to mnemonic, return object with all warnings считывает файл и собирает все сообщения в один объект

func NewLogger

func NewLogger(las *Las) *Logger

NewLogger - constructor

type ParseHeaderParam

type ParseHeaderParam func(s string, i int) (HeaderParam, TWarning)

ParseHeaderParam - function to parse one line of header return new of added parameter and warning on success TWarning.Empty() == true s - string readed from source file i - number of line in source file

type TLasWarnings

type TLasWarnings []TWarning

TLasWarnings - class to store and manipulate warnings Count() - return warnings count SaveWarning(fileName string) error SaveWarningToWriter(writer *bufio.Writer) int SaveWarningToFile(oFile *os.File) int ToString() string for i, w := range obj {w.ToString()} - перебор всех варнингов

func (TLasWarnings) Count

func (w TLasWarnings) Count() int

Count - return number of element

func (*TLasWarnings) SaveWarning

func (w *TLasWarnings) SaveWarning(fileName string) error

SaveWarning - save to file all warning file created and closed

func (*TLasWarnings) SaveWarningToFile

func (w *TLasWarnings) SaveWarningToFile(oFile *os.File) int

SaveWarningToFile - store all warning to file, file not close. return count warning writed

func (*TLasWarnings) SaveWarningToWriter

func (w *TLasWarnings) SaveWarningToWriter(writer *bufio.Writer) int

SaveWarningToWriter - store all warning to writer return count lines writed to

func (*TLasWarnings) ToString

func (w *TLasWarnings) ToString(sep ...string) string

ToString - make one string from all elements sep[0] - record separator разделитель записей sep[1] - field separator разделитель полей default separator between field "," between record "\n" on empty container return ""

type TMnemonic

type TMnemonic = map[string]string

TMnemonic - dictionary of std log name == mnemonics

func LoadStdMnemonicDic

func LoadStdMnemonicDic(fileName ...string) (TMnemonic, error)

LoadStdMnemonicDic - return std mnemonic map read ini file, fill dictionary return empty map if occure error on reading ini file with dictionary, may be add after

type TVocDic

type TVocDic = map[string]string

TVocDic - dictionary of std log name == mnemonics

func LoadStdVocabularyDictionary

func LoadStdVocabularyDictionary(fileName ...string) (TVocDic, error)

LoadStdVocabularyDictionary - return lookup map read ini file, fill dictionary return empty map if occure error on reading ini file with dictionary, may be add after

type TWarning

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

TWarning - class to store warning

func (TWarning) Empty

func (w TWarning) Empty() bool

Empty - return true if warning is empty

func (TWarning) String

func (w TWarning) String() string

String - return string with warning

func (*TWarning) ToCsvString

func (w *TWarning) ToCsvString(sep ...string) string

ToCsvString - return string with warning field TWarning.direct do not write to string

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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