-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from kinverarity1/refactor
Project refactor
- Loading branch information
Showing
11 changed files
with
1,043 additions
and
979 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
from .las import __version__, read, LASFile, CurveItem, HeaderItem, JSONEncoder | ||
from .las import LASFile, JSONEncoder | ||
from .las_items import CurveItem, HeaderItem, SectionItems | ||
from .reader import open_file | ||
|
||
try: | ||
import openpyxl | ||
except ImportError: | ||
pass | ||
else: | ||
from .excel import ExcelConverter | ||
|
||
__version__ = '0.10' | ||
|
||
|
||
def read(file_ref, **kwargs): | ||
'''Read a LAS file. | ||
Note that only versions 1.2 and 2.0 of the LAS file specification | ||
are currently supported. | ||
Arguments: | ||
file_ref: either a filename, an open file object, or a string of | ||
a LAS file contents. | ||
Keyword Arguments: | ||
encoding (str): character encoding to open file_ref with | ||
encoding_errors (str): 'strict', 'replace' (default), 'ignore' - how to | ||
handle errors with encodings (see standard library codecs module or | ||
Python Unicode HOWTO for more information) | ||
autodetect_encoding (bool): use chardet/ccharet to detect encoding | ||
autodetect_encoding_chars (int/None): number of chars to read from LAS | ||
file for auto-detection of encoding. | ||
Returns: | ||
A LASFile object representing the file -- see above | ||
''' | ||
return LASFile(file_ref, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
import numpy as np | ||
|
||
from .las_items import ( | ||
HeaderItem, CurveItem, SectionItems, OrderedDict | ||
) | ||
|
||
|
||
DEFAULT_ITEMS = { | ||
'Version': SectionItems([ | ||
HeaderItem('VERS', '', 2.0, 'CWLS log ASCII Standard -VERSION 2.0'), | ||
HeaderItem('WRAP', '', 'NO', 'One line per depth step'), | ||
HeaderItem('DLM', '', 'SPACE', 'Column Data Section Delimiter'), | ||
]), | ||
'Well': SectionItems([ | ||
HeaderItem('STRT', 'm', np.nan, 'START DEPTH'), | ||
HeaderItem('STOP', 'm', np.nan, 'STOP DEPTH'), | ||
HeaderItem('STEP', 'm', np.nan, 'STEP'), | ||
HeaderItem('NULL', '', -9999.25, 'NULL VALUE'), | ||
HeaderItem('COMP', '', '', 'COMPANY'), | ||
HeaderItem('WELL', '', '', 'WELL'), | ||
HeaderItem('FLD', '', '', 'FIELD'), | ||
HeaderItem('LOC', '', '', 'LOCATION'), | ||
HeaderItem('PROV', '', '', 'PROVINCE'), | ||
HeaderItem('CNTY', '', '', 'COUNTY'), | ||
HeaderItem('STAT', '', '', 'STATE'), | ||
HeaderItem('CTRY', '', '', 'COUNTRY'), | ||
HeaderItem('SRVC', '', '', 'SERVICE COMPANY'), | ||
HeaderItem('DATE', '', '', 'DATE'), | ||
HeaderItem('UWI', '', '', 'UNIQUE WELL ID'), | ||
HeaderItem('API', '', '', 'API NUMBER') | ||
]), | ||
'Curves': SectionItems([]), | ||
'Parameter': SectionItems([]), | ||
'Other': '', | ||
'Data': np.zeros(shape=(0, 1)), | ||
} | ||
|
||
|
||
ORDER_DEFINITIONS = { | ||
1.2: OrderedDict([ | ||
('Version', ['value:descr']), | ||
('Well', [ | ||
'descr:value', | ||
('value:descr', ['STRT', 'STOP', 'STEP', 'NULL'])]), | ||
('Curves', ['value:descr']), | ||
('Parameter', ['value:descr']), | ||
]), | ||
2.0: OrderedDict([ | ||
('Version', ['value:descr']), | ||
('Well', ['value:descr']), | ||
('Curves', ['value:descr']), | ||
('Parameter', ['value:descr']) | ||
])} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class LASDataError(Exception): | ||
|
||
'''Error during reading of numerical data from LAS file.''' | ||
pass | ||
|
||
|
||
class LASHeaderError(Exception): | ||
|
||
'''Error during reading of header data from LAS file.''' | ||
pass | ||
|
||
|
||
class LASUnknownUnitError(Exception): | ||
|
||
'''Error of unknown unit in LAS file.''' | ||
pass |
Oops, something went wrong.