Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Data Flow
Data Loading
Wellbore DDMS Data Loader
Commits
1f7d1293
Commit
1f7d1293
authored
Feb 28, 2022
by
Niall McDaid
Browse files
rename file_load to parse
parent
5bf359ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/wbdutil/commands/
file_load
.py
→
src/wbdutil/commands/
parse
.py
View file @
1f7d1293
from
pathlib
import
Path
from
knack.log
import
get_logger
from
..environment_var_helper
import
EnvironmentVarHelper
from
..file_loader
import
LasParser
,
LocalFileLoader
,
FileUtilities
from
..record_mapper
import
LasToRecordMapper
from
..configuration
import
Configuration
from
..json_writer
import
JsonToFile
logger
=
get_logger
(
__name__
)
def
printlas
(
input_path
):
"""
Print a LAS file header
:param str input_path: Path and filename of a LAS file or folder containing LAS files
"""
las_parser
=
LasParser
(
LocalFileLoader
())
logger
.
info
(
f
"LAS path:
{
input_path
}
"
)
for
file_path
in
FileUtilities
.
get_filenames
(
Path
(
input_path
),
'.las'
):
logger
.
warning
(
f
"LAS file:
{
file_path
}
"
)
las_data
=
las_parser
.
load_las_file
(
file_path
)
print
(
las_data
.
header
)
def
convert
(
input_path
:
str
,
wellbore_id
:
str
,
config_path
:
str
=
None
):
"""
Convert a LAS file to Wellbore and Well Log and write to json files.
:param str input_path: Path and filename of a LAS file or folder containing LAS files
:param str wellbore_id: The wellbore id
:param str config_path: Path to the configuration file
"""
config_path
=
EnvironmentVarHelper
.
get_config_path
(
config_path
)
las_parser
=
LasParser
(
LocalFileLoader
())
config
=
Configuration
(
LocalFileLoader
(),
config_path
)
logger
.
info
(
f
"LAS path:
{
input_path
}
"
)
for
file_path
in
FileUtilities
.
get_filenames
(
Path
(
input_path
),
'.las'
):
logger
.
warning
(
f
"LAS file:
{
file_path
}
"
)
las_data
=
las_parser
.
load_las_file
(
file_path
)
mapper
=
LasToRecordMapper
(
las_data
,
config
)
wellbore_record
=
mapper
.
map_to_wellbore_record
()
welllog_record
=
mapper
.
map_to_well_log_record
(
wellbore_id
)
path
=
Path
(
file_path
)
writer
=
JsonToFile
()
writer
.
write
(
vars
(
wellbore_record
),
path
.
with_suffix
(
'.wellbore.json'
))
logger
.
warning
(
f
"Wellbore record file created:
{
path
.
with_suffix
(
'.wellbore.json'
)
}
"
)
writer
.
write
(
vars
(
welllog_record
),
path
.
with_suffix
(
'.welllog.json'
))
logger
.
warning
(
f
"Well log record file created:
{
path
.
with_suffix
(
'.welllog.json'
)
}
"
)
from
pathlib
import
Path
from
knack.log
import
get_logger
from
..environment_var_helper
import
EnvironmentVarHelper
from
..file_loader
import
LasParser
,
LocalFileLoader
,
FileUtilities
from
..record_mapper
import
LasToRecordMapper
from
..configuration
import
Configuration
from
..json_writer
import
JsonToFile
logger
=
get_logger
(
__name__
)
def
printlas
(
input_path
):
"""
Print a LAS file header
:param str input_path: Path and filename of a LAS file or folder containing LAS files
"""
las_parser
=
LasParser
(
LocalFileLoader
())
logger
.
info
(
f
"LAS path:
{
input_path
}
"
)
for
file_path
in
FileUtilities
.
get_filenames
(
Path
(
input_path
),
'.las'
):
logger
.
warning
(
f
"LAS file:
{
file_path
}
"
)
las_data
=
las_parser
.
load_las_file
(
file_path
)
print
(
las_data
.
header
)
def
convert
(
input_path
:
str
,
wellbore_id
:
str
,
config_path
:
str
=
None
):
"""
Convert a LAS file to Wellbore and Well Log and write to json files.
:param str input_path: Path and filename of a LAS file or folder containing LAS files
:param str wellbore_id: The wellbore id
:param str config_path: Path to the configuration file
"""
config_path
=
EnvironmentVarHelper
.
get_config_path
(
config_path
)
las_parser
=
LasParser
(
LocalFileLoader
())
config
=
Configuration
(
LocalFileLoader
(),
config_path
)
logger
.
info
(
f
"LAS path:
{
input_path
}
"
)
for
file_path
in
FileUtilities
.
get_filenames
(
Path
(
input_path
),
'.las'
):
logger
.
warning
(
f
"LAS file:
{
file_path
}
"
)
las_data
=
las_parser
.
load_las_file
(
file_path
)
mapper
=
LasToRecordMapper
(
las_data
,
config
)
wellbore_record
=
mapper
.
map_to_wellbore_record
()
welllog_record
=
mapper
.
map_to_well_log_record
(
wellbore_id
)
path
=
Path
(
file_path
)
writer
=
JsonToFile
()
writer
.
write
(
vars
(
wellbore_record
),
path
.
with_suffix
(
'.wellbore.json'
))
logger
.
warning
(
f
"Wellbore record file created:
{
path
.
with_suffix
(
'.wellbore.json'
)
}
"
)
writer
.
write
(
vars
(
welllog_record
),
path
.
with_suffix
(
'.welllog.json'
))
logger
.
warning
(
f
"Well log record file created:
{
path
.
with_suffix
(
'.welllog.json'
)
}
"
)
src/wbdutil/wbdutil.py
View file @
1f7d1293
...
...
@@ -34,7 +34,7 @@ class DdmsCommandLoader(CLICommandsLoader):
def
load_command_table
(
self
,
args
):
"""Load all commands"""
with
CommandGroup
(
self
,
'
fileload
'
,
MODULE_NAME
+
'.commands.
file_load
#{}'
)
as
group
:
with
CommandGroup
(
self
,
'
parse
'
,
MODULE_NAME
+
'.commands.
parse
#{}'
)
as
group
:
group
.
command
(
'convert'
,
'convert'
)
group
.
command
(
'print'
,
'printlas'
)
...
...
@@ -66,11 +66,11 @@ class DdmsCommandLoader(CLICommandsLoader):
help
=
'''The path and filename of the configuration file.
Defaults to
\'
CONFIGPATH
\'
environment variable if not set.'''
)
# '
fileload
'
with
ArgumentsContext
(
self
,
'
fileload
'
)
as
arg_context
:
# '
parse
'
with
ArgumentsContext
(
self
,
'
parse
'
)
as
arg_context
:
self
.
_register_input_path_argument
(
arg_context
)
with
ArgumentsContext
(
self
,
'
fileload
convert'
)
as
arg_context
:
with
ArgumentsContext
(
self
,
'
parse
convert'
)
as
arg_context
:
self
.
_register_wellbore_id_flag
(
arg_context
)
# 'ingest'
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment