def test_get_faciesfraction_some_wells(): """Import some wells and get the facies fractions per zone, for wells < 70 degrees inclination. """ wlist = [] for w in sorted(glob.glob(wfiles2)): wlist.append(Well(w, zonelogname='Zonelog')) logger.info('Imported well {}'.format(w)) mypoints = Points() facname = 'Facies' fcode = [1] nwell = mypoints.dfrac_from_wells(wlist, facname, fcode, zonelist=None, incl_limit=70) # rename column mypoints.zname = 'FACFRAC' logger.info('Number of wells is %s, DATAFRAME:\n, %s', nwell, mypoints.dataframe) myquery = 'WELLNAME == "OP_1" and ZONE == 1' usedf = mypoints.dataframe.query(myquery) assert abs(usedf[mypoints.zname].values[0] - 0.86957) < 0.001 mypoints.to_file('TMP/ffrac_per_zone.rmsasc', fformat='rms_attr', attributes=['WELLNAME', 'ZONE'], pfilter={'ZONE': [1]})
def test_get_zone_thickness_some_wells(testpath, tmp_path): """Import some wells and get the zone thicknesses""" wlist = [ Well(wpath, zonelogname="Zonelog") for wpath in glob.glob(str(testpath / WFILES2)) ] mypoints = Points() mypoints.from_wells(wlist, tops=False, zonelist=(1, 22)) mypoints.to_file( tmp_path / "zpoints_w_so622.rmsasc", fformat="rms_attr", attributes=["WellName", "ZoneName"], pfilter={"ZoneName": ["SO622"]}, ) # filter, for backwards compatibility mypoints.to_file( tmp_path / "zpoints_w_so622_again.rmsasc", fformat="rms_attr", attributes=["WellName", "ZoneName"], filter={"ZoneName": ["SO622"]}, )
def test_map_to_points(reek_map): """Get the list of the coordinates""" px = Points() surf = RegularSurface(ftop1) assert isinstance(surf, RegularSurface) tsetup.assert_almostequal(surf.values.mean(), 0.5755830099, 0.001) px.from_surface(surf) # convert to a Points instance px = Points(reek_map) # or # px.from_surface(...) outf = os.path.join(td, 'points_from_surf_reek.poi') px.to_file(outf) assert px.dataframe['X_UTME'].min() == 456719.75 tsetup.assert_almostequal(px.dataframe['Z_TVDSS'].mean(), 0.57558, 0.001) # read the output for comparison pxx = Points(outf) tsetup.assert_almostequal(px.dataframe['Z_TVDSS'].mean(), pxx.dataframe['Z_TVDSS'].mean(), 0.00001)
def test_export_points(): """Export XYZ points to file, various formats""" mypoints = Points(POINTSET4) # should guess based on extesion print(mypoints.dataframe) mypoints.to_file(join(TMPD, "poi_export1.rmsattr"), fformat="rms_attr")
def test_get_faciesfraction_some_wells(testpath, tmp_path): """Import some wells and get the facies fractions per zone, for wells < 70 degrees inclination. """ wlist = [ Well(wpath, zonelogname="Zonelog") for wpath in glob.glob(str(testpath / WFILES2)) ] mypoints = Points() facname = "Facies" fcode = [1] mypoints.dfrac_from_wells(wlist, facname, fcode, zonelist=None, incl_limit=70) # rename column mypoints.zname = "FACFRAC" myquery = 'WELLNAME == "OP_1" and ZONE == 1' usedf = mypoints.dataframe.query(myquery) assert abs(usedf[mypoints.zname].values[0] - 0.86957) < 0.001 mypoints.to_file( tmp_path / "ffrac_per_zone.rmsasc", fformat="rms_attr", attributes=["WELLNAME", "ZONE"], pfilter={"ZONE": [1]}, )
def test_get_zone_thickness_some_wells(): """Import some wells and get the zone thicknesses""" wlist = [] for w in glob.glob(wfiles2): wlist.append(Well(w, zonelogname='Zonelog')) logger.info('Imported well {}'.format(w)) mypoints = Points() nwell = mypoints.from_wells(wlist, tops=False, zonelist=(1, 22)) print(nwell, '\n', mypoints.dataframe) mypoints.to_file('TMP/zpoints_w_so622.rmsasc', fformat='rms_attr', attributes=['WellName', 'ZoneName'], pfilter={'ZoneName': ['SO622']}) # filter, for backwards compatibility mypoints.to_file('TMP/zpoints_w_so622_again.rmsasc', fformat='rms_attr', attributes=['WellName', 'ZoneName'], filter={'ZoneName': ['SO622']}) logger.info('Number of well made to tops: {}'.format(nwell))
def test_get_zone_tops_some_wells(): """Import some well and get the zone tops""" wlist = [] for w in glob.glob(str(WFILES2)): wlist.append(Well(w, zonelogname="Zonelog")) logger.info("Imported well {}".format(w)) mypoints = Points() nwell = mypoints.from_wells(wlist) print(mypoints.dataframe) logger.info("Number of well made to tops: {}".format(nwell)) mypoints.to_file( "TMP/points_w1_many.rmsasc", fformat="rms_attr", attributes=["WellName", "TopName"], ) mypoints.to_file( "TMP/points_w1_many.rmswpicks", fformat="rms_wellpicks", wcolumn="WellName", hcolumn="TopName", )
def test_get_faciesfraction_some_wells(): """Import some wells and get the facies fractions per zone, for wells < 70 degrees inclination. """ wlist = [] for w in sorted(glob.glob(str(WFILES2))): wlist.append(Well(w, zonelogname="Zonelog")) logger.info("Imported well {}".format(w)) mypoints = Points() facname = "Facies" fcode = [1] nwell = mypoints.dfrac_from_wells( wlist, facname, fcode, zonelist=None, incl_limit=70 ) # rename column mypoints.zname = "FACFRAC" logger.info("Number of wells is %s, DATAFRAME:\n, %s", nwell, mypoints.dataframe) myquery = 'WELLNAME == "OP_1" and ZONE == 1' usedf = mypoints.dataframe.query(myquery) assert abs(usedf[mypoints.zname].values[0] - 0.86957) < 0.001 mypoints.to_file( "TMP/ffrac_per_zone.rmsasc", fformat="rms_attr", attributes=["WELLNAME", "ZONE"], pfilter={"ZONE": [1]}, )
def test_get_zone_thickness_some_wells(): """Import some wells and get the zone thicknesses""" wlist = [] for w in glob.glob(str(WFILES2)): wlist.append(Well(w, zonelogname="Zonelog")) logger.info("Imported well {}".format(w)) mypoints = Points() nwell = mypoints.from_wells(wlist, tops=False, zonelist=(1, 22)) print(nwell, "\n", mypoints.dataframe) mypoints.to_file( "TMP/zpoints_w_so622.rmsasc", fformat="rms_attr", attributes=["WellName", "ZoneName"], pfilter={"ZoneName": ["SO622"]}, ) # filter, for backwards compatibility mypoints.to_file( "TMP/zpoints_w_so622_again.rmsasc", fformat="rms_attr", attributes=["WellName", "ZoneName"], filter={"ZoneName": ["SO622"]}, ) logger.info("Number of well made to tops: {}".format(nwell))
def test_get_zone_tops_one_well_w_undef(): """Import a well and get the zone tops, include undef transition""" wlist = [] for w in glob.glob(wfiles1): wlist.append(Well(w, zonelogname="Zonelog")) logger.info("Imported well {}".format(w)) mypoints = Points() nwell = mypoints.from_wells(wlist, use_undef=True) print(mypoints.dataframe) logger.info("Number of well made to tops: {}".format(nwell)) mypoints.to_file( "TMP/points_w1_w_undef.rmsasc", fformat="rms_attr", attributes=["WellName", "TopName"], ) mypoints.to_file( "TMP/points_w1_w_undef.rmswpicks", fformat="rms_wellpicks", wcolumn="WellName", hcolumn="TopName", )
def test_import_rmsattr_format(): """Import points with attributes from RMS attr format""" mypoi = Points() mypoi.from_file(POINTSET3, fformat="rms_attr") print(mypoi.dataframe["VerticalSep"].dtype) mypoi.to_file("TMP/attrs.rmsattr", fformat="rms_attr")
def test_export_points_rmsattr(): """Export XYZ points to file, as rmsattr""" mypoints = Points(POINTSET4) # should guess based on extesion logger.info(mypoints.dataframe) mypoints.to_file(join(TMPD, "poi_export1.rmsattr"), fformat="rms_attr") mypoints2 = Points(join(TMPD, "poi_export1.rmsattr")) assert mypoints.dataframe["Seg"].equals(mypoints2.dataframe["Seg"]) assert mypoints.dataframe["MyNum"].equals(mypoints2.dataframe["MyNum"])
def test_export_points_rmsattr(testpath, tmp_path): """Export XYZ points to file, as rmsattr.""" mypoints = Points(testpath / POINTSET4) # should guess based on extesion output_path = tmp_path / "poi_export.rmsattr" mypoints.to_file(output_path, fformat="rms_attr") mypoints2 = Points(output_path) assert mypoints.dataframe["Seg"].equals(mypoints2.dataframe["Seg"]) assert mypoints.dataframe["MyNum"].equals(mypoints2.dataframe["MyNum"])
def test_import_rmsattr_format(): """Import points with attributes from RMS attr format""" mypoi = Points() mypoi.from_file(POINTSET3, fformat="rms_attr") logger.info(id(mypoi)) logger.info(mypoi._df.head()) # print(mypoi.dataframe.columns[3:]) print(mypoi.dataframe["VerticalSep"].dtype) mypoi.to_file("TMP/attrs.rmsattr", fformat="rms_attr")
def test_export_load_rmsformatted_points(testpath, tmp_path): """Export XYZ points to file, various formats.""" test_points_path = testpath / POINTSET4 orig_points = Points(test_points_path) # should guess based on extesion export_path = tmp_path / "attrs.rmsattr" orig_points.to_file(export_path, fformat="rms_attr") reloaded_points = Points(export_path) pd.testing.assert_frame_equal(orig_points.dataframe, reloaded_points.dataframe)
def test_export_and_load_points(tmp_path): """Export XYZ points to file.""" plist = [(1.0, 1.0, 1.0), (2.0, 3.0, 4.0), (5.0, 6.0, 7.0)] test_points = Points(plist) export_path = tmp_path / "test_points.xyz" test_points.to_file(export_path) exported_points = Points(export_path) pd.testing.assert_frame_equal(test_points.dataframe, exported_points.dataframe) assert list(itertools.chain.from_iterable(plist)) == list( test_points.dataframe.values.flatten())
def test_import_rmsattr_format(testpath, tmp_path): """Import points with attributes from RMS attr format.""" orig_points = Points() test_points_path = testpath / POINTSET3 orig_points.from_file(test_points_path, fformat="rms_attr") export_path = tmp_path / "attrs.rmsattr" orig_points.to_file(export_path, fformat="rms_attr") reloaded_points = Points() reloaded_points.from_file(export_path, fformat="rms_attr") pd.testing.assert_frame_equal(orig_points.dataframe, reloaded_points.dataframe)
def test_points_in_polygon(): """Import XYZ points and do operations if inside or outside""" poi = Points(POINTSET2) pol = Polygons(POLSET2) assert poi.nrow == 30 # remove points in polygon poi.operation_polygons(pol, 0, opname="eli", where=True) assert poi.nrow == 19 poi.to_file(join(TMPD, "poi_test.poi")) poi = Points(POINTSET2) # remove points outside polygon poi.operation_polygons(pol, 0, opname="eli", inside=False, where=True) assert poi.nrow == 1
def test_get_zone_tops_one_well_w_undef(testpath, tmp_path): """Import a well and get the zone tops, include undef transition""" wlist = [Well((testpath / WFILES1), zonelogname="Zonelog")] mypoints = Points() mypoints.from_wells(wlist, use_undef=True) mypoints.to_file( tmp_path / "points_w1_w_undef.rmsasc", fformat="rms_attr", attributes=["WellName", "TopName"], ) mypoints.to_file( tmp_path / "points_w1_w_undef.rmswpicks", fformat="rms_wellpicks", wcolumn="WellName", hcolumn="TopName", )
def test_get_zone_tops_one_well_w_undef(): """Import a well and get the zone tops, include undef transition""" wlist = [] for w in glob.glob(wfiles1): wlist.append(Well(w, zonelogname='Zonelog')) logger.info('Imported well {}'.format(w)) mypoints = Points() nwell = mypoints.from_wells(wlist, use_undef=True) print(mypoints.dataframe) logger.info('Number of well made to tops: {}'.format(nwell)) mypoints.to_file('TMP/points_w1_w_undef.rmsasc', fformat='rms_attr', attributes=['WellName', 'TopName']) mypoints.to_file('TMP/points_w1_w_undef.rmswpicks', fformat='rms_wellpicks', wcolumn='WellName', hcolumn='TopName')
def test_get_zone_tops_some_wells(testpath, tmp_path): """Import some well and get the zone tops""" wlist = [ Well(wpath, zonelogname="Zonelog") for wpath in glob.glob(str(testpath / WFILES2)) ] mypoints = Points() mypoints.from_wells(wlist) mypoints.to_file( tmp_path / "points_w1_many.rmsasc", fformat="rms_attr", attributes=["WellName", "TopName"], ) mypoints.to_file( tmp_path / "points_w1_many.rmswpicks", fformat="rms_wellpicks", wcolumn="WellName", hcolumn="TopName", )
def test_get_zone_tops_some_wells(): """Import some well and get the zone tops""" wlist = [] for w in glob.glob(wfiles2): wlist.append(Well(w, zonelogname='Zonelog')) logger.info('Imported well {}'.format(w)) mypoints = Points() nwell = mypoints.from_wells(wlist) print(mypoints.dataframe) logger.info('Number of well made to tops: {}'.format(nwell)) mypoints.to_file('TMP/points_w1_many.rmsasc', fformat='rms_attr', attributes=['WellName', 'TopName']) mypoints.to_file('TMP/points_w1_many.rmswpicks', fformat='rms_wellpicks', wcolumn='WellName', hcolumn='TopName')