Example #1
0
def test_striplog():
    """Test most of the things.
    """
    r1 = Component({'lithology': 'sand'})
    r2 = Component({'lithology': 'shale'})
    r3 = Component({'lithology': 'limestone'})

    # Bottom up: elevation order
    iv1 = Interval(120, 100, components=[r1])
    iv2 = Interval(150, 120, components=[r2])
    iv3 = Interval(180, 160, components=[r1, r2])
    iv4 = Interval(200, 180, components=[r3, r2])

    s1 = Striplog([iv1, iv2])
    s2 = Striplog([iv3, iv4])
    s = s1 + s2
    assert s.order == 'elevation'
    assert len(s) == 4
    assert s.start.z == 100
    assert s.stop.z == 200
    assert s.__repr__() is not ''
    assert s.__str__() is not ''

    s_rev = s.invert(copy=True)
    assert s_rev.order == 'depth'
    x = s.invert()
    assert x is None
    assert s.order == 'depth'
    assert s[0] == iv1
    assert s[0].top.z == 100

    # Top down: depth order
    iv1 = Interval(80, 120, components=[r1])
    iv2 = Interval(120, 150, components=[r2])
    iv3 = Interval(180, 200, components=[r1, r2])
    iv4 = Interval(200, 250, components=[r3, r2])

    s = Striplog([iv1, iv2, iv3, iv4])
    assert s.order == 'depth'
    assert len(s) == 4
    assert s.start.z == 80
    assert s.stop.z == 250

    l = [iv.thickness for iv in s]
    assert len(l) == 4

    s[2] = Interval(180, 190, components=[r1, r2])
    assert len(s.find_gaps()) == 2

    # Crop.
    x = s.crop((110, 210), copy=True)
    assert x.start.z == 110

    # To csv
    csv = x.to_csv(header=True)
    assert csv[:3] == 'Top'

    # Add.
    assert len(s + iv4) == 5
Example #2
0
    def __init__(self, f=None,
                 lexicon=None,
                 null_subs=None,
                 unknown_as_other=True):

        # First generate the parent object if possible.
        if f:
            super(Well, self).__init__(f, null_subs, unknown_as_other)

        # Add an empty striplog dict-like for later.
        self.striplog = Extra()

        # If we got an OTHER section, let's try loading it as striplogs...
        other = getattr(self, 'other', None)
        if other:
            f = re.MULTILINE
            pattern = re.compile(r'^(\~)(?=\w+?_Parameter)', flags=f)
            chunks = [i for i in filter(None, pattern.split(self.other))]

            # This is gross but I can't see how else to get the tilde
            # back on the strings when I do the re.split().
            nchunks = [a + b for a, b in zip(chunks[::2], chunks[1::2])]

            for section in nchunks:
                name = re.search(r'^\~(\w+?)_', section, flags=f).group(1)
                striplog = Striplog.from_las3(section, lexicon=lexicon)
                self.add_striplog(striplog, name.lower())
Example #3
0
def test_from_csv():
    lexicon = Lexicon.default()
    csv_string = """  200.000,  230.329,  Anhydrite
                      230.329,  233.269,  Grey vf-f sandstone
                      233.269,  234.700,  Anhydrite
                      234.700,  236.596,  Dolomite
                      236.596,  237.911,  Red siltstone
                      237.911,  238.723,  Anhydrite
                      238.723,  239.807,  Grey vf-f sandstone
                      239.807,  240.774,  Red siltstone
                      240.774,  241.122,  Dolomite
                      241.122,  241.702,  Grey siltstone
                      241.702,  243.095,  Dolomite
                      243.095,  246.654,  Grey vf-f sandstone
                      246.654,  247.234,  Dolomite
                      247.234,  255.435,  Grey vf-f sandstone
                      255.435,  258.723,  Grey siltstone
                      258.723,  259.729,  Dolomite
                      259.729,  260.967,  Grey siltstone
                      260.967,  261.354,  Dolomite
                      261.354,  267.041,  Grey siltstone
                      267.041,  267.350,  Dolomite
                      267.350,  274.004,  Grey siltstone
                      274.004,  274.313,  Dolomite
                      274.313,  294.816,  Grey siltstone
                      294.816,  295.397,  Dolomite
                      295.397,  296.286,  Limestone
                      296.286,  300.000,  Volcanic
                    """
    strip2 = Striplog.from_csv(csv_string, lexicon=lexicon)
    assert len(strip2.top) == 7
Example #4
0
def test_from_image():
    legend = Legend.builtin("NSDOE")
    imgfile = "tutorial/M-MG-70_14.3_135.9.png"
    striplog = Striplog.from_img(imgfile, 200, 300, legend=legend)
    assert len(striplog) == 26
    assert striplog[-1].primary.summary() == "Volcanic"
    assert np.floor(striplog.find("sandstone").cum) == 15
    assert striplog.depth(260).primary.lithology == "siltstone"
    assert striplog.to_las3() is not ""
    assert striplog.to_log()[5] == 2.0
    assert striplog.cum == 100.0
    assert striplog.thickest().primary.lithology == "anhydrite"
    assert striplog.thickest(n=7)[1].primary.lithology == "sandstone"
    assert striplog.thinnest().primary.lithology == "dolomite"
    assert striplog.thinnest(n=7)[1].primary.lithology == "siltstone"

    indices = [2, 7, 20]
    del striplog[indices]
    assert len(striplog.find_gaps()) == len(indices)

    striplog.prune(limit=1.0)
    assert len(striplog) == 14

    striplog.anneal()
    assert not striplog.find_gaps()  # Should be None

    rock = striplog.find("sandstone")[1].components[0]
    assert rock in striplog
Example #5
0
def test_histogram():
    """Test histogram. This example is from the tutorial.
    """
    lexicon = Lexicon.default()
    striplog = Striplog.from_las3(las3, lexicon=lexicon)
    _, counts = striplog.histogram()
    assert counts == (124, 6, 6, 5, 3)
Example #6
0
def test_from_array():
    lexicon = Lexicon.default()

    a = [(100, 200, 'red sandstone'),
         (200, 250, 'grey shale'),
         (200, 250, 'red sandstone with shale stringers'),
         ]
    s = Striplog.from_array(a, lexicon=lexicon)
    assert s.__str__() != ''
Example #7
0
def test_from_image():
    """Test the generation of a striplog from an image.
    """
    legend = Legend.builtin('NSDOE')
    imgfile = "tutorial/M-MG-70_14.3_135.9.png"
    striplog = Striplog.from_image(imgfile, 200, 300, legend=legend)
    assert len(striplog) == 26
    assert striplog[-1].primary.summary() == 'Volcanic'
    assert np.floor(striplog.find('sandstone').cum) == 15
    assert striplog.depth(260).primary.lithology == 'siltstone'
    assert striplog.to_las3() is not ''
    assert striplog.cum == 100.0
    assert striplog.thickest().primary.lithology == 'anhydrite'
    assert striplog.thickest(n=7)[1].primary.lithology == 'sandstone'
    assert striplog.thinnest().primary.lithology == 'dolomite'
    assert striplog.thinnest(n=7)[1].primary.lithology == 'siltstone'

    # To and from log.
    log, basis, table = striplog.to_log(step=0.1524, return_meta=True)
    assert log[5] == 2.0
    strip = Striplog.from_log(log, basis=basis, components=table)
    assert len(strip) == len(striplog)
    strip2 = Striplog.from_log(log, basis=basis, cutoff=3, legend=legend)
    assert len(strip2) == 18

    # Extract log onto striplog.
    striplog.extract(log, basis=basis, name="Log", function=np.mean)
    assert striplog[0].data['Log'] == 2.0

    # Indexing.
    indices = [2, 7, 20]
    del striplog[indices]
    assert len(striplog.find_gaps()) == len(indices)

    # Prune and anneal.
    striplog.prune(limit=1.0)
    assert len(striplog) == 14

    striplog.anneal()
    assert not striplog.find_gaps()  # Should be None

    rock = striplog.find('sandstone')[1].components[0]
    assert rock in striplog
Example #8
0
def test_canstrat():
    """
    Test basic stuff.
    """
    w = Well.from_las('tests/P-129_out.LAS')
    s = Striplog.from_csv('tests/K90_strip_pred.csv')
    w.data['test'] = s
    dat = w.to_canstrat(key='test', log='K   90', as_text=True)

    s7 = "K   907   3960 3966L0                                                           "
    assert s7 in dat
Example #9
0
def test_striplog_merge():
    """Test merging. This example is from the tutorial.
    """
    lappy = Striplog([Interval(**{'top': 0, 
                                  'base': 60,
                                  'components':[Component({'lithology': 'dolomite'}),]}),
                      Interval(**{'top': 55,
                                  'base': 75,
                                  'components':[Component({'lithology': 'limestone'}),]}),
                      Interval(**{'top': 75,
                                  'base': 80,
                                  'components':[Component({'lithology': 'volcanic'}),]}), 
                      Interval(**{'top': 78,
                                  'base': 100,
                                  'components':[Component({'lithology': 'anhydrite'}),]})
                      ])
    assert lappy.find_overlaps(index=True) == [0, 2]
    assert lappy.merge_overlaps() is None
    assert lappy.find_overlaps() is None
    assert lappy.merge_overlaps() is None
Example #10
0
def test_striplog():

    r1 = Component({'lithology': 'sand'})
    r2 = Component({'lithology': 'shale'})
    r3 = Component({'lithology': 'limestone'})

    # Bottom up: elevation order
    iv1 = Interval(120, 100, components=[r1])
    iv2 = Interval(150, 120, components=[r2])
    iv3 = Interval(180, 160, components=[r1, r2])
    iv4 = Interval(200, 180, components=[r3, r2])

    s1 = Striplog([iv1, iv2])
    s2 = Striplog([iv3, iv4])
    s = s1 + s2
    assert s.order == 'elevation'
    assert len(s) == 4
    assert s.start == 100
    assert s.stop == 200
    assert s.__repr__() is not ''
    assert s.__str__() is not ''

    # Top down: depth order
    iv1 = Interval(80, 120, components=[r1])
    iv2 = Interval(120, 150, components=[r2])
    iv3 = Interval(180, 200, components=[r1, r2])
    iv4 = Interval(200, 250, components=[r3, r2])

    s = Striplog([iv1, iv2, iv3, iv4])
    assert s.order == 'depth'
    assert len(s) == 4
    assert s.start == 80
    assert s.stop == 250

    l = [iv.thickness for iv in s]
    assert len(l) == 4

    s[2] = Interval(180, 190, components=[r1, r2])
    assert len(s.find_gaps()) == 2

    assert s._Striplog__sort()  # Not used, should probably delete
Example #11
0
def test_striplog_plot():
    """
    Tests mpl image of striplog
    """
    legend = Legend.builtin("NSDOE")

    imgfile = "tutorial/M-MG-70_14.3_135.9.png"

    striplog = Striplog.from_img(imgfile, 14.3, 135.9, legend=legend)

    fig = striplog.thickest(n=5).plot(legend=legend, return_fig=True)
    return fig
Example #12
0
def test_striplog():
    r1 = Component({"lithology": "sand"})
    r2 = Component({"lithology": "shale"})
    r3 = Component({"lithology": "limestone"})

    # Bottom up: elevation order
    iv1 = Interval(120, 100, components=[r1])
    iv2 = Interval(150, 120, components=[r2])
    iv3 = Interval(180, 160, components=[r1, r2])
    iv4 = Interval(200, 180, components=[r3, r2])

    s1 = Striplog([iv1, iv2])
    s2 = Striplog([iv3, iv4])
    s = s1 + s2
    assert s.order == "elevation"
    assert len(s) == 4
    assert s.start == 100
    assert s.stop == 200
    assert s.__repr__() is not ""
    assert s.__str__() is not ""

    # Top down: depth order
    iv1 = Interval(80, 120, components=[r1])
    iv2 = Interval(120, 150, components=[r2])
    iv3 = Interval(180, 200, components=[r1, r2])
    iv4 = Interval(200, 250, components=[r3, r2])

    s = Striplog([iv1, iv2, iv3, iv4])
    assert s.order == "depth"
    assert len(s) == 4
    assert s.start == 80
    assert s.stop == 250

    l = [iv.thickness for iv in s]
    assert len(l) == 4

    s[2] = Interval(180, 190, components=[r1, r2])
    assert len(s.find_gaps()) == 2
def make_well_project(laspath='data/las/', stripath='data/tops/'):
    """
    Return a dictionary of wells and striplogs where the
    key is the base filename
    """
    wells = {}
    lasfiles = glob(laspath + '*.LAS')
    stripfiles = glob(stripath + '*.csv')
    for fname, sname in zip(lasfiles, stripfiles):
        name = fname.split('/')[-1].split('.')[0]
        wells[name] = Well.from_las(fname)
        wells[name].data['tops'] = Striplog.from_csv(sname)
        proj = Project(list(wells.values()))
    return proj
Example #14
0
def test_canstrat():
    """
    Test basic stuff.
    """
    w = Well.from_las('tests/P-129_out.LAS')
    s = Striplog.from_csv('tests/K90_strip_pred.csv')
    w.data['test'] = s
    dat = w.to_canstrat(key='test',
                        log='K   90',
                        lith_field="component",
                        as_text=True)

    s7 = "K   907   3960 3966L0                                                           "
    assert s7 in dat
Example #15
0
def test_striplog_ladder_plot():
    """
    Tests mpl image of striplog with the ladder option.
    """
    legend = Legend.builtin('NSDOE')

    imgfile = "tutorial/M-MG-70_14.3_135.9.png"

    striplog = Striplog.from_image(imgfile, 14.3, 135.9, legend=legend)

    fig = striplog.thickest(n=5).plot(legend=legend,
                                      ladder=True,
                                      return_fig=True)
    return fig
Example #16
0
def test_striplog_ladder_plot():
    """
    Tests mpl image of striplog with the ladder option.
    """
    legend = Legend.builtin('NSDOE')

    imgfile = "tutorial/M-MG-70_14.3_135.9.png"

    striplog = Striplog.from_image(imgfile, 14.3, 135.9, legend=legend)

    fig = striplog.thickest(n=5).plot(legend=legend,
                                      ladder=True,
                                      return_fig=True)
    return fig
Example #17
0
    def add_striplog(self, data: pd.DataFrame):
        unique_borehole = np.unique(data.index)
        self.add_wells(unique_borehole)
        for b in unique_borehole:
            w = self.p.get_well(b)
            data_dict = data.loc[b].to_dict('list')
            s = Striplog.from_dict(data_dict, points=True)

            start, stop, step_size = self._calculate_basis_parameters(w, w.location.md.shape[0])
            s_log, basis, table = s.to_log(step_size, start, stop, return_meta=True)

            w.data['lith'] = s
            w.data['lith_log'] = Curve(s_log, basis)

        return self.p
Example #18
0
def test_striplog_intersect():
    """Test intersection. This example is from the tutorial.
    """
    chrono = Striplog([Interval(**{'top': 0,
                                   'base': 60,
                                   'components': [Component({'age': 'Holocene'})]
                                   }),
                       Interval(**{'top': 60,
                                   'base': 75,
                                   'components': [Component({'age': 'Palaeogene'})]
                                   }),
                       Interval(**{'top': 75,
                                   'base': 100,
                                   'components': [Component({'age': 'Cretaceous'})]
                                   }),
                       ])
    legend = Legend.builtin('NSDOE')
    imgfile = "tutorial/M-MG-70_14.3_135.9.png"
    strip = Striplog.from_image(imgfile, 14.3, 135.9, legend=legend)
    sands = strip.find('sandstone')
    cretaceous = chrono.find('Palaeogene')
    cret_sand = sands.intersect(cretaceous)
    assert len(cret_sand) == 3
    assert cret_sand.stop.z == 75
Example #19
0
def test_well():

    fname = 'tutorial/P-129_out.LAS'
    well = Well(fname)
    assert well.well.DATE.data == '10-Oct-2007'
    assert well.data['GR'][0] == 46.69865036

    legend = Legend.default()
    f = 'tutorial/P-129_280_1935.png'
    name, start, stop = f.strip('.png').split('_')
    striplog = Striplog.from_img(f, float(start), float(stop), legend=legend, tolerance=35)
    well.add_striplog(striplog, "striplog")
    assert well.striplog.striplog.source == 'Image'
    assert well.striplog.striplog.start == 280.0
    assert len(well.striplogs_to_las3()) == 14841
Example #20
0
def test_striplog_intersect():
    """Test intersection. This example is from the tutorial.
    """
    chrono = Striplog([Interval(**{'top': 0,
                                   'base': 60,
                                   'components': [Component({'age': 'Holocene'})]
                                   }),
                       Interval(**{'top': 60,
                                   'base': 75,
                                   'components': [Component({'age': 'Palaeogene'})]
                                   }),
                       Interval(**{'top': 75,
                                   'base': 100,
                                   'components': [Component({'age': 'Cretaceous'})]
                                   }),
                       ])
    legend = Legend.builtin('NSDOE')
    imgfile = "tutorial/M-MG-70_14.3_135.9.png"
    strip = Striplog.from_image(imgfile, 14.3, 135.9, legend=legend)
    sands = strip.find('sandstone')
    cretaceous = chrono.find('Palaeogene')
    cret_sand = sands.intersect(cretaceous)
    assert len(cret_sand) == 3
    assert cret_sand.stop.z == 75
Example #21
0
def test_from_array():
    """Test the array route.
    Deprecated.
    """
    lexicon = Lexicon.default()

    a = [(100, 200, 'red sandstone'),
         (200, 250, 'grey shale'),
         (200, 250, 'red sandstone with shale stringers'),
         ]

    with pytest.warns(DeprecationWarning):
        s = Striplog._from_array(a, lexicon=lexicon)

    assert s.__str__() != ''
Example #22
0
def make_well_project(laspath='data/las/', stripath='data/tops/'):
    """
    Return a dictionary of wells and striplogs where the
    key is the base filename

    This assumes that the las file and tops files have the same name
    """
    wells = {}
    lasfiles = glob(laspath + '*.LAS')
    stripfiles = glob(stripath + '*.csv')
    for fname, sname in zip(lasfiles, stripfiles):
        name = Path(fname).stem
        wells[name] = Well.from_las(fname)
        wells[name].data['tops'] = Striplog.from_csv(sname)
        proj = Project(list(wells.values()))
    return proj
Example #23
0
def test_striplog_colour_plot():
    """
    Tests mpl image of striplog with the ladder option.
    """
    legend = Legend.builtin('NSDOE')

    imgfile = "tutorial/M-MG-70_14.3_135.9.png"

    striplog = Striplog.from_image(imgfile, 14.3, 135.9, legend=legend)

    for iv in striplog:
        iv.data['porosity'] = iv.top.z / 100

    fig = striplog.plot(colour='porosity', aspect=3, return_fig=True)

    return fig
Example #24
0
def test_striplog_top_plot():
    """
    Tests mpl image of striplog with the tops option.
    """
    tops_csv = """top, Comp formation
                   25, Escanilla Fm.
                   35, San Vicente Fm.
                   20, Sobrarbe Fm.
                   50, Cretaceous"""

    tops = Striplog.from_csv(text=tops_csv)

    fig = tops.plot(style='tops',
                    field='formation',
                    aspect=1.5,
                    return_fig=True)

    return fig
def test_striplog_2():
    data = pd.read_excel(data_path.joinpath('borehole_lith.xlsx'))
    well_name_column = 'SITE_ID'
    well_names = data[well_name_column].unique()
    foo = data.groupby(well_name_column).get_group(well_names[0])
    data_dict = foo.to_dict('list')

    s = Striplog.from_dict(data_dict,
                           remap={
                               'DEPTH_FROM': 'top',
                               'DEPTH_TO': 'base',
                               'LITHOLOGY': 'component lith',
                               'SITE_ID': 'description'
                           })

    s.plot()
    plt.show()
    print(s)
Example #26
0
def test_well():

    fname = 'tutorial/P-129_out.LAS'
    well = Well(fname)
    assert well.well.DATE.data == '10-Oct-2007'
    assert well.data['GR'][0] == 46.69865036

    legend = Legend.default()
    f = 'tutorial/P-129_280_1935.png'
    name, start, stop = f.strip('.png').split('_')
    striplog = Striplog.from_img(f,
                                 float(start),
                                 float(stop),
                                 legend=legend,
                                 tolerance=35)
    well.add_striplog(striplog, "striplog")
    assert well.striplog.striplog.source == 'Image'
    assert well.striplog.striplog.start == 280.0
    assert len(well.striplogs_to_las3()) == 14841
Example #27
0
    def add_canstrat_striplogs(self, path, name='canstrat'):
        """
        This may be to specific a method... just move it to the workflow.

        Requires striplog.
        """
        from striplog import Striplog

        for w in self.__list:
            dat_file = utils.find_file(w.uwi, path)

            if dat_file is None:
                print("- Omitting {}: no data".format(w.uwi))
                continue

            # If we got here, we're using it.
            print("+ Adding {}".format(w.uwi))

            w.data[name] = Striplog.from_canstrat(dat_file)

        return
Example #28
0
def test_petrel():
    """Test we can load petrel text.
    """
    # What to include: only rows with Well = P-108
    include = {'Well': lambda x: x == 'P-108'}

    # Rename the Surface field as Name.
    remap = {'Surface': 'Name'}

    # What to exclude: any rows with Name = TD
    exclude = {'Name': lambda x: x == 'TD'}

    # What to transform before using.
    function = {
        'Z': lambda x: -x,
        'Name': lambda x: x.replace('Maguma', 'Meguma')
    }

    # Which fields to leave out of the result, apart from those that are Null.
    ignore = [
        'Edited by user', 'Locked to fault', 'Used by dep.conv.', 'Well',
        'Symbol'
    ]

    # Do the thing!
    s = Striplog.from_petrel("tests/data/tops.txt",
                             include=include,
                             exclude=exclude,
                             remap=remap,
                             ignore=ignore,
                             function=function,
                             points=False,
                             null=-999.0)

    print(s)

    assert len(s) == 4
    assert s[3].base.z == 1056
    assert s[3].data['Name'] == 'Meguma'
Example #29
0
def test_striplog_merge():
    """Test merging. This example is from the tutorial.
    """
    lappy = Striplog([Interval(**{'top': 0, 
                                  'base': 60,
                                  'components':[Component({'lithology': 'dolomite'}),]}),
                      Interval(**{'top': 55,
                                  'base': 75,
                                  'components':[Component({'lithology': 'limestone'}),]}),
                      Interval(**{'top': 75,
                                  'base': 80,
                                  'components':[Component({'lithology': 'volcanic'}),]}), 
                      Interval(**{'top': 78,
                                  'base': 100,
                                  'components':[Component({'lithology': 'anhydrite'}),]})
                      ])
    assert lappy.find_overlaps(index=True) == [0, 2]
    assert lappy.merge_overlaps() is None
    assert lappy.find_overlaps() is None
    assert lappy.merge_overlaps() is None
Example #30
0
def test_striplog():

    r1 = Component({'lithology': 'sand'})
    r2 = Component({'lithology': 'shale'})
    r3 = Component({'lithology': 'limestone'})

    # Bottom up: elevation order
    iv1 = Interval(120, 100, components=[r1])
    iv2 = Interval(150, 120, components=[r2])
    iv3 = Interval(180, 160, components=[r1, r2])
    iv4 = Interval(200, 180, components=[r3, r2])

    s1 = Striplog([iv1, iv2])
    s2 = Striplog([iv3, iv4])
    s = s1 + s2
    assert s.order == 'elevation'
    assert len(s) == 4
    assert s.start == 100
    assert s.stop == 200
    assert s.__repr__() is not ''
    assert s.__str__() is not ''

    # Top down: depth order
    iv1 = Interval(80, 120, components=[r1])
    iv2 = Interval(120, 150, components=[r2])
    iv3 = Interval(180, 200, components=[r1, r2])
    iv4 = Interval(200, 250, components=[r3, r2])

    s = Striplog([iv1, iv2, iv3, iv4])
    assert s.order == 'depth'
    assert len(s) == 4
    assert s.start == 80
    assert s.stop == 250

    l = [iv.thickness for iv in s]
    assert len(l) == 4

    s[2] = Interval(180, 190, components=[r1, r2])
    assert len(s.find_gaps()) == 2

    assert s._Striplog__sort()  # Not used, should probably delete
Example #31
0
def test_from_descriptions():
    """Test the CSV route.
    """
    lexicon = Lexicon.default()
    strip2 = Striplog.from_descriptions(text=csv_intervals, lexicon=lexicon)
    assert len(strip2.unique) == 7
Example #32
0
def test_canstrat():
    """Read a file.
    """
    s = Striplog.from_canstrat('tests/data/test_canstrat.dat')
    assert len(s) == 28
    assert abs(s[3].data['grains_mm'] - 0.0012) < 0.0000001
    print(' '*5, fname)
print('\n')

tops_legend = Legend.from_csv(filename='data/Poseidon_data/tops_legend.csv')

p = Project.from_las('data/Poseidon_data/las/*.LAS')
well_uwi = [w.uwi for w in p] ##gets the well uwi data for use in the well-selector tool

# Add striplogs to Project
# Striplog must have the same name as LAS file.
# e.g. Torosa-1.LAS and Torosa-1.csv
for w in p:
    name = Path(w.fname).name.split('.')[0]
    new_path = f'data/Poseidon_data/tops/{name}.csv'
    print(name, new_path)
    strip = Striplog.from_csv(f'data/Poseidon_data/tops/{name}.csv')
    w.data['tops'] = strip


# Make the well correlation panel
def encode_xsection(p):
    """
    Takes the project and saves a xsec PNG a disk and encodes it for dash
    """
    section_plot(p, tops_legend)
    image_filename = 'cross_section.png' # replace with your own image 
    encoded_image = base64.b64encode(open(image_filename, 'rb').read())
    return 'data:image/png;base64,{}'.format(encoded_image.decode())


# Initialize Cross-section
Example #34
0
def test_error():
    with pytest.raises(StriplogError):
        Striplog([])
Example #35
0
def test_from_csv():
    """Test the CSV route.
    """
    lexicon = Lexicon.default()
    strip2 = Striplog.from_csv(csv_intervals, lexicon=lexicon)
    assert len(strip2.top) == 7
    helper.update_picks_on_plot(fig, picks_selected)

    return fig


base_dir = "./data/Poseidon_data"

# # load well data
"""Need to add a method for the user to point to the directory or add additional las files later"""
fpath = Path(base_dir + "/las/*.LAS")
p = Project.from_las(str(fpath))
well_uwi = [w.uwi for w in p]

for w in p:
    name = w.fname.split('/')[-1].split('.')[0]
    strip = Striplog.from_csv(base_dir + f'/tops/{name}.csv')
    w.data['tops'] = strip

well_uwi = [w.uwi for w in p]
well_uwi = st.sidebar.selectbox("Well Names", well_uwi)

df = p[0].df()  ##gets data from the first well in the Welly Project
curve_list = df.columns.tolist(
)  ##gets the column names for later use in the curve-selector tool
curve_dropdown_options = [{
    'label': k,
    'value': k
} for k in sorted(curve_list)]  ##list of well log curves to the dropdown

curve = st.sidebar.selectbox(
    "Well Names", [item['value'] for item in curve_dropdown_options])
Example #37
0
def test_histogram():
    lexicon = Lexicon.default()
    striplog = Striplog.from_las3(las3, lexicon=lexicon)
    _, counts = striplog.histogram()
    assert counts == (123, 6, 6, 5, 3)
Example #38
0
def test_points():
    """Test a striplog of points.
    """
    points = Striplog.from_csv(text=csv_points, points=True)
    assert len(points) == 6
    assert points.order == 'none'
Example #39
0
else:
    data_path = cwd + '/..'

print(data_path + '/data/input_data/striplog_integration/*.tops')
topsfiles = glob.glob(data_path +
                      '/data/input_data/striplog_integration/*.tops')
topsfiles

# %%
# Creating striplog object
my_striplogs = []

for file in topsfiles:
    with open(file) as f:
        text = f.read()
        striplog = Striplog.from_csv(text=text)
        my_striplogs.append(striplog)

striplog_dict = {
    'alpha': my_striplogs[1],
    'beta': my_striplogs[2],
    'gamma': my_striplogs[3],
    'epsilon': my_striplogs[0]
}

striplog_dict['alpha'][0]

# %%
# Plot striplog
f, a = plt.subplots(ncols=4, sharey=True)
Example #40
0
def test_from_las3():
    """Test the LAS3 route.
    """
    s = Striplog.from_las3(las3)
    assert len(s) == 14
Example #41
0
def test_histogram():
    lexicon = Lexicon.default()
    striplog = Striplog.from_las3(las3, lexicon=lexicon)
    _, counts = striplog.histogram()
    assert counts == (123, 6, 6, 5, 3)
Example #42
0
def test_from_array():
    lexicon = Lexicon.default()

    a = [(100, 200, "red sandstone"), (200, 250, "grey shale"), (200, 250, "red sandstone with shale stringers")]
    s = Striplog._from_array(a, lexicon=lexicon)
    assert s.__str__() != ""
Example #43
0
def test_from_las3():
    s = Striplog.from_las3(las3)
    assert len(s) == 14
Example #44
0
def test_from_csv():
    lexicon = Lexicon.default()
    strip2 = Striplog.from_csv(csv_string, lexicon=lexicon)
    assert len(strip2.top) == 7
Example #45
0
def test_from_las3():
    """Test the LAS3 route.
    """
    lexicon = Lexicon.default()
    s = Striplog.from_las3(las3, lexicon=lexicon)
    assert len(s) == 14
Example #46
0
def test_from_descriptions():
    """Test the CSV route.
    """
    lexicon = Lexicon.default()
    strip2 = Striplog.from_descriptions(text=csv_intervals, lexicon=lexicon)
    assert len(strip2.top) == 7
Example #47
0
def test_points():
    """Test a striplog of points.
    """
    points = Striplog.from_csv(text=csv_points, points=True)
    assert len(points) == 6
    assert points.order == 'none'
Example #48
0
stripfiles = glob(path2 + '*.csv')

legend = Legend.from_csv(filename='data/Poseidon_data/tops_legend.csv'
                         )  # direct link to specific data

p = Project.from_las(
    'data/Poseidon_data/las/*.LAS')  # direct link to specific data
well_uwi = [w.uwi for w in p
            ]  ##gets the well uwi data for use in the well-selector tool

# Add striplogs to Project
# Striplog must have the same name as LAS file.
# e.g. Torosa-1.LAS and Torosa-1.csv
for w in p:
    name = Path(w.fname).stem
    strip = Striplog.from_csv(
        f'data/Poseidon_data/tops/{name}.csv')  # direct link to specific data
    w.data['tops'] = strip

well = p[0]  ##gets data from the first well in the Welly Project
curve_list = get_curves(
    p)  ##gets the column names for later use in the curve-selector tool
curve = get_first_curve(curve_list)
surface_picks_df = get_tops_df(p)

#well dropdown selector
well_dropdown_options = [{
    'label': k,
    'value': k
} for k in sorted(well_uwi)]  ##list of wells to the dropdown
#tops dropdown options
"""we need to have a stratigraphic column at some point"""
Example #49
0
def test_error():
    """Test the generic error.
    """
    with pytest.raises(StriplogError):
        Striplog([])
Example #50
0
def test_from_csv():
    lexicon = Lexicon.default()
    strip2 = Striplog.from_csv(csv_string, lexicon=lexicon)
    assert len(strip2.top) == 7
Example #51
0
def test_from_las3():
    s = Striplog.from_las3(las3)
    assert len(s) == 14
Example #52
0
def test_from_las3():
    """Test the LAS3 route.
    """
    s = Striplog.from_las3(las3)
    assert len(s) == 14