Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
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())
Beispiel #4
0
def test_histogram():
    """Test histogram plot.
    """
    fig, ax = plt.subplots()
    lexicon = Lexicon.default()
    striplog = Striplog.from_las3(las3, lexicon=lexicon)
    *_, ax = striplog.histogram(ax=ax)
    return fig
Beispiel #5
0
def test_histogram():
    """Test histogram. This example is from the tutorial.
    """
    lexicon = Lexicon.default()
    striplog = Striplog.from_las3(las3, lexicon=lexicon)
    thicks, *_ = striplog.histogram(plot=False)  # See test_plots for plots.
    t = [123.005, 7.919, 5.504, 4.022, 2.964]
    assert np.allclose(t, thicks)
Beispiel #6
0
def test_bar():
    """Test bar plot.
    """
    fig, ax = plt.subplots()
    lexicon = Lexicon.default()
    striplog = Striplog.from_las3(las3, lexicon=lexicon)
    legend = Legend.builtin('nagmdm__6_2')
    ax = striplog.bar(sort=True, legend=legend, ax=ax, align='center')
    return fig
Beispiel #7
0
    def __init__(self,
                 intervals=None,
                 components=None,
                 name='',
                 legend=None,
                 x_collar=0.,
                 y_collar=0.):
        """
        build a Borehole3D object from Striplog.Intervals list
        
        Parameters
        -----------
        intervals : list
            list of Striplog.Interval object (default = None)
            
        components : 
            (default = None)
        
        name : str 
        
        legend : Striplog Legend object (default = None)
        
        x_collar : float
            X coordinate of the borehole (default = 0)
            
        y_collar : float
            Y coordinate of the borehole (default = 0)
        """

        self.name = name

        if legend is None or not isinstance(legend, Legend):
            self.legend = Legend.default()
        else:
            self.legend = legend

        self.x_collar = x_collar
        self.y_collar = y_collar
        self.omf_legend, self.omf_cmap = striplog_legend_to_omf_legend(
            self.legend)

        if intervals is None:
            lexicon = Lexicon.default()
            with open(ROOT_DIR + '/data/test.las', 'r') as las3:
                default_intv = Striplog.from_las3(las3.read(), lexicon)
                intervals = list(default_intv)
            print("Pay attention that default intervals are actually used !\n")

        self.intervals = intervals
        self.geometry = []

        # instantiation with supers properties
        Striplog.__init__(self, list_of_Intervals=self.intervals)

        # self.uid=uuid #get a unique for identification of borehole in the project

        self.build_geometry()
Beispiel #8
0
def striplog_from_text(filename, lexicon=None):
    """ creates a Striplog object from a las or flat text file
    
    Parameters
    ----------
    Lexicon : dict
              A vocabulary for parsing lithologic or stratigraphic descriptions
              (default set to Lexicon.default() if lexicon is None)
              
    Returns
    -------
    strip: striplog object
    
 
    """

    if lexicon is None:
        lexicon = Lexicon.default()

    if re.compile(r".+\.las").match(filename):
        print(f"File {filename:s} OK! Creation of the striplog ...")
        with open(filename, 'r') as las3:
            strip = Striplog.from_las3(las3.read(), lexicon)

    elif re.compile(r".+\.(csv|txt)").match(filename):
        print(f"File {filename:s} OK! Creation of the striplog ...")
        f = re.DOTALL | re.IGNORECASE
        regex_data = r'start.+?\n(.+?)(?:\n\n+|\n*\#|\n*$)'  # retrieve data of BH

        pattern = re.compile(regex_data, flags=f)
        with open(filename, 'r') as csv:
            text = pattern.search(csv.read()).group(1)
            text = re.sub(r'[\t]+', ';', re.sub(r'(\n+|\r\n|\r)', '\n', text.strip()))
            strip = Striplog.from_descriptions(text, dlm=';', lexicon=lexicon)

    else:
        print("Error! Please check the file extension !")
        raise

    return strip
Beispiel #9
0
def test_from_las3():
    """Test the LAS3 route.
    """
    lexicon = Lexicon.default()
    s = Striplog.from_las3(las3, lexicon=lexicon)
    assert len(s) == 14
Beispiel #10
0
def test_histogram():
    lexicon = Lexicon.default()
    striplog = Striplog.from_las3(las3, lexicon=lexicon)
    _, counts = striplog.histogram()
    assert counts == (123, 6, 6, 5, 3)
Beispiel #11
0
def test_from_las3():
    s = Striplog.from_las3(las3)
    assert len(s) == 14
Beispiel #12
0
def test_histogram():
    lexicon = Lexicon.default()
    striplog = Striplog.from_las3(las3, lexicon=lexicon)
    _, counts = striplog.histogram()
    assert counts == (123, 6, 6, 5, 3)
Beispiel #13
0
def test_from_las3():
    s = Striplog.from_las3(las3)
    assert len(s) == 14
Beispiel #14
0
def test_from_las3():
    """Test the LAS3 route.
    """
    s = Striplog.from_las3(las3)
    assert len(s) == 14
Beispiel #15
0
def test_from_las3():
    """Test the LAS3 route.
    """
    s = Striplog.from_las3(las3)
    assert len(s) == 14