def test_update_simdata_from_rft_norne(norne_data): """Similar test as the reek version, but the Norne RFT file does not contain saturations, and in libecl terms contains EclPLTCell as opposed to EclRFTCell as in Reek""" grid = EclGrid(ECL_BASE_NORNE + ".EGRID") rft = EclRFTFile(ECL_BASE_NORNE + ".RFT") rft_well_date = rft.get("C-3H", datetime.date(1999, 5, 4)) # A trajectory point for an active cell in Norne, picked # from a line in gendata_rft_input_files/C-3H.txt point = TrajectoryPoint(455752.59771598293, 7321015.949386452, 2785.78173828125, 2785.78173828125) assert point.grid_ijk is None assert point.pressure is None assert point.swat is None assert point.sgas is None assert point.soil is None point.set_ijk( grid.find_cell(point.utm_x, point.utm_y, point.true_vertical_depth)) assert point.grid_ijk == (8, 12, 20) # Zero-indexed integers. point.update_simdata_from_rft(rft_well_date) # There is no saturation data in the Norne binary output, then these # should be None assert point.swat is None assert point.sgas is None assert point.soil is None # Construct a Trajectory from the point traj = Trajectory([]) traj.trajectory_points = [point] # (can't initialize from list of points) dframe = traj.to_dataframe() assert {"i", "j", "k", "pressure"}.issubset(set(dframe)) assert "swat" not in dframe
def test_update_simdata_from_rft_reek(reek_data): """Test data extraction from the binary Eclipse files for a single well point using TrajectoryPoint.update_simdata_from_rft()""" grid = EclGrid(ECL_BASE_REEK + ".EGRID") rft = EclRFTFile(ECL_BASE_REEK + ".RFT") rft_well_date = rft.get("OP_1", datetime.date(2000, 2, 1)) # A trajectory point for an active cell in reek: point = TrajectoryPoint(462608.57, 5934210.96, 1624.38, 1624.38) assert point.grid_ijk is None assert point.pressure is None assert point.swat is None assert point.sgas is None assert point.soil is None point.set_ijk( grid.find_cell(point.utm_x, point.utm_y, point.true_vertical_depth)) assert point.grid_ijk == (28, 27, 7) point.update_simdata_from_rft(rft_well_date) assert np.isclose(point.pressure, 304.37) assert np.isclose(point.swat, 0.151044) assert np.isclose(point.soil, 1 - 0.151044) assert np.isclose(point.sgas, 0.0) # Construct a Trajectory from the point traj = Trajectory([]) traj.trajectory_points = [point] # (can't initialize from list of points) dframe = traj.to_dataframe() assert {"i", "j", "k", "pressure", "soil", "sgas", "swat"}.issubset(set(dframe))
def test_PLT(self): rft_file = EclRFTFile( self.createTestPath("Statoil/ECLIPSE/Heidrun/RFT/2C3_MR61.RFT")) rft0 = rft_file[0] rft1 = rft_file[1] rft2 = rft_file[2] rft3 = rft_file[3] self.assertTrue(rft0.is_RFT()) self.assertTrue(rft1.is_RFT()) self.assertTrue(rft2.is_PLT()) self.assertTrue(rft3.is_PLT()) self.assertEqual(len(rft0), 42) self.assertEqual(len(rft1), 37) self.assertEqual(len(rft2), 42) self.assertEqual(len(rft3), 37) self.assertFloatEqual(rft0[0].pressure, 0.22919502E+03) self.assertFloatEqual(rft0[0].depth, 0.21383721E+04) self.assertFloatEqual(rft1[0].pressure, 0.22977950E+03) self.assertFloatEqual(rft1[0].depth, 0.21384775E+04) self.assertFloatEqual(rft2[0].pressure, 0.19142435E+03) self.assertFloatEqual(rft2[0].depth, 0.21383721E+04)
def test_RFT_load(self): rftFile = EclRFTFile(self.RFT_file) rft = rftFile[0] cell = rft.ijkget((32, 53, 0)) self.assertIsInstance(cell, EclRFTCell) self.assertEqual(2, rftFile.size()) self.assertEqual(0, rftFile.size(well="OP*")) self.assertEqual(0, rftFile.size(well="XXX")) self.assertEqual(1, rftFile.size(date=datetime.date(2000, 6, 1))) self.assertEqual(0, rftFile.size(date=datetime.date(2000, 6, 17))) cell = rft.ijkget((30, 20, 1880)) self.assertIsNone(cell) for rft in rftFile: self.assertTrue(rft.is_RFT()) self.assertFalse(rft.is_SEGMENT()) self.assertFalse(rft.is_PLT()) self.assertFalse(rft.is_MSW()) for cell in rft: self.assertIsInstance(cell, EclRFTCell) cell0 = rft.iget_sorted(0) self.assertIsInstance(cell, EclRFTCell) rft.sort() for h in rftFile.getHeaders(): print(h) self.assertIsInstance(h[1], datetime.date)
def test_PLT_load(self): pltFile = EclRFTFile(self.PLT_file) plt = pltFile[11] self.assertTrue(plt.is_PLT()) self.assertFalse(plt.is_SEGMENT()) self.assertFalse(plt.is_RFT()) self.assertFalse(plt.is_MSW()) for cell in plt: self.assertIsInstance(cell, EclPLTCell)
def test_update_simdata_outside_grid(tmpdir): grid = EclGrid(ECL_BASE_REEK + ".EGRID") rft = EclRFTFile(ECL_BASE_REEK + ".RFT") rft_well_date = rft.get("OP_1", datetime.date(2000, 2, 1)) # A point outside the grid: point = TrajectoryPoint(45000, 60000000, 1, 1) point.set_ijk( grid.find_cell(point.utm_x, point.utm_y, point.true_vertical_depth)) assert point.grid_ijk is None # There is no Exception raised by set_ijk() point.update_simdata_from_rft(rft_well_date) assert point.pressure is None # Since we are outside the grid. # Construct a Trajectory from the point traj = Trajectory([]) traj.trajectory_points = [point] # (can't initialize from list of points) dframe = traj.to_dataframe() assert not set(dframe).intersection({"i", "j", "k", "pressure", "swat"})
def valid_eclbase(file_path): """ The filename is assumed to be without extension and two files must be present, <filename>.RFT and <filename>.EGRID. Loads both files with respective loaders and returns them Parameters ---------- filename : string Filename to open Returns ------- Tuple Returns a tuple with an ecl grid instance and an rft instance """ rft_filepath = file_path + ".RFT" if not os.path.isfile(rft_filepath): raise argparse.ArgumentTypeError( "The path {} does not exist".format(rft_filepath) ) try: ecl_rft = EclRFTFile(rft_filepath) except (IOError, OSError) as err: raise argparse.ArgumentTypeError( ( "Could not load eclipse RFT from file: {fname}\n" "With the following error:" "\n{ecl_err}" ).format(fname=rft_filepath, ecl_err=err) ) grid_filepath = file_path + ".EGRID" if not os.path.isfile(grid_filepath): raise argparse.ArgumentTypeError( "The path {} does not exist".format(grid_filepath) ) try: ecl_grid = EclGrid(grid_filepath) except (IOError, OSError) as err: raise argparse.ArgumentTypeError( ( "Could not load eclipse Grid from file: {fname}\n" "With the following error:\n" "{ecl_err}" ).format(fname=grid_filepath, ecl_err=err) ) return ecl_grid, ecl_rft
def test_update_simdata_outside_well(tmpdir): grid = EclGrid(ECL_BASE_REEK + ".EGRID") rft = EclRFTFile(ECL_BASE_REEK + ".RFT") rft_well_date = rft.get("OP_1", datetime.date(2000, 2, 1)) # A point in the grid, but not related to the well point = TrajectoryPoint(462825.55, 5934025.52, 1623.19, 1623.19) point.set_ijk( grid.find_cell(point.utm_x, point.utm_y, point.true_vertical_depth)) # NB: grid_ijk ints start at zero, ResInsight and ecl2df report this as (29, 29, 7) assert point.grid_ijk == (28, 28, 6) point.update_simdata_from_rft(rft_well_date) assert point.pressure is None assert point.swat is None assert point.sgas is None assert point.soil is None # Construct a Trajectory from the point traj = Trajectory([]) traj.trajectory_points = [point] # (can't initialize from list of points) dframe = traj.to_dataframe() assert {"i", "j", "k"}.issubset(set(dframe)) assert not set(dframe).intersection({"pressure", "swat", "soil", "sgas"})
def test_exceptions(self): with self.assertRaises(IndexError): rftFile = EclRFTFile(self.RFT_file) rft = rftFile[100]