From 4f09b302495b4db4ff2f45dd0ba32210540ae565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= Date: Fri, 20 Nov 2020 13:26:34 +0100 Subject: [PATCH 01/11] Not configure root logger --- ecl2df/common.py | 3 +-- ecl2df/compdat.py | 2 +- ecl2df/eclfiles.py | 2 +- ecl2df/equil.py | 2 +- ecl2df/faults.py | 3 +-- ecl2df/fipreports.py | 2 +- ecl2df/grid.py | 3 +-- ecl2df/gruptree.py | 3 +-- ecl2df/inferdims.py | 2 +- ecl2df/nnc.py | 3 +-- ecl2df/parameters.py | 3 +-- ecl2df/pillars.py | 2 +- ecl2df/pvt.py | 2 +- ecl2df/rft.py | 2 +- ecl2df/satfunc.py | 2 +- ecl2df/summary.py | 3 +-- ecl2df/trans.py | 3 +-- ecl2df/wcon.py | 2 +- 18 files changed, 18 insertions(+), 26 deletions(-) diff --git a/ecl2df/common.py b/ecl2df/common.py index c9684e490..4d9449ace 100644 --- a/ecl2df/common.py +++ b/ecl2df/common.py @@ -59,9 +59,8 @@ ) -logging.basicConfig() logger = logging.getLogger(__name__) - +logger.addHandler(logging.NullHandler()) def parse_ecl_month(eclmonth): """Translate Eclipse month strings to integer months""" diff --git a/ecl2df/compdat.py b/ecl2df/compdat.py index 6946f68c5..4ec67369e 100644 --- a/ecl2df/compdat.py +++ b/ecl2df/compdat.py @@ -21,8 +21,8 @@ ) from .grid import merge_initvectors -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) """OPM authors and Roxar RMS authors have interpreted the Eclipse documentation ever so slightly different when naming the data. diff --git a/ecl2df/eclfiles.py b/ecl2df/eclfiles.py index ba6a51a12..ea93503ae 100644 --- a/ecl2df/eclfiles.py +++ b/ecl2df/eclfiles.py @@ -17,8 +17,8 @@ from ecl.grid import EclGrid from ecl.summary import EclSum -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) # Default parse option to opm.io for a very permissive parsing OPMIOPARSER_RECOVERY = [ diff --git a/ecl2df/equil.py b/ecl2df/equil.py index b12121657..aa945132d 100644 --- a/ecl2df/equil.py +++ b/ecl2df/equil.py @@ -17,8 +17,8 @@ from ecl2df import inferdims, common from .eclfiles import EclFiles -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) SUPPORTED_KEYWORDS = ["EQUIL", "PBVD", "PDVD", "RSVD", "RVVD"] RENAMERS = {} diff --git a/ecl2df/faults.py b/ecl2df/faults.py index 5d1d4fca8..ed209d967 100644 --- a/ecl2df/faults.py +++ b/ecl2df/faults.py @@ -16,9 +16,8 @@ from .eclfiles import EclFiles from .common import parse_opmio_deckrecord -logging.basicConfig() logger = logging.getLogger(__name__) - +logger.addHandler(logging.NullHandler()) RECORD_COLUMNS = ["NAME", "IX1", "IX2", "IY1", "IY2", "IZ1", "IZ2", "FACE"] COLUMNS = ["NAME", "I", "J", "K", "FACE"] diff --git a/ecl2df/fipreports.py b/ecl2df/fipreports.py index a019cf642..2c989b535 100644 --- a/ecl2df/fipreports.py +++ b/ecl2df/fipreports.py @@ -13,8 +13,8 @@ from .eclfiles import EclFiles from .common import parse_ecl_month -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) REGION_REPORT_COLUMNS = [ "DATE", diff --git a/ecl2df/grid.py b/ecl2df/grid.py index a4a7622f5..fe2291670 100644 --- a/ecl2df/grid.py +++ b/ecl2df/grid.py @@ -31,9 +31,8 @@ from ecl.eclfile import EclFile from .eclfiles import EclFiles -logging.basicConfig() logger = logging.getLogger(__name__) - +logger.addHandler(logging.NullHandler()) def rstdates(eclfiles): """Return a list of datetime objects for the available dates in the RST file""" diff --git a/ecl2df/gruptree.py b/ecl2df/gruptree.py index 724b82dbb..f0f808707 100644 --- a/ecl2df/gruptree.py +++ b/ecl2df/gruptree.py @@ -18,9 +18,8 @@ from .eclfiles import EclFiles from .common import parse_opmio_date_rec, parse_opmio_deckrecord, parse_opmio_tstep_rec -logging.basicConfig() logger = logging.getLogger(__name__) - +logger.addHandler(logging.NullHandler()) def gruptree2df(deck, startdate=None, welspecs=True): """Deprecated function name""" diff --git a/ecl2df/inferdims.py b/ecl2df/inferdims.py index 764fb098a..a4c0bddc8 100644 --- a/ecl2df/inferdims.py +++ b/ecl2df/inferdims.py @@ -14,8 +14,8 @@ from ecl2df import EclFiles -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) # Constants to use for pointing to positions in the xxxDIMS keyword DIMS_POS = dict(NTPVT=1, NTSFUN=0, NTEQUL=0) diff --git a/ecl2df/nnc.py b/ecl2df/nnc.py index 2f6bb5bb2..e8b452c1b 100644 --- a/ecl2df/nnc.py +++ b/ecl2df/nnc.py @@ -14,9 +14,8 @@ from ecl2df import common, EclFiles, grid, __version__ -logging.basicConfig() logger = logging.getLogger(__name__) - +logger.addHandler(logging.NullHandler()) def df(eclfiles, coords=False, pillars=False): """Produce a Pandas Dataframe with NNC information diff --git a/ecl2df/parameters.py b/ecl2df/parameters.py index 9d10a1c36..3c79c2e0f 100644 --- a/ecl2df/parameters.py +++ b/ecl2df/parameters.py @@ -10,9 +10,8 @@ from ecl2df.eclfiles import EclFiles -logging.basicConfig() logger = logging.getLogger(__name__) - +logger.addHandler(logging.NullHandler()) def find_parameter_files(ecldeck_or_eclpath, filebase="parameters"): """Locate a default prioritized list of files to try to read as key-value diff --git a/ecl2df/pillars.py b/ecl2df/pillars.py index d5e914be3..855b8aadd 100644 --- a/ecl2df/pillars.py +++ b/ecl2df/pillars.py @@ -17,8 +17,8 @@ import ecl2df -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) AGGREGATORS = { "VOLUME": "sum", diff --git a/ecl2df/pvt.py b/ecl2df/pvt.py index 5b35a9e86..ec0ca66de 100644 --- a/ecl2df/pvt.py +++ b/ecl2df/pvt.py @@ -16,8 +16,8 @@ from ecl2df import inferdims, common, __version__ from .eclfiles import EclFiles -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) SUPPORTED_KEYWORDS = ["PVTO", "PVDO", "PVTG", "PVDG", "DENSITY", "ROCK", "PVTW"] diff --git a/ecl2df/rft.py b/ecl2df/rft.py index a6914daaf..3e14bbe81 100644 --- a/ecl2df/rft.py +++ b/ecl2df/rft.py @@ -31,8 +31,8 @@ from .common import merge_zones -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) # In debug mode, these columns will be exported to three csv files. CON_TOPOLOGY_COLS = {"CONIDX", "CONBRNO", "CONSEGNO", "CONNXT", "DEPTH"} diff --git a/ecl2df/satfunc.py b/ecl2df/satfunc.py index 635480203..a92f5aa1a 100644 --- a/ecl2df/satfunc.py +++ b/ecl2df/satfunc.py @@ -26,8 +26,8 @@ from ecl2df import inferdims, common from .eclfiles import EclFiles -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) SUPPORTED_KEYWORDS = ["SWOF", "SGOF", "SWFN", "SGWFN", "SOF2", "SGFN", "SOF3", "SLGOF"] diff --git a/ecl2df/summary.py b/ecl2df/summary.py index a49963e4d..19aaeb9db 100644 --- a/ecl2df/summary.py +++ b/ecl2df/summary.py @@ -21,9 +21,8 @@ from .eclfiles import EclFiles from . import parameters -logging.basicConfig() logger = logging.getLogger(__name__) - +logger.addHandler(logging.NullHandler()) def normalize_dates(start_date, end_date, freq): """ diff --git a/ecl2df/trans.py b/ecl2df/trans.py index ce84c84ef..ab77b8f0e 100644 --- a/ecl2df/trans.py +++ b/ecl2df/trans.py @@ -15,9 +15,8 @@ import ecl2df from .eclfiles import EclFiles -logging.basicConfig() logger = logging.getLogger(__name__) - +logger.addHandler(logging.NullHandler()) def df( eclfiles, diff --git a/ecl2df/wcon.py b/ecl2df/wcon.py index 579fd7a4d..1126a6702 100644 --- a/ecl2df/wcon.py +++ b/ecl2df/wcon.py @@ -19,8 +19,8 @@ from .eclfiles import EclFiles from .common import parse_opmio_date_rec, OPMKEYWORDS -logging.basicConfig() logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) # The keywords supported in this module. WCONKEYS = ["WCONHIST", "WCONINJE", "WCONINJH", "WCONPROD"] From 62ea9ae5f9813e30262b6740b3a9ee461cb9e1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= Date: Fri, 20 Nov 2020 13:34:42 +0100 Subject: [PATCH 02/11] black --- ecl2df/common.py | 1 + ecl2df/grid.py | 1 + ecl2df/gruptree.py | 1 + ecl2df/nnc.py | 1 + ecl2df/parameters.py | 1 + ecl2df/trans.py | 1 + 6 files changed, 6 insertions(+) diff --git a/ecl2df/common.py b/ecl2df/common.py index 83a335f14..d49be8bdd 100644 --- a/ecl2df/common.py +++ b/ecl2df/common.py @@ -64,6 +64,7 @@ logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) + def write_dframe_stdout_file( dframe, output, index=False, caller_logger=None, logstr=None ): diff --git a/ecl2df/grid.py b/ecl2df/grid.py index 0c0e4409d..151cc2669 100644 --- a/ecl2df/grid.py +++ b/ecl2df/grid.py @@ -26,6 +26,7 @@ logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) + def get_available_rst_dates(eclfiles): """Return a list of datetime objects for the available dates in the RST file""" report_indices = EclFile.file_report_list(eclfiles.get_rstfilename()) diff --git a/ecl2df/gruptree.py b/ecl2df/gruptree.py index 923dd8d98..5fed65ddd 100644 --- a/ecl2df/gruptree.py +++ b/ecl2df/gruptree.py @@ -23,6 +23,7 @@ logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) + def df(deck, startdate=None, welspecs=True): """Extract all group information from a deck and present as a Pandas Dataframe of all edges. diff --git a/ecl2df/nnc.py b/ecl2df/nnc.py index b94d0cb36..fdd751eff 100644 --- a/ecl2df/nnc.py +++ b/ecl2df/nnc.py @@ -11,6 +11,7 @@ logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) + def df(eclfiles, coords=False, pillars=False): """Produce a Pandas Dataframe with NNC information diff --git a/ecl2df/parameters.py b/ecl2df/parameters.py index 7f199515b..ef0978486 100644 --- a/ecl2df/parameters.py +++ b/ecl2df/parameters.py @@ -13,6 +13,7 @@ logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) + def find_parameter_files(ecldeck_or_eclpath, filebase="parameters"): """Locate a default prioritized list of files to try to read as key-value diff --git a/ecl2df/trans.py b/ecl2df/trans.py index a84958ace..00b8cf163 100644 --- a/ecl2df/trans.py +++ b/ecl2df/trans.py @@ -20,6 +20,7 @@ logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) + def df( eclfiles, vectors=None, From 1dcb50c44066f0f3c3238dda3b6757a3bda2cd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= Date: Tue, 24 Nov 2020 12:35:22 +0100 Subject: [PATCH 03/11] nullhandler --- ecl2df/common.py | 1 - ecl2df/compdat.py | 1 - ecl2df/eclfiles.py | 1 - ecl2df/equil.py | 1 - ecl2df/faults.py | 1 - ecl2df/fipreports.py | 1 - ecl2df/grid.py | 1 - ecl2df/gruptree.py | 1 - ecl2df/inferdims.py | 1 - ecl2df/nnc.py | 1 - ecl2df/parameters.py | 1 - ecl2df/pillars.py | 1 - ecl2df/pvt.py | 1 - ecl2df/rft.py | 1 - ecl2df/satfunc.py | 1 - ecl2df/summary.py | 1 - ecl2df/trans.py | 1 - ecl2df/wcon.py | 1 - 18 files changed, 18 deletions(-) diff --git a/ecl2df/common.py b/ecl2df/common.py index d49be8bdd..0a0b27c19 100644 --- a/ecl2df/common.py +++ b/ecl2df/common.py @@ -62,7 +62,6 @@ logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) def write_dframe_stdout_file( diff --git a/ecl2df/compdat.py b/ecl2df/compdat.py index 35cb203b6..4140d8189 100644 --- a/ecl2df/compdat.py +++ b/ecl2df/compdat.py @@ -18,7 +18,6 @@ from .grid import merge_initvectors logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) """OPM authors and Roxar RMS authors have interpreted the Eclipse documentation ever so slightly different when naming the data. diff --git a/ecl2df/eclfiles.py b/ecl2df/eclfiles.py index ab4ecc2a7..7083ceba0 100644 --- a/ecl2df/eclfiles.py +++ b/ecl2df/eclfiles.py @@ -14,7 +14,6 @@ from ecl.summary import EclSum logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) # Default parse option to opm.io for a very permissive parsing OPMIOPARSER_RECOVERY = [ diff --git a/ecl2df/equil.py b/ecl2df/equil.py index 799ef9eab..bc2d79009 100644 --- a/ecl2df/equil.py +++ b/ecl2df/equil.py @@ -11,7 +11,6 @@ from .eclfiles import EclFiles logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) SUPPORTED_KEYWORDS = ["EQUIL", "PBVD", "PDVD", "RSVD", "RVVD"] RENAMERS = {} diff --git a/ecl2df/faults.py b/ecl2df/faults.py index 5317b78c1..e26f4a1bf 100644 --- a/ecl2df/faults.py +++ b/ecl2df/faults.py @@ -11,7 +11,6 @@ from .common import parse_opmio_deckrecord logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) RECORD_COLUMNS = ["NAME", "IX1", "IX2", "IY1", "IY2", "IZ1", "IZ2", "FACE"] COLUMNS = ["NAME", "I", "J", "K", "FACE"] diff --git a/ecl2df/fipreports.py b/ecl2df/fipreports.py index bb2092155..73459b1b5 100644 --- a/ecl2df/fipreports.py +++ b/ecl2df/fipreports.py @@ -13,7 +13,6 @@ from .common import parse_ecl_month, write_dframe_stdout_file logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) REGION_REPORT_COLUMNS = [ "DATE", diff --git a/ecl2df/grid.py b/ecl2df/grid.py index 151cc2669..ccd545313 100644 --- a/ecl2df/grid.py +++ b/ecl2df/grid.py @@ -24,7 +24,6 @@ from .eclfiles import EclFiles logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) def get_available_rst_dates(eclfiles): diff --git a/ecl2df/gruptree.py b/ecl2df/gruptree.py index 5fed65ddd..5f933a93b 100644 --- a/ecl2df/gruptree.py +++ b/ecl2df/gruptree.py @@ -21,7 +21,6 @@ ) logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) def df(deck, startdate=None, welspecs=True): diff --git a/ecl2df/inferdims.py b/ecl2df/inferdims.py index 84df5deaf..bb0e36259 100644 --- a/ecl2df/inferdims.py +++ b/ecl2df/inferdims.py @@ -11,7 +11,6 @@ from ecl2df import EclFiles logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) # Constants to use for pointing to positions in the xxxDIMS keyword DIMS_POS = dict(NTPVT=1, NTSFUN=0, NTEQUL=0) diff --git a/ecl2df/nnc.py b/ecl2df/nnc.py index fdd751eff..017ea3505 100644 --- a/ecl2df/nnc.py +++ b/ecl2df/nnc.py @@ -9,7 +9,6 @@ from ecl2df import common, EclFiles, grid, __version__ logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) def df(eclfiles, coords=False, pillars=False): diff --git a/ecl2df/parameters.py b/ecl2df/parameters.py index ef0978486..9e6f4a9f0 100644 --- a/ecl2df/parameters.py +++ b/ecl2df/parameters.py @@ -11,7 +11,6 @@ from ecl2df.eclfiles import EclFiles logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) def find_parameter_files(ecldeck_or_eclpath, filebase="parameters"): diff --git a/ecl2df/pillars.py b/ecl2df/pillars.py index b7ac4fcd4..914a9289e 100644 --- a/ecl2df/pillars.py +++ b/ecl2df/pillars.py @@ -12,7 +12,6 @@ import ecl2df logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) AGGREGATORS = { "VOLUME": "sum", diff --git a/ecl2df/pvt.py b/ecl2df/pvt.py index 8ece8f2af..be1df745c 100644 --- a/ecl2df/pvt.py +++ b/ecl2df/pvt.py @@ -13,7 +13,6 @@ from .eclfiles import EclFiles logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) SUPPORTED_KEYWORDS = ["PVTO", "PVDO", "PVTG", "PVDG", "DENSITY", "ROCK", "PVTW"] diff --git a/ecl2df/rft.py b/ecl2df/rft.py index 3a62e5628..55ff75717 100644 --- a/ecl2df/rft.py +++ b/ecl2df/rft.py @@ -26,7 +26,6 @@ logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) # In debug mode, these columns will be exported to three csv files. CON_TOPOLOGY_COLS = {"CONIDX", "CONBRNO", "CONSEGNO", "CONNXT", "DEPTH"} diff --git a/ecl2df/satfunc.py b/ecl2df/satfunc.py index 67ac8a2dc..4712b8507 100644 --- a/ecl2df/satfunc.py +++ b/ecl2df/satfunc.py @@ -21,7 +21,6 @@ from .common import write_dframe_stdout_file logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) SUPPORTED_KEYWORDS = ["SWOF", "SGOF", "SWFN", "SGWFN", "SOF2", "SGFN", "SOF3", "SLGOF"] diff --git a/ecl2df/summary.py b/ecl2df/summary.py index 561810544..de5df2c89 100644 --- a/ecl2df/summary.py +++ b/ecl2df/summary.py @@ -16,7 +16,6 @@ from .common import write_dframe_stdout_file logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) PD_FREQ_MNEMONICS = { "monthly": "MS", diff --git a/ecl2df/trans.py b/ecl2df/trans.py index 00b8cf163..74c6cdafb 100644 --- a/ecl2df/trans.py +++ b/ecl2df/trans.py @@ -18,7 +18,6 @@ HAVE_NETWORKX = False logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) def df( diff --git a/ecl2df/wcon.py b/ecl2df/wcon.py index d394cb934..4fa48ba26 100644 --- a/ecl2df/wcon.py +++ b/ecl2df/wcon.py @@ -15,7 +15,6 @@ from .common import parse_opmio_date_rec, OPMKEYWORDS logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) # The keywords supported in this module. WCONKEYS = ["WCONHIST", "WCONINJE", "WCONINJH", "WCONPROD"] From 0394cd9d902007198df1564bc83b8285654ce8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= Date: Tue, 24 Nov 2020 20:32:03 +0100 Subject: [PATCH 04/11] basicConfig on application entrypoints --- ecl2df/compdat.py | 2 +- ecl2df/equil.py | 4 ++-- ecl2df/faults.py | 2 +- ecl2df/fipreports.py | 2 +- ecl2df/grid.py | 2 +- ecl2df/gruptree.py | 2 +- ecl2df/nnc.py | 2 +- ecl2df/pillars.py | 2 +- ecl2df/pvt.py | 4 ++-- ecl2df/rft.py | 4 ++-- ecl2df/satfunc.py | 4 ++-- ecl2df/summary.py | 2 +- ecl2df/trans.py | 2 +- ecl2df/wcon.py | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ecl2df/compdat.py b/ecl2df/compdat.py index 4140d8189..bf9c9554a 100644 --- a/ecl2df/compdat.py +++ b/ecl2df/compdat.py @@ -400,7 +400,7 @@ def fill_parser(parser): def compdat_main(args): """Entry-point for module, for command line utility""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) compdat_df = df(eclfiles, initvectors=args.initvectors) if compdat_df.empty: diff --git a/ecl2df/equil.py b/ecl2df/equil.py index bc2d79009..a2413851d 100644 --- a/ecl2df/equil.py +++ b/ecl2df/equil.py @@ -294,7 +294,7 @@ def fill_reverse_parser(parser): def equil_main(args): """Read from disk and write CSV back to disk""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) if eclfiles: deck = eclfiles.get_ecldeck() @@ -326,7 +326,7 @@ def equil_main(args): def equil_reverse_main(args): """Entry-point for module, for command line utility for CSV to Eclipse""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) equil_df = pd.read_csv(args.csvfile) logger.info("Parsed %s", args.csvfile) inc_string = df2ecl(equil_df, keywords=args.keywords) diff --git a/ecl2df/faults.py b/ecl2df/faults.py index e26f4a1bf..5a928c967 100644 --- a/ecl2df/faults.py +++ b/ecl2df/faults.py @@ -69,7 +69,7 @@ def fill_parser(parser): def faults_main(args): """Read from disk and write CSV back to disk""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) if eclfiles: deck = eclfiles.get_ecldeck() diff --git a/ecl2df/fipreports.py b/ecl2df/fipreports.py index 73459b1b5..61e167ca2 100644 --- a/ecl2df/fipreports.py +++ b/ecl2df/fipreports.py @@ -182,7 +182,7 @@ def fill_parser(parser): def fipreports_main(args): """Command line API""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) if args.PRTFILE.endswith(".PRT"): prtfile = args.PRTFILE else: diff --git a/ecl2df/grid.py b/ecl2df/grid.py index ccd545313..9dc457742 100644 --- a/ecl2df/grid.py +++ b/ecl2df/grid.py @@ -656,7 +656,7 @@ def df2ecl( def grid_main(args): """This is the command line API""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) grid_df = df( eclfiles, diff --git a/ecl2df/gruptree.py b/ecl2df/gruptree.py index 5f933a93b..960dcb384 100644 --- a/ecl2df/gruptree.py +++ b/ecl2df/gruptree.py @@ -291,7 +291,7 @@ def fill_parser(parser): def gruptree_main(args): """Entry-point for module, for command line utility""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) if not args.output and not args.prettyprint: print("Nothing to do. Set --output or --prettyprint") sys.exit(0) diff --git a/ecl2df/nnc.py b/ecl2df/nnc.py index 017ea3505..a78b190db 100644 --- a/ecl2df/nnc.py +++ b/ecl2df/nnc.py @@ -277,7 +277,7 @@ def df2ecl_editnnc(nnc_df, filename=None, nocomments=False): def nnc_main(args): """Command line access point from main() or from ecl2csv via subparser""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) nncdf = df(eclfiles, coords=args.coords, pillars=args.pillars) if nncdf.empty: diff --git a/ecl2df/pillars.py b/ecl2df/pillars.py index 914a9289e..5f45c8f68 100644 --- a/ecl2df/pillars.py +++ b/ecl2df/pillars.py @@ -406,7 +406,7 @@ def fill_parser(parser): def pillars_main(args): """This is the command line API""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = ecl2df.EclFiles(args.DATAFILE) dframe = df( eclfiles, diff --git a/ecl2df/pvt.py b/ecl2df/pvt.py index be1df745c..0ce02cd8e 100644 --- a/ecl2df/pvt.py +++ b/ecl2df/pvt.py @@ -245,7 +245,7 @@ def fill_reverse_parser(parser): def pvt_main(args): """Entry-point for module, for command line utility for Eclipse to CSV""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) logger.info("Parsed %s", args.DATAFILE) if eclfiles: @@ -279,7 +279,7 @@ def pvt_main(args): def pvt_reverse_main(args): """Entry-point for module, for command line utility for CSV to Eclipse""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) pvt_df = pd.read_csv(args.csvfile) logger.info("Parsed %s", args.csvfile) inc_string = df2ecl(pvt_df, keywords=args.keywords) diff --git a/ecl2df/rft.py b/ecl2df/rft.py index 55ff75717..4461406b1 100644 --- a/ecl2df/rft.py +++ b/ecl2df/rft.py @@ -674,9 +674,9 @@ def fill_parser(parser): def rft_main(args): """Entry-point for module, for command line utility""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) if args.debug: - logger.setLevel(logging.DEBUG) + logging.basicConfig(level=logging.DEBUG) if args.DATAFILE.endswith(".RFT"): # Support the RFT file as an argument also: eclfiles = EclFiles(args.DATAFILE.replace(".RFT", "") + ".DATA") diff --git a/ecl2df/satfunc.py b/ecl2df/satfunc.py index 4712b8507..e3d084e28 100644 --- a/ecl2df/satfunc.py +++ b/ecl2df/satfunc.py @@ -275,7 +275,7 @@ def fill_reverse_parser(parser): def satfunc_main(args): """Entry-point for module, for command line utility""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) if eclfiles: deck = eclfiles.get_ecldeck() @@ -307,7 +307,7 @@ def satfunc_main(args): def satfunc_reverse_main(args): """For command line utility for CSV to Eclipse""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) satfunc_df = pd.read_csv(args.csvfile) logger.info("Parsed %s", args.csvfile) inc_string = df2ecl(satfunc_df, keywords=args.keywords) diff --git a/ecl2df/summary.py b/ecl2df/summary.py index de5df2c89..c1288ade0 100644 --- a/ecl2df/summary.py +++ b/ecl2df/summary.py @@ -371,7 +371,7 @@ def fill_parser(parser): def summary_main(args): """Read summary data from disk and write CSV back to disk""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) sum_df = df( eclfiles, diff --git a/ecl2df/trans.py b/ecl2df/trans.py index 74c6cdafb..ade7e58f5 100644 --- a/ecl2df/trans.py +++ b/ecl2df/trans.py @@ -297,7 +297,7 @@ def fill_parser(parser): def trans_main(args): """This is the command line API""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) trans_df = df( eclfiles, diff --git a/ecl2df/wcon.py b/ecl2df/wcon.py index 4fa48ba26..48af162cb 100644 --- a/ecl2df/wcon.py +++ b/ecl2df/wcon.py @@ -146,7 +146,7 @@ def fill_parser(parser): def wcon_main(args): """Read from disk and write CSV back to disk""" if args.verbose: - logger.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO) eclfiles = EclFiles(args.DATAFILE) if eclfiles: deck = eclfiles.get_ecldeck() From 7139be40ad6f14f251bcf81030e2fd099499f7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= Date: Wed, 25 Nov 2020 10:14:41 +0100 Subject: [PATCH 05/11] Add verbose logging test --- tests/test_logging.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_logging.py diff --git a/tests/test_logging.py b/tests/test_logging.py new file mode 100644 index 000000000..f7db153de --- /dev/null +++ b/tests/test_logging.py @@ -0,0 +1,28 @@ +import logging +import argparse + +import pytest + +from ecl2df.grid import grid_main +from test_grid import DATAFILE + + +@pytest.mark.parametrize("verbose", [False, True]) +def test_grid_logging(caplog, tmp_path, verbose): + + args = argparse.Namespace( + verbose=verbose, + DATAFILE=DATAFILE, + vectors="*", + rstdates="", + dropconstants=False, + stackdates=False, + output=tmp_path / "eclgrid.csv", + ) + + grid_main(args) + + if verbose: + assert caplog.records + else: + assert caplog.records == [] From ab82a2f0ac7dfe3936bdb6da8aab9405de60ef99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Fri, 20 Nov 2020 14:06:31 +0100 Subject: [PATCH 06/11] Replace os.path with pathlib (#206) --- ecl2df/common.py | 17 +++---- ecl2df/eclfiles.py | 25 +++++----- ecl2df/grid.py | 11 ++--- ecl2df/nnc.py | 10 ++-- ecl2df/parameters.py | 12 ++--- ecl2df/summary.py | 4 +- tests/test_compdat.py | 17 +++---- tests/test_equil.py | 14 +++--- tests/test_ert_hooks.py | 17 +++---- tests/test_faults.py | 10 ++-- tests/test_fipreports.py | 12 ++--- tests/test_grid.py | 20 ++++---- tests/test_gruptree.py | 14 +++--- tests/test_hook_implementations.py | 12 ++--- tests/test_nnc.py | 10 ++-- tests/test_parameters.py | 78 ++++++++++++++---------------- tests/test_pillars.py | 28 +++++------ tests/test_pvt.py | 12 ++--- tests/test_rft.py | 14 +++--- tests/test_satfunc.py | 12 ++--- tests/test_summary.py | 50 ++++++++++--------- tests/test_trans.py | 12 ++--- tests/test_userapi.py | 7 +-- tests/test_wcon.py | 10 ++-- tests/test_zonemap.py | 7 ++- 25 files changed, 208 insertions(+), 227 deletions(-) diff --git a/ecl2df/common.py b/ecl2df/common.py index 0a0b27c19..693d200e5 100644 --- a/ecl2df/common.py +++ b/ecl2df/common.py @@ -2,7 +2,6 @@ Common functions for ecl2df modules """ -import os import sys import json import signal @@ -10,6 +9,7 @@ import logging import datetime import itertools +from pathlib import Path import numpy as np import pandas as pd @@ -55,10 +55,9 @@ "WELSEGS", "WELSPECS", ]: - with open( - os.path.join(os.path.dirname(__file__), "opmkeywords", keyw), "r" - ) as file_handle: - OPMKEYWORDS[keyw] = json.load(file_handle) + OPMKEYWORDS[keyw] = json.loads( + (Path(__file__).parent / "opmkeywords" / keyw).read_text() + ) logger = logging.getLogger(__name__) @@ -523,12 +522,8 @@ def df2ecl( string += function(dataframe) if filename is not None: - # Make directory if not present: - filenamedir = os.path.dirname(filename) - if filenamedir and not os.path.exists(filenamedir): - os.makedirs(filenamedir) - with open(filename, "w") as f_handle: - f_handle.write(string) + Path(filename).parent.mkdir(parents=True, exist_ok=True) + Path(filename).write_text(string, encoding="utf-8") return string diff --git a/ecl2df/eclfiles.py b/ecl2df/eclfiles.py index 7083ceba0..7f756aea0 100644 --- a/ecl2df/eclfiles.py +++ b/ecl2df/eclfiles.py @@ -6,6 +6,7 @@ import errno import logging import shlex +from pathlib import Path import opm.io @@ -48,7 +49,7 @@ def __init__(self, eclbase): eclbase = str(eclbase) # Hint about possible wrong filenames: - if ".DATA" in eclbase and not os.path.exists(eclbase): + if ".DATA" in eclbase and not Path(eclbase).is_file(): logger.warning("File %s does not exist", eclbase) # (this is not an error, because it is possible # to obtain summary without the DATA file being present) @@ -72,12 +73,12 @@ def __init__(self, eclbase): def get_path(self): """Return the full path to the directory with the DATA file""" - return os.path.dirname(os.path.abspath(self._eclbase)) + return Path(self._eclbase).absolute().parent def get_ecldeck(self): """Return a opm.io deck of the DATA file""" if not self._deck: - if os.path.exists(self._eclbase + ".DATA"): + if Path(self._eclbase + ".DATA").is_file(): deckfile = self._eclbase + ".DATA" else: deckfile = self._eclbase # Will be any filename @@ -106,7 +107,7 @@ def get_egrid(self): """Find and return EGRID file as an EclGrid object""" if not self._egrid: egridfilename = self._eclbase + ".EGRID" - if not os.path.exists(egridfilename): + if not Path(egridfilename).is_file(): raise FileNotFoundError( errno.ENOENT, os.strerror(errno.ENOENT), egridfilename ) @@ -120,7 +121,7 @@ def get_egridfile(self): This gives access to data vectors defined on the grid.""" if not self._egridfile: egridfilename = self._eclbase + ".EGRID" - if not os.path.exists(egridfilename): + if not Path(egridfilename).is_file(): raise FileNotFoundError( errno.ENOENT, os.strerror(errno.ENOENT), egridfilename ) @@ -140,7 +141,7 @@ def get_eclsum(self, include_restart=True): """ if not self._eclsum: smryfilename = self._eclbase + ".UNSMRY" - if not os.path.exists(smryfilename): + if not Path(smryfilename).is_file(): raise FileNotFoundError( errno.ENOENT, os.strerror(errno.ENOENT), smryfilename ) @@ -152,7 +153,7 @@ def get_initfile(self): """Find and return the INIT file as an EclFile object""" if not self._initfile: initfilename = self._eclbase + ".INIT" - if not os.path.exists(initfilename): + if not Path(initfilename).is_file(): raise FileNotFoundError( errno.ENOENT, os.strerror(errno.ENOENT), initfilename ) @@ -164,7 +165,7 @@ def get_rftfile(self): """Find and return the RFT file as an EclFile object""" if not self._rftfile: rftfilename = self._eclbase + ".RFT" - if not os.path.exists(rftfilename): + if not Path(rftfilename).is_file(): raise FileNotFoundError( errno.ENOENT, os.strerror(errno.ENOENT), rftfilename ) @@ -176,7 +177,7 @@ def get_rstfile(self): """Find and return the UNRST file as an EclFile object""" if not self._rstfile: rstfilename = self._eclbase + ".UNRST" - if not os.path.exists(rstfilename): + if not Path(rstfilename).is_file(): raise FileNotFoundError( errno.ENOENT, os.strerror(errno.ENOENT), rstfilename ) @@ -221,11 +222,11 @@ def get_zonemap(self, filename=None): else: filename_defaulted = False assert isinstance(filename, str) - if not os.path.isabs(filename): - fullpath = os.path.join(self.get_path(), filename) + if not Path(filename).is_absolute(): + fullpath = Path(self.get_path()) / filename else: fullpath = filename - if not os.path.exists(fullpath): + if not Path(fullpath).is_file(): if filename_defaulted: # No warnings when the default filename is not there. return {} diff --git a/ecl2df/grid.py b/ecl2df/grid.py index 9dc457742..66aa2534f 100644 --- a/ecl2df/grid.py +++ b/ecl2df/grid.py @@ -9,12 +9,12 @@ the INIT file, and dynamic data can be merged from the Restart (UNRST) file. """ -import os import logging import fnmatch import textwrap import datetime import dateutil.parser +from pathlib import Path import numpy as np import pandas as pd @@ -643,13 +643,8 @@ def df2ecl( string += "\n" if filename is not None: - # Make directory if not present: - filenamedir = os.path.dirname(filename) - if filenamedir and not os.path.exists(filenamedir): - os.makedirs(filenamedir) - with open(filename, "w") as file_handle: - file_handle.write(string) - + Path(filename).parent.mkdir(parents=True, exist_ok=True) + Path(filename).write_text(string, encoding="utf-8") return string diff --git a/ecl2df/nnc.py b/ecl2df/nnc.py index a78b190db..3516414ce 100644 --- a/ecl2df/nnc.py +++ b/ecl2df/nnc.py @@ -5,6 +5,7 @@ import logging import datetime import pandas as pd +from pathlib import Path from ecl2df import common, EclFiles, grid, __version__ @@ -264,13 +265,8 @@ def df2ecl_editnnc(nnc_df, filename=None, nocomments=False): string += "\n\n" if filename is not None: - # Make directory if not present: - filenamedir = os.path.dirname(filename) - if filenamedir and not os.path.exists(filenamedir): - os.makedirs(filenamedir) - with open(filename, "w") as file_handle: - file_handle.write(string) - + Path(filename).parent.mkdir(parents=True, exist_ok=True) + Path(filename).write_text(string, encoding="utf-8") return string diff --git a/ecl2df/parameters.py b/ecl2df/parameters.py index 9e6f4a9f0..6eb4db310 100644 --- a/ecl2df/parameters.py +++ b/ecl2df/parameters.py @@ -1,8 +1,8 @@ """Support module for extra files with key-value information related to Eclipse runs""" -import os import logging +from pathlib import Path import json import yaml @@ -32,9 +32,9 @@ def find_parameter_files(ecldeck_or_eclpath, filebase="parameters"): found """ if isinstance(ecldeck_or_eclpath, EclFiles): - eclbasepath = ecldeck_or_eclpath.get_path() + eclbasepath = Path(ecldeck_or_eclpath.get_path()) elif isinstance(ecldeck_or_eclpath, str): - eclbasepath = os.path.abspath(os.path.dirname(ecldeck_or_eclpath)) + eclbasepath = Path(ecldeck_or_eclpath).parent.absolute() else: raise TypeError files_to_lookfor = [ @@ -43,12 +43,12 @@ def find_parameter_files(ecldeck_or_eclpath, filebase="parameters"): filebase + ".txt", filebase, ] - paths_to_check = [os.curdir, os.pardir, os.path.join(os.pardir, os.pardir)] + paths_to_check = [".", "..", Path("..") / Path("..")] foundfiles = [] for path in paths_to_check: for fname in files_to_lookfor: - fullfname = os.path.join(eclbasepath, path, fname) - if os.path.exists(fullfname): + fullfname = eclbasepath / path / fname + if fullfname.is_file(): foundfiles.append(fullfname) return foundfiles diff --git a/ecl2df/summary.py b/ecl2df/summary.py index c1288ade0..1ebbcc947 100644 --- a/ecl2df/summary.py +++ b/ecl2df/summary.py @@ -4,10 +4,10 @@ Code taken from fmu.ensemble.ScratchRealization """ -import os import logging import datetime import dateutil.parser +from pathlib import Path import pandas as pd @@ -265,7 +265,7 @@ def df( logger.info("Loading parameters from files: %s", str(param_files)) param_dict = parameters.load_all(param_files) else: - if not os.path.isabs(paramfile): + if not Path(paramfile).is_absolute(): param_file = parameters.find_parameter_files( eclfiles, filebase=paramfile ) diff --git a/tests/test_compdat.py b/tests/test_compdat.py index 3b061357d..99e09ce34 100644 --- a/tests/test_compdat.py +++ b/tests/test_compdat.py @@ -1,8 +1,7 @@ """Test module for nnc""" - -import os import sys +from pathlib import Path import pandas as pd @@ -11,10 +10,10 @@ from ecl2df import compdat, ecl2csv from ecl2df import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") -SCHFILE = os.path.join(TESTDIR, "./data/reek/eclipse/include/schedule/reek_history.sch") +SCHFILE = str(TESTDIR / "./data/reek/eclipse/include/schedule/reek_history.sch") def test_df(): @@ -301,11 +300,11 @@ def test_initmerging(): def test_main_subparsers(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-compdat.csv") + tmpcsvfile = tmpdir / "compdat.csv" sys.argv = ["ecl2csv", "compdat", "-v", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "ZONE" in disk_df assert not disk_df.empty @@ -321,7 +320,7 @@ def test_main_subparsers(tmpdir): ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "FIPNUM" in disk_df assert not disk_df.empty @@ -338,7 +337,7 @@ def test_main_subparsers(tmpdir): ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "FIPNUM" in disk_df assert "EQLNUM" in disk_df diff --git a/tests/test_equil.py b/tests/test_equil.py index cbf17ab05..6c1a0647c 100644 --- a/tests/test_equil.py +++ b/tests/test_equil.py @@ -1,7 +1,7 @@ """Test module for equil2df""" -import os import sys +from pathlib import Path import pytest @@ -10,8 +10,8 @@ from ecl2df import equil, ecl2csv from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_equil2df(): @@ -40,11 +40,11 @@ def test_df2ecl(tmpdir): eclfiles = EclFiles(DATAFILE) equildf = equil.df(eclfiles) equil.df2ecl(equildf, filename="equil.inc") - assert os.path.exists("equil.inc") + assert Path("equil.inc").is_file() # Test automatic directory creation: equil.df2ecl(equildf, filename="eclipse/include/equil.inc") - assert os.path.exists("eclipse/include/equil.inc") + assert Path("eclipse/include/equil.inc").is_file() def test_decks(): @@ -359,10 +359,10 @@ def test_ntequl(): def test_main_subparser(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-equil.csv") + tmpcsvfile = tmpdir / ".TMP-equil.csv" sys.argv = ["ecl2csv", "equil", "-v", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty diff --git a/tests/test_ert_hooks.py b/tests/test_ert_hooks.py index f506e9f7e..638f660a7 100644 --- a/tests/test_ert_hooks.py +++ b/tests/test_ert_hooks.py @@ -1,5 +1,5 @@ -import os import subprocess +from pathlib import Path import pytest @@ -14,8 +14,8 @@ ) -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATADIR = os.path.join(TESTDIR, "data/reek/eclipse/model") +TESTDIR = Path(__file__).absolute().parent +DATADIR = TESTDIR / "data/reek/eclipse/model" def test_ecl2csv_through_ert(tmpdir): @@ -37,7 +37,7 @@ def test_ecl2csv_through_ert(tmpdir): for ext in ecl_extensions: f_name = eclbase + "." + ext - os.symlink(os.path.join(DATADIR, f_name), f_name) + Path(f_name).symlink_to(DATADIR / f_name) ert_config = [ "ECLBASE " + eclbase + ".DATA", @@ -74,14 +74,13 @@ def test_ecl2csv_through_ert(tmpdir): ) ert_config_filename = "ecl2csv_test.ert" - with open(ert_config_filename, "w") as file_h: - file_h.write("\n".join(ert_config)) + Path(ert_config_filename).write_text("\n".join(ert_config), encoding="utf-8") subprocess.call(["ert", "test_run", ert_config_filename]) - assert os.path.exists("OK") + assert Path("OK").is_file() for subcommand in ecl2csv_subcommands: - assert os.path.exists(subcommand + ".csv") + assert Path(subcommand + ".csv").is_file() for subcommand in csv2ecl_subcommands: - assert os.path.exists(subcommand + ".inc") + assert Path(subcommand + ".inc").is_file() diff --git a/tests/test_faults.py b/tests/test_faults.py index 4ff328b6d..0808561b5 100644 --- a/tests/test_faults.py +++ b/tests/test_faults.py @@ -1,15 +1,15 @@ """Test module for nnc2df""" -import os import sys +from pathlib import Path import pandas as pd from ecl2df import faults, ecl2csv from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_faults2df(): @@ -62,10 +62,10 @@ def test_multiplestr2df(): def test_main_subparser(tmpdir): """Test command line interface with subparsers""" - tmpcsvfile = tmpdir.join(".TMP-faultsdf.csv") + tmpcsvfile = tmpdir / "faultsdf.csv" sys.argv = ["ecl2csv", "faults", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty diff --git a/tests/test_fipreports.py b/tests/test_fipreports.py index f3c4efafa..5d236561a 100644 --- a/tests/test_fipreports.py +++ b/tests/test_fipreports.py @@ -1,7 +1,7 @@ """Test module for fipreports""" -import os import sys +from pathlib import Path import pandas as pd @@ -9,9 +9,9 @@ from ecl2df.eclfiles import EclFiles from ecl2df.fipreports import report_block_lineparser as parser -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") -MOCKPRTFILE = os.path.join(TESTDIR, "data/fipreports/TEST1.PRT") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") +MOCKPRTFILE = str(TESTDIR / "data/fipreports/TEST1.PRT") def test_fipreports2df(): @@ -81,11 +81,11 @@ def test_report_block_lineparser(): def test_cmdline(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-fipreports.csv") + tmpcsvfile = tmpdir / "TMP-fipreports.csv" sys.argv = ["ecl2csv", "fipreports", "-v", DATAFILE, "--output", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(tmpcsvfile) assert "FIPNAME" in disk_df assert "STOIIP_OIL" in disk_df diff --git a/tests/test_grid.py b/tests/test_grid.py index e5e9ff123..c59398a8e 100644 --- a/tests/test_grid.py +++ b/tests/test_grid.py @@ -1,8 +1,8 @@ """Test module for ecl2df.grid""" -import os import sys import datetime +from pathlib import Path import numpy as np import pandas as pd @@ -13,8 +13,8 @@ from ecl2df import ecl2csv from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_gridgeometry2df(): @@ -129,7 +129,7 @@ def test_df2ecl(tmpdir): tmpdir.chdir() grid.df2ecl(grid_df, ["PERMX", "PERMY", "PERMZ"], dtype=float, filename="perm.inc") - assert os.path.exists("perm.inc") + assert Path("perm.inc").is_file() incstring = open("perm.inc").readlines() assert sum([1 for line in incstring if "PERM" in line]) == 6 @@ -275,7 +275,7 @@ def test_df(): def test_main(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-eclgrid.csv") + tmpcsvfile = tmpdir / "eclgrid.csv" sys.argv = [ "ecl2csv", "grid", @@ -288,10 +288,10 @@ def test_main(tmpdir): "PORO", ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty - os.remove(str(tmpcsvfile)) + Path(tmpcsvfile).unlink() # Do again with also restarts: sys.argv = [ @@ -306,15 +306,15 @@ def test_main(tmpdir): "PORO", ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty - os.remove(str(tmpcsvfile)) + Path(tmpcsvfile).unlink() # Test with constants dropping sys.argv = ["ecl2csv", "grid", DATAFILE, "-o", str(tmpcsvfile), "--dropconstants"] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) # That PVTNUM is constant is a particular feature # of the test dataset. diff --git a/tests/test_gruptree.py b/tests/test_gruptree.py index a40741b26..d8d3ad3ea 100644 --- a/tests/test_gruptree.py +++ b/tests/test_gruptree.py @@ -1,7 +1,7 @@ """Test module for nnc2df""" -import os import sys +from pathlib import Path import pytest import pandas as pd @@ -9,8 +9,8 @@ from ecl2df import gruptree, ecl2csv from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_gruptree2df(): @@ -261,11 +261,11 @@ def test_tstep(): def test_main(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-gruptree.csv") + tmpcsvfile = tmpdir.join("gruptree.csv") sys.argv = ["ecl2csv", "gruptree", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty @@ -278,10 +278,10 @@ def test_prettyprint(): def test_main_subparser(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-gruptree.csv") + tmpcsvfile = tmpdir.join("gruptree.csv") sys.argv = ["ecl2csv", "gruptree", "-v", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty diff --git a/tests/test_hook_implementations.py b/tests/test_hook_implementations.py index fdf91bc4e..577db7acb 100644 --- a/tests/test_hook_implementations.py +++ b/tests/test_hook_implementations.py @@ -1,5 +1,5 @@ -import os import shutil +from pathlib import Path import pytest @@ -32,7 +32,7 @@ def test_hook_implementations(): for wf_name, wf_location in EXPECTED_JOBS.items(): assert wf_name in installable_jobs assert installable_jobs[wf_name].endswith(wf_location) - assert os.path.isfile(installable_jobs[wf_name]) + assert Path(installable_jobs[wf_name]).is_file() assert set(installable_jobs.keys()) == set(EXPECTED_JOBS.keys()) @@ -47,10 +47,10 @@ def test_hook_implementations(): def test_job_config_syntax(): """Check for syntax errors made in job configuration files""" - src_path = os.path.join(os.path.dirname(__file__), "../") + src_path = Path(__file__).parent.parent for _, job_config in EXPECTED_JOBS.items(): # Check (loosely) that double-dashes are enclosed in quotes: - with open(os.path.join(src_path, job_config)) as f_handle: + with open(src_path / job_config) as f_handle: for line in f_handle.readlines(): if not line.strip().startswith("--") and "--" in line: assert '"--' in line and " --" not in line @@ -59,9 +59,9 @@ def test_job_config_syntax(): @pytest.mark.integration def test_executables(): """Test executables listed in job configurations exist in $PATH""" - src_path = os.path.join(os.path.dirname(__file__), "../") + src_path = Path(__file__).parent.parent for _, job_config in EXPECTED_JOBS.items(): - with open(os.path.join(src_path, job_config)) as f_handle: + with open(src_path / job_config) as f_handle: executable = f_handle.readlines()[0].split()[1] assert shutil.which(executable) diff --git a/tests/test_nnc.py b/tests/test_nnc.py index 53bd3870f..35f493366 100644 --- a/tests/test_nnc.py +++ b/tests/test_nnc.py @@ -1,7 +1,7 @@ """Test module for nnc2df""" -import os import sys +from pathlib import Path import pandas as pd import pytest @@ -9,8 +9,8 @@ from ecl2df import nnc, faults, ecl2csv, trans from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_nnc2df(): @@ -99,11 +99,11 @@ def test_df2ecl_editnnc(tmpdir): def test_main(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-nnc.csv") + tmpcsvfile = tmpdir.join("nnc.csv") sys.argv = ["ecl2csv", "nnc", "-v", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty assert "I1" in disk_df diff --git a/tests/test_parameters.py b/tests/test_parameters.py index 6a502e724..85ad2f482 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -1,15 +1,14 @@ """Test module for parameters""" -import os - import json import yaml +from pathlib import Path from ecl2df.parameters import load, load_all, find_parameter_files from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_parameters(): @@ -19,59 +18,54 @@ def test_parameters(): # NB: This test easily fails due to remnants of other test code.. assert not find_parameter_files(eclfiles) - parameterstxt = os.path.join(eclfiles.get_path(), "parameters.txt") - if os.path.exists(parameterstxt): - # If this exists, it is a remnant from test code that has - # crashed. It should NOT be in git. - os.unlink(parameterstxt) - with open(parameterstxt, "w") as pfile: - pfile.write("FOO 1\nBAR 3") - assert os.path.exists(parameterstxt) + parameterstxt = Path(eclfiles.get_path()) / "parameters.txt" + # If this exists, it is a remnant from test code that has + # crashed. It should NOT be in git. + if parameterstxt.is_file(): + parameterstxt.unlink() + parameterstxt.write_text("FOO 1\nBAR 3", encoding="utf-8") + assert Path(parameterstxt).is_file() param_dict = load(parameterstxt) assert "FOO" in param_dict assert "BAR" in param_dict assert len(find_parameter_files(eclfiles)) == 1 - os.unlink(parameterstxt) + parameterstxt.unlink() - parameterstxt = os.path.join(eclfiles.get_path(), os.pardir, "parameters.txt") - if os.path.exists(parameterstxt): - os.unlink(parameterstxt) - with open(parameterstxt, "w") as pfile: - pfile.write("FOO 1\nBAR 3\n") - pfile.write("CONTACT:BARF 2700") - assert os.path.exists(parameterstxt) + parameterstxt = Path(eclfiles.get_path()).parent / "parameters.txt" + if parameterstxt.is_file(): + parameterstxt.unlink() + parameterstxt.write_text("FOO 1\nBAR 3\nCONTACT:BARF 2700", encoding="utf-8") + assert Path(parameterstxt).is_file() param_dict = load(parameterstxt) assert "FOO" in param_dict assert "BAR" in param_dict assert param_dict["BAR"] == 3 assert param_dict["CONTACT:BARF"] == 2700 assert len(find_parameter_files(eclfiles)) == 1 - os.unlink(parameterstxt) + parameterstxt.unlink() # Typical parameters.json structure: The group "CONTACT" is assumed having # duplicate information, and is to be ignored dump_me = {"FOO": 1, "BAR": "com", "CONTACT:BARF": 2700, "CONTACT": {"BARF": 2700}} - parametersyml = os.path.join(eclfiles.get_path(), "parameters.yml") - if os.path.exists(parametersyml): - os.unlink(parametersyml) - with open(parametersyml, "w") as pfile: - pfile.write(yaml.dump(dump_me)) - assert os.path.exists(parametersyml) + parametersyml = Path(eclfiles.get_path()) / "parameters.yml" + if parametersyml.is_file(): + parametersyml.unlink() + parametersyml.write_text(yaml.dump(dump_me), encoding="utf-8") + assert Path(parametersyml).is_file() assert len(find_parameter_files(eclfiles)) == 1 param_dict = load(parametersyml) assert "FOO" in param_dict assert "BAR" in param_dict assert param_dict["BAR"] == "com" - os.unlink(parametersyml) + parametersyml.unlink() - parametersjson = os.path.join(eclfiles.get_path(), "parameters.json") - if os.path.exists(parametersjson): - os.unlink(parametersjson) - with open(parametersjson, "w") as pfile: - pfile.write(json.dumps(dump_me)) - assert os.path.exists(parametersjson) + parametersjson = Path(eclfiles.get_path()) / "parameters.json" + if parametersjson.is_file(): + parametersjson.unlink() + parametersjson.write_text(json.dumps(dump_me), encoding="utf-8") + assert Path(parametersjson).is_file() assert len(find_parameter_files(eclfiles)) == 1 param_dict = load(find_parameter_files(eclfiles)[0]) param_dict_m = load_all(find_parameter_files(eclfiles)) @@ -79,20 +73,18 @@ def test_parameters(): assert "BAR" in param_dict assert param_dict["BAR"] == "com" assert param_dict == param_dict_m - os.unlink(parametersjson) + parametersjson.unlink() def test_multiple_parameters(): """Test what happens when we have duplicate parameter files""" eclfiles = EclFiles(DATAFILE) - parametersjson = os.path.join(eclfiles.get_path(), "parameters.json") - parameterstxt = os.path.join(eclfiles.get_path(), os.pardir, "parameters.txt") - with open(parameterstxt, "w") as pfile: - pfile.write("FOO 1\nBAR 4") - with open(parametersjson, "w") as pfile: - pfile.write(json.dumps({"BAR": 5, "COM": 6})) + parametersjson = Path(eclfiles.get_path()) / "parameters.json" + parameterstxt = Path(eclfiles.get_path()).parent / "parameters.txt" + parameterstxt.write_text("FOO 1\nBAR 4", encoding="utf-8") + parametersjson.write_text(json.dumps({"BAR": 5, "COM": 6}), encoding="utf-8") param_dict = load_all(find_parameter_files(eclfiles)) assert len(param_dict) == 3 assert param_dict["BAR"] == 5 # json has precedence over txt - os.unlink(parametersjson) - os.unlink(parameterstxt) + parametersjson.unlink() + parameterstxt.unlink() diff --git a/tests/test_pillars.py b/tests/test_pillars.py index 170ce62a5..197f5ab8c 100644 --- a/tests/test_pillars.py +++ b/tests/test_pillars.py @@ -1,7 +1,7 @@ """Test module for ecl2df.pillars""" -import os import sys +from pathlib import Path import pandas as pd @@ -10,8 +10,8 @@ from ecl2df import ecl2csv from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_pillars(): @@ -151,10 +151,10 @@ def test_contact(): def test_main(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-pillars.csv") + tmpcsvfile = tmpdir / "pillars.csv" sys.argv = ["ecl2csv", "pillars", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" in disk_df assert not disk_df.empty @@ -172,7 +172,7 @@ def test_main(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" not in disk_df # because of grouping assert "FIPNUM" not in disk_df @@ -192,7 +192,7 @@ def test_main(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" in disk_df assert "FIPNUM" in disk_df @@ -211,7 +211,7 @@ def test_main(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" not in disk_df # because of grouping assert "FIPNUM" in disk_df # grouped by this. @@ -231,7 +231,7 @@ def test_main(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" not in disk_df # because of region averaging assert "FIPNUM" not in disk_df @@ -257,7 +257,7 @@ def test_main(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" not in disk_df # because of region averaging assert "FIPNUM" not in disk_df @@ -283,7 +283,7 @@ def test_main(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" not in disk_df # because of region averaging assert "FIPNUM" not in disk_df @@ -308,7 +308,7 @@ def test_main(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" not in disk_df # because of region averaging assert "FIPNUM" not in disk_df @@ -334,7 +334,7 @@ def test_main(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" in disk_df assert "FIPNUM" in disk_df @@ -356,7 +356,7 @@ def test_main(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert "PILLAR" in disk_df assert "FIPNUM" not in disk_df diff --git a/tests/test_pvt.py b/tests/test_pvt.py index afcc76804..7c3044827 100644 --- a/tests/test_pvt.py +++ b/tests/test_pvt.py @@ -1,7 +1,7 @@ """Test module for pvt""" -import os import sys +from pathlib import Path import logging import pandas as pd @@ -11,8 +11,8 @@ from ecl2df import pvt, ecl2csv, csv2ecl from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") logger = logging.getLogger("") logger.setLevel(logging.DEBUG) @@ -351,7 +351,7 @@ def test_main(tmpdir): sys.argv = ["ecl2csv", "pvt", "-v", DATAFILE, "-o", tmpcsvfile] ecl2csv.main() - assert os.path.exists(tmpcsvfile) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(tmpcsvfile) assert "PVTNUM" in disk_df assert "KEYWORD" in disk_df @@ -364,7 +364,7 @@ def test_main(tmpdir): # Reparse the include file on disk back to dataframe # and check dataframe equality - assert os.path.exists(incfile) + assert Path(incfile).is_file() disk_inc_df = pvt.df(open(incfile).read()) pd.testing.assert_frame_equal(disk_df, disk_inc_df) @@ -428,7 +428,7 @@ def test_df2ecl(tmpdir): assert "foo" not in rock_inc rock_inc = pvt.df2ecl(rock_df, comments=dict(ROCK="foo\nbar"), filename="foo.inc") - assert os.path.exists("foo.inc") + assert Path("foo.inc").is_file() assert "foo" in rock_inc assert "bar" in rock_inc # Multiline comments are tricky, is the output valid? diff --git a/tests/test_rft.py b/tests/test_rft.py index e06e6851e..8ed44b7cc 100644 --- a/tests/test_rft.py +++ b/tests/test_rft.py @@ -1,9 +1,9 @@ """Test module for rft""" -import os import sys import random import datetime +from pathlib import Path import pandas as pd import numpy as np @@ -13,8 +13,8 @@ from ecl2df import rft, ecl2csv from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") # pylint: disable=protected-access @@ -384,15 +384,15 @@ def test_rft2df(): def test_main_subparsers(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-rft.csv") + tmpcsvfile = tmpdir / ".TMP-rft.csv" sys.argv = ["ecl2csv", "rft", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty - tmpcsvfile = tmpdir.join(".TMP-rft2.csv") + tmpcsvfile = tmpdir / ".TMP-rft2.csv" # Test with RFT file as argument: sys.argv = [ "ecl2cvsv", @@ -403,6 +403,6 @@ def test_main_subparsers(tmpdir): str(tmpcsvfile), ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty diff --git a/tests/test_satfunc.py b/tests/test_satfunc.py index dbbe2f5c7..2fb554134 100644 --- a/tests/test_satfunc.py +++ b/tests/test_satfunc.py @@ -1,15 +1,15 @@ """Test module for satfunc2df""" -import os import sys +from pathlib import Path import pandas as pd from ecl2df import satfunc, ecl2csv, inferdims from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_satfunc2df(): @@ -124,7 +124,7 @@ def test_slgof(tmpdir): assert "KRO" in slgof_df assert "PCOG" in slgof_df inc = satfunc.df2ecl(slgof_df, filename="slgof.inc") - assert os.path.exists("slgof.inc") + assert Path("slgof.inc").is_file() df_from_inc = satfunc.df(inc) pd.testing.assert_frame_equal(slgof_df, df_from_inc) @@ -251,7 +251,7 @@ def test_main_subparsers(tmpdir): sys.argv = ["ecl2csv", "satfunc", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty @@ -268,6 +268,6 @@ def test_main_subparsers(tmpdir): ] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile2)) + assert Path(tmpcsvfile2).is_file() disk_df = pd.read_csv(str(tmpcsvfile2)) assert set(disk_df["KEYWORD"].unique()) == {"SWOF"} diff --git a/tests/test_summary.py b/tests/test_summary.py index bccb8e9b2..1528bfd4b 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -1,8 +1,8 @@ """Test module for nnc2df""" -import os import sys import datetime +from pathlib import Path import yaml import pandas as pd @@ -11,8 +11,8 @@ from ecl2df.eclfiles import EclFiles from ecl2df.summary import normalize_dates, resample_smry_dates -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_summary2df(): @@ -70,7 +70,7 @@ def test_summary2df_dates(tmpdir): assert sumdf.index.name == "DATE" assert sumdf.index.dtype == "datetime64[ns]" or sumdf.index.dtype == "datetime64" - tmpcsvfile = tmpdir.join(".TMP-sum.csv") + tmpcsvfile = tmpdir / "sum.csv" sys.argv = [ "ecl2csv", "summary", @@ -89,7 +89,7 @@ def test_summary2df_dates(tmpdir): assert str(disk_df["DATE"].values[0]) == "2002-01-02 00:00:00" assert str(disk_df["DATE"].values[-1]) == "2003-01-02 00:00:00" - tmpcsvfile = tmpdir.join(".TMP-sum.csv") + tmpcsvfile = tmpdir / "sum.csv" sys.argv = [ "ecl2csv", "summary", @@ -111,15 +111,21 @@ def test_summary2df_dates(tmpdir): def test_paramsupport(tmpdir): - """Test that we can merge in parameters.txt""" - tmpcsvfile = tmpdir.join(".TMP-sum.csv") + """Test that we can merge in parameters.txt + + This test code manipulates the paths in the checked out + repository (as it involves some pointing upwards in the directory structure) + It should not leave any extra files around, but requires certain filenames + not to be under version control. + """ + tmpcsvfile = tmpdir / "sum.csv" + eclfiles = EclFiles(DATAFILE) - parameterstxt = os.path.join(eclfiles.get_path(), "parameters.txt") - if os.path.exists(parameterstxt): - os.remove(parameterstxt) - with open(parameterstxt, "w") as pfile: - pfile.write("FOO 1\nBAR 3") + parameterstxt = Path(eclfiles.get_path()) / "parameters.txt" + if parameterstxt.is_file(): + parameterstxt.unlink() + parameterstxt.write_text("FOO 1\nBAR 3", encoding="utf-8") sys.argv = ["ecl2csv", "summary", DATAFILE, "-o", str(tmpcsvfile), "-p"] ecl2csv.main() disk_df = pd.read_csv(tmpcsvfile) @@ -127,14 +133,12 @@ def test_paramsupport(tmpdir): assert "FOO" in disk_df assert "BAR" in disk_df assert disk_df["BAR"].unique()[0] == 3 - os.remove(parameterstxt) - os.remove(str(tmpcsvfile)) - - parametersyml = os.path.join(eclfiles.get_path(), "parameters.yml") - if os.path.exists(parametersyml): - os.remove(parametersyml) - with open(parametersyml, "w") as pfile: - pfile.write(yaml.dump({"FOO": 1, "BAR": 3})) + parameterstxt.unlink() + + parametersyml = Path(eclfiles.get_path()) / "parameters.yml" + if parametersyml.is_file(): + parametersyml.unlink() + parametersyml.write_text(yaml.dump({"FOO": 1, "BAR": 3}), encoding="utf-8") sys.argv = ["ecl2csv", "summary", DATAFILE, "-o", str(tmpcsvfile), "-p"] ecl2csv.main() disk_df = pd.read_csv(str(tmpcsvfile)) @@ -145,16 +149,16 @@ def test_paramsupport(tmpdir): assert "BAR" in disk_df assert len(disk_df["BAR"].unique()) == 1 assert disk_df["BAR"].unique()[0] == 3 - os.remove(parametersyml) + parametersyml.unlink() def test_main_subparser(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-sum.csv") + tmpcsvfile = tmpdir / "sum.csv" sys.argv = ["ecl2csv", "summary", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty assert "FOPT" in disk_df diff --git a/tests/test_trans.py b/tests/test_trans.py index a4c2d80c7..2b6276324 100644 --- a/tests/test_trans.py +++ b/tests/test_trans.py @@ -1,7 +1,7 @@ """Test module for ecl2df.trans""" -import os import sys +from pathlib import Path import pandas as pd import networkx @@ -10,8 +10,8 @@ from ecl2df import ecl2csv from ecl2df.eclfiles import EclFiles -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_trans(): @@ -76,14 +76,14 @@ def test_nx(tmpdir): networkx.write_gexf( network, str(tmpdir.join("reek-fipnum-trans.gxf")), prettyprint=True ) - assert os.path.exists(str(tmpdir.join("reek-fipnum-trans.gxf"))) + assert Path(tmpdir / "reek-fipnum-trans.gxf").is_file() def test_main(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-trans.csv") + tmpcsvfile = tmpdir / "trans.csv" sys.argv = ["ecl2csv", "trans", "-v", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty diff --git a/tests/test_userapi.py b/tests/test_userapi.py index 6ae22ec6c..7a12e48f2 100644 --- a/tests/test_userapi.py +++ b/tests/test_userapi.py @@ -1,10 +1,11 @@ """Test module for user API for ecl2df""" -import os +from pathlib import Path + import ecl2df -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_userapi(): diff --git a/tests/test_wcon.py b/tests/test_wcon.py index 7876a2f6e..3bacf1e21 100644 --- a/tests/test_wcon.py +++ b/tests/test_wcon.py @@ -1,7 +1,7 @@ """Test module for wcon""" -import os import sys +from pathlib import Path import pandas as pd @@ -9,8 +9,8 @@ from ecl2df.eclfiles import EclFiles from ecl2df.wcon import unroll_defaulted_items, ad_hoc_wconparser -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_unroller(): @@ -143,10 +143,10 @@ def test_tstep(): def test_main_subparsers(tmpdir): """Test command line interface""" - tmpcsvfile = tmpdir.join(".TMP-wcondf.csv") + tmpcsvfile = tmpdir / ".TMP-wcondf.csv" sys.argv = ["ecl2csv", "wcon", DATAFILE, "-o", str(tmpcsvfile)] ecl2csv.main() - assert os.path.exists(str(tmpcsvfile)) + assert Path(tmpcsvfile).is_file() disk_df = pd.read_csv(str(tmpcsvfile)) assert not disk_df.empty diff --git a/tests/test_zonemap.py b/tests/test_zonemap.py index 4e24d26aa..0fc361831 100644 --- a/tests/test_zonemap.py +++ b/tests/test_zonemap.py @@ -1,14 +1,13 @@ """Test module for layer mapping to zone names""" -import os - import pytest +from pathlib import Path import ecl2df -TESTDIR = os.path.dirname(os.path.abspath(__file__)) -DATAFILE = os.path.join(TESTDIR, "data/reek/eclipse/model/2_R001_REEK-0.DATA") +TESTDIR = Path(__file__).absolute().parent +DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") def test_stdzoneslyr(): From 50325f62b75386417846555a4bf0c058ab51f2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trygve=20Kl=C3=B8v?= <36536100+tklov11@users.noreply.github.com> Date: Fri, 20 Nov 2020 19:36:28 +0100 Subject: [PATCH 07/11] Wsegaicd support (#201) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added support for WSEGAICD and WSEGSICD in response to issue #199 Co-authored-by: Trygve Kløv (ST RRR RM) --- ecl2df/common.py | 2 + ecl2df/compdat.py | 37 ++- ecl2df/opmkeywords/WSEGAICD | 107 +++++++++ ecl2df/opmkeywords/WSEGSICD | 63 ++++++ .../eclipse/include/schedule/op6_aicd1_gp.sch | 213 ++++++++++++++++++ .../eclipse/include/schedule/op6_icd1_gp.sch | 213 ++++++++++++++++++ tests/test_compdat.py | 77 ++++++- 7 files changed, 708 insertions(+), 4 deletions(-) create mode 100644 ecl2df/opmkeywords/WSEGAICD create mode 100644 ecl2df/opmkeywords/WSEGSICD create mode 100644 tests/data/reek/eclipse/include/schedule/op6_aicd1_gp.sch create mode 100644 tests/data/reek/eclipse/include/schedule/op6_icd1_gp.sch diff --git a/ecl2df/common.py b/ecl2df/common.py index 693d200e5..46513c5be 100644 --- a/ecl2df/common.py +++ b/ecl2df/common.py @@ -54,6 +54,8 @@ "WELOPEN", "WELSEGS", "WELSPECS", + "WSEGAICD", + "WSEGSICD", ]: OPMKEYWORDS[keyw] = json.loads( (Path(__file__).parent / "opmkeywords" / keyw).read_text() diff --git a/ecl2df/compdat.py b/ecl2df/compdat.py index bf9c9554a..1528ddb7e 100644 --- a/ecl2df/compdat.py +++ b/ecl2df/compdat.py @@ -65,6 +65,8 @@ def deck2dfs(deck, start_date=None, unroll=True): compsegsrecords = [] welopenrecords = [] welsegsrecords = [] + wsegsicdrecords = [] + wsegaicdrecords = [] welspecs = {} date = start_date # DATE column will always be there, but can contain NaN/None for idx, kword in enumerate(deck): @@ -114,6 +116,18 @@ def deck2dfs(deck, start_date=None, unroll=True): ) rec_data["J"] = welspecs[rec_data["WELL"]]["J"] compdatrecords.append(rec_data) + elif kword.name == "WSEGSICD": + for rec in kword: # Loop over the lines inside WSEGSICD record + rec_data = parse_opmio_deckrecord(rec, "WSEGSICD") + rec_data["DATE"] = date + rec_data["KEYWORD_IDX"] = idx + wsegsicdrecords.append(rec_data) + elif kword.name == "WSEGAICD": + for rec in kword: # Loop over the lines inside WSEGAICD record + rec_data = parse_opmio_deckrecord(rec, "WSEGAICD") + rec_data["DATE"] = date + rec_data["KEYWORD_IDX"] = idx + wsegaicdrecords.append(rec_data) elif kword.name == "COMPSEGS": wellname = parse_opmio_deckrecord( kword[0], "COMPSEGS", itemlistname="records", recordindex=0 @@ -138,7 +152,6 @@ def deck2dfs(deck, start_date=None, unroll=True): "COMPDAT state. Using 'SHUT' instead." % rec_data["STATUS"] ) welopenrecords.append(rec_data) - elif kword.name == "WELSEGS": # First record contains meta-information for well # (opm deck returns default values for unspecified items.) @@ -172,14 +185,34 @@ def deck2dfs(deck, start_date=None, unroll=True): compsegs_df = pd.DataFrame(compsegsrecords) welsegs_df = pd.DataFrame(welsegsrecords) + wsegsicd_df = pd.DataFrame(wsegsicdrecords) + wsegaicd_df = pd.DataFrame(wsegaicdrecords) if unroll and not welsegs_df.empty: welsegs_df = unrolldf(welsegs_df, "SEGMENT1", "SEGMENT2") + if unroll and not wsegsicd_df.empty: + wsegsicd_df = unrolldf(wsegsicd_df, "SEGMENT1", "SEGMENT2") + + if unroll and not wsegaicd_df.empty: + wsegaicd_df = unrolldf(wsegaicd_df, "SEGMENT1", "SEGMENT2") + if "KEYWORD_IDX" in compdat_df.columns: compdat_df.drop(["KEYWORD_IDX"], axis=1, inplace=True) - return dict(COMPDAT=compdat_df, COMPSEGS=compsegs_df, WELSEGS=welsegs_df) + if "KEYWORD_IDX" in wsegsicd_df.columns: + wsegsicd_df.drop(["KEYWORD_IDX"], axis=1, inplace=True) + + if "KEYWORD_IDX" in wsegaicd_df.columns: + wsegaicd_df.drop(["KEYWORD_IDX"], axis=1, inplace=True) + + return dict( + COMPDAT=compdat_df, + COMPSEGS=compsegs_df, + WELSEGS=welsegs_df, + WSEGSICD=wsegsicd_df, + WSEGAICD=wsegaicd_df, + ) def postprocess(): diff --git a/ecl2df/opmkeywords/WSEGAICD b/ecl2df/opmkeywords/WSEGAICD new file mode 100644 index 000000000..8927831c7 --- /dev/null +++ b/ecl2df/opmkeywords/WSEGAICD @@ -0,0 +1,107 @@ +{ + "name": "WSEGAICD", + "sections": [ + "SCHEDULE" + ], + "items": [ + { + "name": "WELL", + "value_type": "STRING" + }, + { + "name": "SEGMENT1", + "value_type": "INT" + }, + { + "name": "SEGMENT2", + "value_type": "INT" + }, + { + "name": "STRENGTH", + "value_type": "DOUBLE" + }, + { + "name": "LENGTH", + "value_type": "DOUBLE", + "default": 12.0 + }, + { + "name": "RHO_CAL", + "value_type": "DOUBLE", + "default": 1000.25 + }, + { + "name": "MU_CAL", + "value_type": "DOUBLE", + "default": 1.45 + }, + { + "name": "CRIT_WATFRAC", + "value_type": "DOUBLE" + }, + { + "name": "WIDTH_WATFRAC", + "value_type": "DOUBLE" + }, + { + "name": "MAX_RATIO", + "value_type": "DOUBLE", + "default": 5.0 + }, + { + "name": "SCALING", + "value_type": "INT", + "dimension": -1, + "default": 0 + }, + { + "name": "MAX_RATE", + "value_type": "DOUBLE" + }, + { + "name": "VOLUME_RATE_EXP", + "value_type": "DOUBLE", + "default": 1.0 + }, + { + "name": "VISCOSITY_EXP", + "value_type": "DOUBLE", + "default": 1.0 + }, + { + "name": "FLAG", + "value_type": "STRING", + "default": "OPEN" + }, + { + "name": "OIL_FRAC_EXP_DENS", + "value_type": "DOUBLE", + "default": 1.0 + }, + { + "name": "WATER_FRAC_EXP_DENS", + "value_type": "DOUBLE", + "default": 1.0 + }, + { + "name": "GAS_FRAC_EXP_DENS", + "value_type": "DOUBLE", + "default": 1.0 + }, + { + "name": "OIL_FRAC_EXP_VISC", + "value_type": "DOUBLE", + "default": 1.0 + }, + { + "name": "WATER_FRAC_EXP_VISC", + "value_type": "DOUBLE", + "default": 1.0 + }, + { + "name": "GAS_FRAC_EXP_VISC", + "value_type": "DOUBLE", + "default": 1.0 + } + ] +} diff --git a/ecl2df/opmkeywords/WSEGSICD b/ecl2df/opmkeywords/WSEGSICD new file mode 100644 index 000000000..4a4217434 --- /dev/null +++ b/ecl2df/opmkeywords/WSEGSICD @@ -0,0 +1,63 @@ +{ + "name": "WSEGSICD", + "sections": [ + "SCHEDULE" + ], + "items": [ + { + "name": "WELL", + "value_type": "STRING" + }, + { + "name": "SEGMENT1", + "value_type": "INT" + }, + { + "name": "SEGMENT2", + "value_type": "INT" + }, + { + "name": "STRENGTH", + "value_type": "DOUBLE" + }, + { + "name": "LENGTH", + "value_type": "DOUBLE", + "default": 12.0 + }, + { + "name": "RHO_CAL", + "value_type": "DOUBLE", + "default": 1000.25 + }, + { + "name": "MU_CAL", + "value_type": "DOUBLE", + "default": 1.45 + }, + { + "name": "CRIT_WATFRAC", + "value_type": "DOUBLE", + "default": 0.5 + }, + { + "name": "WIDTH_WATFRAC", + "value_type": "DOUBLE", + "default": 0.05 + }, + { + "name": "SCALING", + "value_type": "INT", + "default": -1 + }, + { + "name": "MAX_RATE", + "value_type": "DOUBLE" + }, + { + "name": "FLAG", + "value_type": "STRING", + "default": "OPEN" + } + ] +} diff --git a/tests/data/reek/eclipse/include/schedule/op6_aicd1_gp.sch b/tests/data/reek/eclipse/include/schedule/op6_aicd1_gp.sch new file mode 100644 index 000000000..0d137cec8 --- /dev/null +++ b/tests/data/reek/eclipse/include/schedule/op6_aicd1_gp.sch @@ -0,0 +1,213 @@ +-- ================================================================================================== +-- +-- Exported by user hsven from RMS11.1 at 2020-06-30 15:41:09 +-- +-- ================================================================================================== + +-- Date: 1 FEB 2003 + +WELSPECS + --WELL GROUP IHEEL JHEEL DREF PHASE DRAD INFEQ SIINS XFLOW PRTAB DENS + 'OP_6' 'DUMMY' 28 37 1575.81971 OIL 1* 1* SHUT 1* 1* 1* / + / + +COMPORD + 'OP_6' INPUT / +/ + + +---------------------------------------------------------------------------------------------------- +-- Output from WellBuilder 1.0 +-- Made in Norway +-- Copyright Equinor +-- Case file : op6_aicd1_gp.case +-- Schedule file : reek_prediction_op6.INC +-- Created by : TKLOV +-- Created at : 30 September 2020 09:46 +---------------------------------------------------------------------------------------------------- + + +COMPDAT +------------------------------------------------------------------------------------------- +-- Well : OP_6 : Lateral : 1 +------------------------------------------------------------------------------------------- +-- WELL I J K K2 FLAG SAT CF DIAM KH SKIN DFACT DIR RO + OP_6 28 37 1 1 OPEN 1* 1.27194551 0.311 114.88788 0.0 1* X 19.652259 / + OP_6 28 37 2 2 OPEN 1* 3.67578858 0.311 336.318088 0.0 1* X 20.924668 / + OP_6 28 37 3 3 OPEN 1* 7.92025953 0.311 727.803499 0.0 1* X 21.373217 / + OP_6 28 37 4 4 OPEN 1* 118.349656 0.311 9740.10833 0.0 1* X 12.784487 / + OP_6 28 37 5 5 OPEN 1* 294.985871 0.311 26721.376 0.0 1* X 19.928724 / + OP_6 28 37 6 6 OPEN 1* 5.28790464 0.311 471.168716 0.0 1* X 18.407388 / + OP_6 28 38 6 6 OPEN 1* 40.4257482 0.311 3312.19194 0.0 1* X 12.535772 / + OP_6 28 38 7 7 OPEN 1* 1.70716613 0.311 150.795009 0.0 1* X 17.661088 / + OP_6 28 38 8 8 OPEN 1* 2.21198615 0.311 192.036154 0.0 1* X 16.284687 / + OP_6 29 38 8 8 OPEN 1* 2.78513556 0.311 239.344926 0.0 1* X 15.535037 / + OP_6 29 38 9 9 OPEN 1* 5.42614956 0.311 463.609065 0.0 1* X 15.127031 / + OP_6 29 38 10 10 OPEN 1* 3.26152723 0.311 276.59607 0.0 1* X 14.621753 / + OP_6 29 39 8 8 OPEN 1* 10.8601698 0.311 875.395434 0.0 1* Y 11.675669 / + OP_6 30 39 8 8 OPEN 1* 33.2444313 0.311 2789.98421 0.0 1* Y 13.946626 / + OP_6 30 39 7 7 OPEN 1* 14.3361235 0.311 1076.6418 0.0 1* Y 8.692897 / + OP_6 30 39 6 6 OPEN 1* 10.9829068 0.311 884.536241 0.0 1* X 11.632887 / + OP_6 30 39 5 5 OPEN 1* 11.8553141 0.311 1025.28895 0.0 1* X 15.997006 / + OP_6 30 40 5 5 OPEN 1* 41.2833991 0.311 3573.62275 0.0 1* X 16.065460 / + OP_6 31 40 5 5 OPEN 1* 69.2228715 0.311 5543.59781 0.0 1* Y 11.353216 / + OP_6 31 40 4 4 OPEN 1* 270.569974 0.311 23121.8021 0.0 1* Y 15.140099 / + OP_6 31 41 4 4 OPEN 1* 68.2881225 0.311 5444.96789 0.0 1* Y 11.143431 / + OP_6 32 41 4 4 OPEN 1* 97.0857644 0.311 7704.03241 0.0 1* Y 10.917474 / + OP_6 32 41 5 5 OPEN 1* 49.9299583 0.311 3823.22019 0.0 1* Y 9.406092 / + OP_6 32 41 6 6 OPEN 1* 1.99590293 0.311 169.511142 0.0 1* Y 14.719107 / + OP_6 32 42 6 6 OPEN 1* 31.0570356 0.311 2642.66942 0.0 1* Y 14.846855 / + OP_6 32 42 7 7 OPEN 1* 10.2562712 0.311 855.75701 0.0 1* Y 13.588228 / + OP_6 33 42 7 7 OPEN 1* 19.5588571 0.311 1663.51215 0.0 1* Y 14.815672 / + OP_6 33 42 8 8 OPEN 1* 45.7100801 0.311 3897.80845 0.0 1* Y 14.991981 / + OP_6 33 43 8 8 OPEN 1* 16.3874512 0.311 1399.32541 0.0 1* Y 15.086781 / +/ + + +WELSEGS +-- WELL SEGMENTTVD SEGMENTMD WBVOLUME INFOTYPE PDROPCOMP MPMODEL + OP_6 0.0 0.0 1* ABS HF- HO / +--------------------------------------------------------------- +-- Well : OP_6 : Lateral : 1 : Tubing layer +--------------------------------------------------------------- +-- SEG SEG2 BRANCH OUT MD TVD DIAM ROUGHNESS + 2 2 1 1 2371.596 1577.726 0.15 0.00065 / + 3 3 1 2 2381.708 1581.539 0.15 0.00065 / + 4 4 1 3 2391.834 1585.358 0.15 0.00065 / + 5 5 1 4 2402.215 1589.201 0.15 0.00065 / + 6 6 1 5 2413.230 1593.026 0.15 0.00065 / + 7 7 1 6 2419.746 1595.162 0.15 0.00065 / + 8 8 1 7 2425.809 1597.064 0.15 0.00065 / + 9 9 1 8 2438.314 1600.723 0.15 0.00065 / + 10 10 1 9 2450.446 1603.903 0.15 0.00065 / + 11 11 1 10 2468.742 1608.086 0.15 0.00065 / + 12 12 1 11 2538.718 1616.383 0.15 0.00065 / + 13 13 1 12 2626.385 1618.627 0.15 0.00065 / + 14 14 1 13 2680.837 1620.095 0.15 0.00065 / + 15 15 1 14 2717.512 1621.083 0.15 0.00065 / + 16 16 1 15 2762.839 1622.305 0.15 0.00065 / + 17 17 1 16 2823.756 1623.947 0.15 0.00065 / + 18 18 1 17 2862.442 1624.989 0.15 0.00065 / + 19 19 1 18 2905.477 1626.149 0.15 0.00065 / + 20 20 1 19 2984.406 1628.276 0.15 0.00065 / + 21 21 1 20 3058.393 1630.270 0.15 0.00065 / + 22 22 1 21 3128.915 1632.171 0.15 0.00065 / + 23 23 1 22 3186.551 1633.724 0.15 0.00065 / + 24 24 1 23 3248.668 1635.398 0.15 0.00065 / + 25 25 1 24 3298.664 1636.746 0.15 0.00065 / + 26 26 1 25 3337.500 1637.792 0.15 0.00065 / + 27 27 1 26 3389.861 1639.204 0.15 0.00065 / + 28 28 1 27 3424.949 1640.149 0.15 0.00065 / + 29 29 1 28 3479.908 1641.630 0.15 0.00065 / + 30 30 1 29 3530.864 1643.004 0.15 0.00065 / +--------------------------------------------------------------- +-- Well : OP_6 : Lateral : 1 : Device layer +--------------------------------------------------------------- +-- SEG SEG2 BRANCH OUT MD TVD DIAM ROUGHNESS + 31 31 2 2 2371.696 1577.726 0.15 0.00065 / -- AICD types + 32 32 3 3 2381.808 1581.539 0.15 0.00065 / -- AICD types + 33 33 4 4 2391.934 1585.358 0.15 0.00065 / -- AICD types + 34 34 5 5 2402.315 1589.201 0.15 0.00065 / -- AICD types + 35 35 6 6 2413.330 1593.026 0.15 0.00065 / -- AICD types + 36 36 7 7 2419.846 1595.162 0.15 0.00065 / -- AICD types + 37 37 8 8 2425.909 1597.064 0.15 0.00065 / -- AICD types + 38 38 9 9 2438.414 1600.723 0.15 0.00065 / -- AICD types + 39 39 10 10 2450.546 1603.903 0.15 0.00065 / -- AICD types + 40 40 11 11 2468.842 1608.086 0.15 0.00065 / -- AICD types + 41 41 12 12 2538.818 1616.383 0.15 0.00065 / -- AICD types + 42 42 13 13 2626.485 1618.627 0.15 0.00065 / -- AICD types + 43 43 14 14 2680.937 1620.095 0.15 0.00065 / -- AICD types + 44 44 15 15 2717.612 1621.083 0.15 0.00065 / -- AICD types + 45 45 16 16 2762.939 1622.305 0.15 0.00065 / -- AICD types + 46 46 17 17 2823.856 1623.947 0.15 0.00065 / -- AICD types + 47 47 18 18 2862.542 1624.989 0.15 0.00065 / -- AICD types + 48 48 19 19 2905.577 1626.149 0.15 0.00065 / -- AICD types + 49 49 20 20 2984.506 1628.276 0.15 0.00065 / -- AICD types + 50 50 21 21 3058.493 1630.270 0.15 0.00065 / -- AICD types + 51 51 22 22 3129.015 1632.171 0.15 0.00065 / -- AICD types + 52 52 23 23 3186.651 1633.724 0.15 0.00065 / -- AICD types + 53 53 24 24 3248.768 1635.398 0.15 0.00065 / -- AICD types + 54 54 25 25 3298.764 1636.746 0.15 0.00065 / -- AICD types + 55 55 26 26 3337.600 1637.792 0.15 0.00065 / -- AICD types + 56 56 27 27 3389.961 1639.204 0.15 0.00065 / -- AICD types + 57 57 28 28 3425.049 1640.149 0.15 0.00065 / -- AICD types + 58 58 29 29 3480.008 1641.630 0.15 0.00065 / -- AICD types + 59 59 30 30 3530.964 1643.004 0.15 0.00065 / -- AICD types +/ + + +COMPSEGS +OP_6 / +------------------------------------------------------- +-- Well : OP_6 : Lateral : 1 +------------------------------------------------------- +-- I J K BRANCH STARTMD ENDMD DIR DEF SEG + 28 37 1 2 2366.541 2376.651 1* 3* 31 / + 28 37 2 3 2376.651 2386.766 1* 3* 32 / + 28 37 3 4 2386.766 2396.902 1* 3* 33 / + 28 37 4 5 2396.902 2407.527 1* 3* 34 / + 28 37 5 6 2407.527 2418.933 1* 3* 35 / + 28 37 6 7 2418.933 2420.559 1* 3* 36 / + 28 38 6 8 2420.559 2431.058 1* 3* 37 / + 28 38 7 9 2431.058 2445.570 1* 3* 38 / + 28 38 8 10 2445.570 2455.323 1* 3* 39 / + 29 38 8 11 2455.323 2482.161 1* 3* 40 / + 29 38 9 12 2482.161 2595.275 1* 3* 41 / + 29 38 10 13 2595.275 2657.496 1* 3* 42 / + 29 39 8 14 2657.496 2704.177 1* 3* 43 / + 30 39 8 15 2704.177 2730.846 1* 3* 44 / + 30 39 7 16 2730.846 2794.831 1* 3* 45 / + 30 39 6 17 2794.831 2852.681 1* 3* 46 / + 30 39 5 18 2852.681 2872.203 1* 3* 47 / + 30 40 5 19 2872.203 2938.751 1* 3* 48 / + 31 40 5 20 2938.751 3030.062 1* 3* 49 / + 31 40 4 21 3030.062 3086.725 1* 3* 50 / + 31 41 4 22 3086.725 3171.104 1* 3* 51 / + 32 41 4 23 3171.104 3201.998 1* 3* 52 / + 32 41 5 24 3201.998 3295.338 1* 3* 53 / + 32 41 6 25 3295.338 3301.991 1* 3* 54 / + 32 42 6 26 3301.991 3373.010 1* 3* 55 / + 32 42 7 27 3373.010 3406.712 1* 3* 56 / + 33 42 7 28 3406.712 3443.186 1* 3* 57 / + 33 42 8 29 3443.186 3516.629 1* 3* 58 / + 33 43 8 30 3516.629 3545.098 1* 3* 59 / +/ + + +WSEGAICD +------------------------------------------------------------------------------------------------------------------ +-- Well : OP_6 : Lateral : 1 +------------------------------------------------------------------------------------------------------------------ +-- WELL SEG SEG2 ALPHA SF RHO VIS DEF X Y FLAG A B C D E F + OP_6 31 31 1.7253e-05 -1.186915444 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 32 32 1.7253e-05 -1.186436656 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 33 33 1.7253e-05 -1.183849919 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 34 34 1.7253e-05 -1.129375625 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 35 35 1.7253e-05 -1.052096302 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 36 36 1.7253e-05 -7.380754682 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 37 37 1.7253e-05 -1.142948579 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 38 38 1.7253e-05 -0.8269297957 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 39 39 1.7253e-05 -1.230341451 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 40 40 1.7253e-05 -0.4471243755 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 41 41 1.7253e-05 -0.1060880295 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 42 42 1.7253e-05 -0.1928604973 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 43 43 1.7253e-05 -0.257062415 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 44 44 1.7253e-05 -0.4499619782 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 45 45 1.7253e-05 -0.187543428 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 46 46 1.7253e-05 -0.2074327654 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 47 47 1.7253e-05 -0.6146964706 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 48 48 1.7253e-05 -0.1803220281 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 49 49 1.7253e-05 -0.131419486 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 50 50 1.7253e-05 -0.2117762041 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 51 51 1.7253e-05 -0.1422150925 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 52 52 1.7253e-05 -0.3884253141 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 53 53 1.7253e-05 -0.1285622593 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 54 54 1.7253e-05 -1.803857549 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 55 55 1.7253e-05 -0.168967892 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 56 56 1.7253e-05 -0.3560628 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 57 57 1.7253e-05 -0.3290018413 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 58 58 1.7253e-05 -0.1633919738 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / + OP_6 59 59 1.7253e-05 -0.4215044548 1000.0 1.0 5* 3.05 0.67 OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / +/ + + diff --git a/tests/data/reek/eclipse/include/schedule/op6_icd1_gp.sch b/tests/data/reek/eclipse/include/schedule/op6_icd1_gp.sch new file mode 100644 index 000000000..8f6878db7 --- /dev/null +++ b/tests/data/reek/eclipse/include/schedule/op6_icd1_gp.sch @@ -0,0 +1,213 @@ +-- ================================================================================================== +-- +-- Exported by user hsven from RMS11.1 at 2020-06-30 15:41:09 +-- +-- ================================================================================================== + +-- Date: 1 FEB 2003 + +WELSPECS + --WELL GROUP IHEEL JHEEL DREF PHASE DRAD INFEQ SIINS XFLOW PRTAB DENS + 'OP_6' 'DUMMY' 28 37 1575.81971 OIL 1* 1* SHUT 1* 1* 1* / + / + +COMPORD + 'OP_6' INPUT / +/ + + +---------------------------------------------------------------------------------------------------- +-- Output from WellBuilder 1.0 +-- Made in Norway +-- Copyright Equinor +-- Case file : op6_icd1_gp.case +-- Schedule file : reek_prediction_op6.INC +-- Created by : TKLOV +-- Created at : 30 September 2020 09:47 +---------------------------------------------------------------------------------------------------- + + +COMPDAT +------------------------------------------------------------------------------------------- +-- Well : OP_6 : Lateral : 1 +------------------------------------------------------------------------------------------- +-- WELL I J K K2 FLAG SAT CF DIAM KH SKIN DFACT DIR RO + OP_6 28 37 1 1 OPEN 1* 1.27194551 0.311 114.88788 0.0 1* X 19.652259 / + OP_6 28 37 2 2 OPEN 1* 3.67578858 0.311 336.318088 0.0 1* X 20.924668 / + OP_6 28 37 3 3 OPEN 1* 7.92025953 0.311 727.803499 0.0 1* X 21.373217 / + OP_6 28 37 4 4 OPEN 1* 118.349656 0.311 9740.10833 0.0 1* X 12.784487 / + OP_6 28 37 5 5 OPEN 1* 294.985871 0.311 26721.376 0.0 1* X 19.928724 / + OP_6 28 37 6 6 OPEN 1* 5.28790464 0.311 471.168716 0.0 1* X 18.407388 / + OP_6 28 38 6 6 OPEN 1* 40.4257482 0.311 3312.19194 0.0 1* X 12.535772 / + OP_6 28 38 7 7 OPEN 1* 1.70716613 0.311 150.795009 0.0 1* X 17.661088 / + OP_6 28 38 8 8 OPEN 1* 2.21198615 0.311 192.036154 0.0 1* X 16.284687 / + OP_6 29 38 8 8 OPEN 1* 2.78513556 0.311 239.344926 0.0 1* X 15.535037 / + OP_6 29 38 9 9 OPEN 1* 5.42614956 0.311 463.609065 0.0 1* X 15.127031 / + OP_6 29 38 10 10 OPEN 1* 3.26152723 0.311 276.59607 0.0 1* X 14.621753 / + OP_6 29 39 8 8 OPEN 1* 10.8601698 0.311 875.395434 0.0 1* Y 11.675669 / + OP_6 30 39 8 8 OPEN 1* 33.2444313 0.311 2789.98421 0.0 1* Y 13.946626 / + OP_6 30 39 7 7 OPEN 1* 14.3361235 0.311 1076.6418 0.0 1* Y 8.692897 / + OP_6 30 39 6 6 OPEN 1* 10.9829068 0.311 884.536241 0.0 1* X 11.632887 / + OP_6 30 39 5 5 OPEN 1* 11.8553141 0.311 1025.28895 0.0 1* X 15.997006 / + OP_6 30 40 5 5 OPEN 1* 41.2833991 0.311 3573.62275 0.0 1* X 16.065460 / + OP_6 31 40 5 5 OPEN 1* 69.2228715 0.311 5543.59781 0.0 1* Y 11.353216 / + OP_6 31 40 4 4 OPEN 1* 270.569974 0.311 23121.8021 0.0 1* Y 15.140099 / + OP_6 31 41 4 4 OPEN 1* 68.2881225 0.311 5444.96789 0.0 1* Y 11.143431 / + OP_6 32 41 4 4 OPEN 1* 97.0857644 0.311 7704.03241 0.0 1* Y 10.917474 / + OP_6 32 41 5 5 OPEN 1* 49.9299583 0.311 3823.22019 0.0 1* Y 9.406092 / + OP_6 32 41 6 6 OPEN 1* 1.99590293 0.311 169.511142 0.0 1* Y 14.719107 / + OP_6 32 42 6 6 OPEN 1* 31.0570356 0.311 2642.66942 0.0 1* Y 14.846855 / + OP_6 32 42 7 7 OPEN 1* 10.2562712 0.311 855.75701 0.0 1* Y 13.588228 / + OP_6 33 42 7 7 OPEN 1* 19.5588571 0.311 1663.51215 0.0 1* Y 14.815672 / + OP_6 33 42 8 8 OPEN 1* 45.7100801 0.311 3897.80845 0.0 1* Y 14.991981 / + OP_6 33 43 8 8 OPEN 1* 16.3874512 0.311 1399.32541 0.0 1* Y 15.086781 / +/ + + +WELSEGS +-- WELL SEGMENTTVD SEGMENTMD WBVOLUME INFOTYPE PDROPCOMP MPMODEL + OP_6 0.0 0.0 1* ABS HF- HO / +--------------------------------------------------------------- +-- Well : OP_6 : Lateral : 1 : Tubing layer +--------------------------------------------------------------- +-- SEG SEG2 BRANCH OUT MD TVD DIAM ROUGHNESS + 2 2 1 1 2371.596 1577.726 0.15 0.00065 / + 3 3 1 2 2381.708 1581.539 0.15 0.00065 / + 4 4 1 3 2391.834 1585.358 0.15 0.00065 / + 5 5 1 4 2402.215 1589.201 0.15 0.00065 / + 6 6 1 5 2413.230 1593.026 0.15 0.00065 / + 7 7 1 6 2419.746 1595.162 0.15 0.00065 / + 8 8 1 7 2425.809 1597.064 0.15 0.00065 / + 9 9 1 8 2438.314 1600.723 0.15 0.00065 / + 10 10 1 9 2450.446 1603.903 0.15 0.00065 / + 11 11 1 10 2468.742 1608.086 0.15 0.00065 / + 12 12 1 11 2538.718 1616.383 0.15 0.00065 / + 13 13 1 12 2626.385 1618.627 0.15 0.00065 / + 14 14 1 13 2680.837 1620.095 0.15 0.00065 / + 15 15 1 14 2717.512 1621.083 0.15 0.00065 / + 16 16 1 15 2762.839 1622.305 0.15 0.00065 / + 17 17 1 16 2823.756 1623.947 0.15 0.00065 / + 18 18 1 17 2862.442 1624.989 0.15 0.00065 / + 19 19 1 18 2905.477 1626.149 0.15 0.00065 / + 20 20 1 19 2984.406 1628.276 0.15 0.00065 / + 21 21 1 20 3058.393 1630.270 0.15 0.00065 / + 22 22 1 21 3128.915 1632.171 0.15 0.00065 / + 23 23 1 22 3186.551 1633.724 0.15 0.00065 / + 24 24 1 23 3248.668 1635.398 0.15 0.00065 / + 25 25 1 24 3298.664 1636.746 0.15 0.00065 / + 26 26 1 25 3337.500 1637.792 0.15 0.00065 / + 27 27 1 26 3389.861 1639.204 0.15 0.00065 / + 28 28 1 27 3424.949 1640.149 0.15 0.00065 / + 29 29 1 28 3479.908 1641.630 0.15 0.00065 / + 30 30 1 29 3530.864 1643.004 0.15 0.00065 / +--------------------------------------------------------------- +-- Well : OP_6 : Lateral : 1 : Device layer +--------------------------------------------------------------- +-- SEG SEG2 BRANCH OUT MD TVD DIAM ROUGHNESS + 31 31 2 2 2371.696 1577.726 0.15 0.00065 / -- ICD types + 32 32 3 3 2381.808 1581.539 0.15 0.00065 / -- ICD types + 33 33 4 4 2391.934 1585.358 0.15 0.00065 / -- ICD types + 34 34 5 5 2402.315 1589.201 0.15 0.00065 / -- ICD types + 35 35 6 6 2413.330 1593.026 0.15 0.00065 / -- ICD types + 36 36 7 7 2419.846 1595.162 0.15 0.00065 / -- ICD types + 37 37 8 8 2425.909 1597.064 0.15 0.00065 / -- ICD types + 38 38 9 9 2438.414 1600.723 0.15 0.00065 / -- ICD types + 39 39 10 10 2450.546 1603.903 0.15 0.00065 / -- ICD types + 40 40 11 11 2468.842 1608.086 0.15 0.00065 / -- ICD types + 41 41 12 12 2538.818 1616.383 0.15 0.00065 / -- ICD types + 42 42 13 13 2626.485 1618.627 0.15 0.00065 / -- ICD types + 43 43 14 14 2680.937 1620.095 0.15 0.00065 / -- ICD types + 44 44 15 15 2717.612 1621.083 0.15 0.00065 / -- ICD types + 45 45 16 16 2762.939 1622.305 0.15 0.00065 / -- ICD types + 46 46 17 17 2823.856 1623.947 0.15 0.00065 / -- ICD types + 47 47 18 18 2862.542 1624.989 0.15 0.00065 / -- ICD types + 48 48 19 19 2905.577 1626.149 0.15 0.00065 / -- ICD types + 49 49 20 20 2984.506 1628.276 0.15 0.00065 / -- ICD types + 50 50 21 21 3058.493 1630.270 0.15 0.00065 / -- ICD types + 51 51 22 22 3129.015 1632.171 0.15 0.00065 / -- ICD types + 52 52 23 23 3186.651 1633.724 0.15 0.00065 / -- ICD types + 53 53 24 24 3248.768 1635.398 0.15 0.00065 / -- ICD types + 54 54 25 25 3298.764 1636.746 0.15 0.00065 / -- ICD types + 55 55 26 26 3337.600 1637.792 0.15 0.00065 / -- ICD types + 56 56 27 27 3389.961 1639.204 0.15 0.00065 / -- ICD types + 57 57 28 28 3425.049 1640.149 0.15 0.00065 / -- ICD types + 58 58 29 29 3480.008 1641.630 0.15 0.00065 / -- ICD types + 59 59 30 30 3530.964 1643.004 0.15 0.00065 / -- ICD types +/ + + +COMPSEGS +OP_6 / +------------------------------------------------------- +-- Well : OP_6 : Lateral : 1 +------------------------------------------------------- +-- I J K BRANCH STARTMD ENDMD DIR DEF SEG + 28 37 1 2 2366.541 2376.651 1* 3* 31 / + 28 37 2 3 2376.651 2386.766 1* 3* 32 / + 28 37 3 4 2386.766 2396.902 1* 3* 33 / + 28 37 4 5 2396.902 2407.527 1* 3* 34 / + 28 37 5 6 2407.527 2418.933 1* 3* 35 / + 28 37 6 7 2418.933 2420.559 1* 3* 36 / + 28 38 6 8 2420.559 2431.058 1* 3* 37 / + 28 38 7 9 2431.058 2445.570 1* 3* 38 / + 28 38 8 10 2445.570 2455.323 1* 3* 39 / + 29 38 8 11 2455.323 2482.161 1* 3* 40 / + 29 38 9 12 2482.161 2595.275 1* 3* 41 / + 29 38 10 13 2595.275 2657.496 1* 3* 42 / + 29 39 8 14 2657.496 2704.177 1* 3* 43 / + 30 39 8 15 2704.177 2730.846 1* 3* 44 / + 30 39 7 16 2730.846 2794.831 1* 3* 45 / + 30 39 6 17 2794.831 2852.681 1* 3* 46 / + 30 39 5 18 2852.681 2872.203 1* 3* 47 / + 30 40 5 19 2872.203 2938.751 1* 3* 48 / + 31 40 5 20 2938.751 3030.062 1* 3* 49 / + 31 40 4 21 3030.062 3086.725 1* 3* 50 / + 31 41 4 22 3086.725 3171.104 1* 3* 51 / + 32 41 4 23 3171.104 3201.998 1* 3* 52 / + 32 41 5 24 3201.998 3295.338 1* 3* 53 / + 32 41 6 25 3295.338 3301.991 1* 3* 54 / + 32 42 6 26 3301.991 3373.010 1* 3* 55 / + 32 42 7 27 3373.010 3406.712 1* 3* 56 / + 33 42 7 28 3406.712 3443.186 1* 3* 57 / + 33 42 8 29 3443.186 3516.629 1* 3* 58 / + 33 43 8 30 3516.629 3545.098 1* 3* 59 / +/ + + +WSEGSICD +------------------------------------------------------------ +-- Well : OP_6 : Lateral : 1 +------------------------------------------------------------ +-- WELL SEG SEG2 ALPHA SF RHO VIS WCT + OP_6 31 31 0.0001 -1.186915444 1000.0 1.0 0.5 / + OP_6 32 32 0.0001 -1.186436656 1000.0 1.0 0.5 / + OP_6 33 33 0.0001 -1.183849919 1000.0 1.0 0.5 / + OP_6 34 34 0.0001 -1.129375625 1000.0 1.0 0.5 / + OP_6 35 35 0.0001 -1.052096302 1000.0 1.0 0.5 / + OP_6 36 36 0.0001 -7.380754682 1000.0 1.0 0.5 / + OP_6 37 37 0.0001 -1.142948579 1000.0 1.0 0.5 / + OP_6 38 38 0.0001 -0.8269297957 1000.0 1.0 0.5 / + OP_6 39 39 0.0001 -1.230341451 1000.0 1.0 0.5 / + OP_6 40 40 0.0001 -0.4471243755 1000.0 1.0 0.5 / + OP_6 41 41 0.0001 -0.1060880295 1000.0 1.0 0.5 / + OP_6 42 42 0.0001 -0.1928604973 1000.0 1.0 0.5 / + OP_6 43 43 0.0001 -0.257062415 1000.0 1.0 0.5 / + OP_6 44 44 0.0001 -0.4499619782 1000.0 1.0 0.5 / + OP_6 45 45 0.0001 -0.187543428 1000.0 1.0 0.5 / + OP_6 46 46 0.0001 -0.2074327654 1000.0 1.0 0.5 / + OP_6 47 47 0.0001 -0.6146964706 1000.0 1.0 0.5 / + OP_6 48 48 0.0001 -0.1803220281 1000.0 1.0 0.5 / + OP_6 49 49 0.0001 -0.131419486 1000.0 1.0 0.5 / + OP_6 50 50 0.0001 -0.2117762041 1000.0 1.0 0.5 / + OP_6 51 51 0.0001 -0.1422150925 1000.0 1.0 0.5 / + OP_6 52 52 0.0001 -0.3884253141 1000.0 1.0 0.5 / + OP_6 53 53 0.0001 -0.1285622593 1000.0 1.0 0.5 / + OP_6 54 54 0.0001 -1.803857549 1000.0 1.0 0.5 / + OP_6 55 55 0.0001 -0.168967892 1000.0 1.0 0.5 / + OP_6 56 56 0.0001 -0.3560628 1000.0 1.0 0.5 / + OP_6 57 57 0.0001 -0.3290018413 1000.0 1.0 0.5 / + OP_6 58 58 0.0001 -0.1633919738 1000.0 1.0 0.5 / + OP_6 59 59 0.0001 -0.4215044548 1000.0 1.0 0.5 / +/ + + diff --git a/tests/test_compdat.py b/tests/test_compdat.py index 99e09ce34..c10ca0758 100644 --- a/tests/test_compdat.py +++ b/tests/test_compdat.py @@ -1,4 +1,4 @@ -"""Test module for nnc""" +"""Test module for compdat""" import sys from pathlib import Path @@ -13,7 +13,12 @@ TESTDIR = Path(__file__).absolute().parent DATAFILE = str(TESTDIR / "data/reek/eclipse/model/2_R001_REEK-0.DATA") -SCHFILE = str(TESTDIR / "./data/reek/eclipse/include/schedule/reek_history.sch") +SCHFILE = str(TESTDIR / "data/reek/eclipse/include/schedule/reek_history.sch") + +# Reek cases with multisegment well OP_6 including +# AICD and ICD completion from WellBuilder +SCHFILE_AICD = str(TESTDIR / "data/reek/eclipse/include/schedule/op6_aicd1_gp.sch") +SCHFILE_ICD = str(TESTDIR / "data/reek/eclipse/include/schedule/op6_icd1_gp.sch") def test_df(): @@ -427,3 +432,71 @@ def test_defaulted_compdat_i_j(tmpdir): assert compdat_df[compdat_df["DATE"].astype(str) == "2040-01-01"]["J"].unique() == [ 33 ] + + +# Multisegement well testing +def test_msw_schfile2df(): + """Test that we can process individual files with AICD and ICD MSW""" + deck = EclFiles.file2deck(SCHFILE_AICD) + compdfs = compdat.deck2dfs(deck) + assert not compdfs["WSEGAICD"].empty + assert not compdfs["WSEGAICD"].columns.empty + + deck = EclFiles.file2deck(SCHFILE_ICD) + compdfs = compdat.deck2dfs(deck) + assert not compdfs["WSEGSICD"].empty + assert not compdfs["WSEGSICD"].columns.empty + + +def test_msw_str2df(): + """Testing making a dataframe from an explicit string including MSW""" + schstr = """ +WELSPECS + 'OP_6' 'DUMMY' 28 37 1575.82 OIL 0.0 'STD' 'SHUT' 'YES' 0 'SEG' / +/ + +COMPDAT + 'OP_6' 28 37 1 1 OPEN 0 1.2719 0.311 114.887 0.0 0.0 'X' 19.65 / +/ + +WELSEGS +-- WELL SEGMENTTVD SEGMENTMD WBVOLUME INFOTYPE PDROPCOMP MPMODEL + 'OP_6' 0.0 0.0 1.0E-5 'ABS' 'HF-' 'HO' / +-- SEG SEG2 BRANCH OUT MD TVD DIAM ROUGHNESS + 2 2 1 1 2371.596 1577.726 0.15 0.00065 / +/ + +COMPSEGS + 'OP_6' / +-- I J K BRANCH STARTMD ENDMD DIR DEF SEG + 28 37 1 2 2366.541 2376.651 1* 3* 31 / +/ + +WSEGAICD +-- WELL SEG SEG2 ALPHA SF RHO VIS EMU DEF X Y +-- FLAG A B C D E F + OP_6 31 31 1.7e-05 -1.18 1000 1.0 0.5 4* 3.05 0.67 + OPEN 1.0 1.0 1.0 2.43 1.18 10.0 / +/ + +WSEGSICD +-- WELL SEG SEG2 ALPHA SF RHO VIS WCT + OP_6 31 31 0.0001 -1.186915444 1000.0 1.0 0.5 / +/ +""" + deck = EclFiles.str2deck(schstr) + compdfs = compdat.deck2dfs(deck) + wsegaicd = compdfs["WSEGAICD"] + wsegsicd = compdfs["WSEGSICD"] + + # Test WSEGAICD + assert len(wsegaicd) == 1 + assert "WELL" in wsegaicd + assert wsegaicd["WELL"].unique()[0] == "OP_6" + assert len(wsegaicd.dropna(axis=1, how="all").iloc[0]) == 19 + + # Test WSEGSICD + assert len(wsegsicd) == 1 + assert "WELL" in wsegsicd + assert wsegsicd["WELL"].unique()[0] == "OP_6" + assert len(wsegsicd.dropna(axis=1, how="all").iloc[0]) == 11 From d40c39d45b96aa3ec122598584b8152cdf74983b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= Date: Wed, 25 Nov 2020 10:17:28 +0100 Subject: [PATCH 08/11] f --- tests/test_logging.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_logging.py b/tests/test_logging.py index f7db153de..31bf1a61a 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -1,4 +1,3 @@ -import logging import argparse import pytest From 77325d8b22e3e6ec902e067aa8ec66f8f5a13bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= Date: Wed, 25 Nov 2020 11:11:47 +0100 Subject: [PATCH 09/11] Use subprocess in order to test endpoint --- tests/test_logging.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/test_logging.py b/tests/test_logging.py index 31bf1a61a..bbc72e9cd 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -1,4 +1,4 @@ -import argparse +import subprocess import pytest @@ -7,21 +7,15 @@ @pytest.mark.parametrize("verbose", [False, True]) -def test_grid_logging(caplog, tmp_path, verbose): +def test_grid_logging(tmp_path, verbose): - args = argparse.Namespace( - verbose=verbose, - DATAFILE=DATAFILE, - vectors="*", - rstdates="", - dropconstants=False, - stackdates=False, - output=tmp_path / "eclgrid.csv", - ) + commands = ["ecl2csv", "grid", DATAFILE, "--output", tmp_path / "eclgrid.csv"] + if verbose: + commands.append("-v") - grid_main(args) + result = subprocess.run(commands, check=True, capture_output=True) if verbose: - assert caplog.records + assert "INFO:" in result.stderr.decode() else: - assert caplog.records == [] + assert "INFO:" not in result.stderr.decode() From ac0e11140a91c4f6920c2df2f654c04e1cbf2c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= Date: Wed, 25 Nov 2020 11:13:42 +0100 Subject: [PATCH 10/11] Remove unused import --- tests/test_logging.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_logging.py b/tests/test_logging.py index bbc72e9cd..04a9cab35 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -2,7 +2,6 @@ import pytest -from ecl2df.grid import grid_main from test_grid import DATAFILE From 87856c28ae241f0b38b8325a32e747f89f2ea18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= Date: Wed, 25 Nov 2020 11:31:37 +0100 Subject: [PATCH 11/11] Skip new test on Python 3.6 --- tests/test_logging.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_logging.py b/tests/test_logging.py index 04a9cab35..4136336b1 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -1,3 +1,4 @@ +import sys import subprocess import pytest @@ -5,6 +6,7 @@ from test_grid import DATAFILE +@pytest.mark.skipif(sys.version_info < (3, 7), reason="Requires Python 3.7 or higher") @pytest.mark.parametrize("verbose", [False, True]) def test_grid_logging(tmp_path, verbose): @@ -13,8 +15,6 @@ def test_grid_logging(tmp_path, verbose): commands.append("-v") result = subprocess.run(commands, check=True, capture_output=True) + output = result.stdout.decode() + result.stderr.decode() - if verbose: - assert "INFO:" in result.stderr.decode() - else: - assert "INFO:" not in result.stderr.decode() + assert "INFO:" in output if verbose else "INFO:" not in output