Esempio n. 1
0
    def test_remove(self, stat_segy, header_index, inplace, pre_mark_dead):
        """Check that `remove_dead_traces` properly updates survey `headers` and sets `n_dead_traces` counter to 0."""

        path, trace_data = stat_segy
        survey = Survey(path, header_index=header_index, header_cols="offset")

        traces_pos = survey.headers.reset_index(
        )["TRACE_SEQUENCE_FILE"].values - 1
        trace_data = trace_data[np.argsort(traces_pos)]

        survey_copy = survey.copy()

        if pre_mark_dead:
            survey.mark_dead_traces()

        survey_filtered = survey.remove_dead_traces(inplace=inplace)

        is_dead = np.isclose(trace_data.min(axis=1), trace_data.max(axis=1))
        survey_copy.headers = survey_copy.headers.loc[~is_dead]
        survey_copy.n_dead_traces = 0
        survey_copy.headers[HDR_DEAD_TRACE] = False

        # Validate that dead traces are not present
        assert survey_filtered.n_dead_traces == 0
        assert survey_filtered.headers.index.is_monotonic_increasing
        assert_surveys_equal(survey_filtered, survey_copy)
        assert_survey_processed_inplace(survey, survey_filtered, inplace)
Esempio n. 2
0
    def test_collect_stats(self, stat_segy, init_limits, remove_dead,
                           n_quantile_traces, quantile_precision, stats_limits,
                           use_segyio_trace_loader):
        """Compare stats obtained by running `collect_stats` with the actual ones."""
        path, trace_data = stat_segy
        survey = Survey(path,
                        header_index="TRACE_SEQUENCE_FILE",
                        header_cols="offset",
                        limits=init_limits,
                        use_segyio_trace_loader=use_segyio_trace_loader,
                        bar=False)
        survey.mark_dead_traces(bar=False)

        if remove_dead:
            survey.remove_dead_traces(inplace=True)

        survey_copy = survey.copy()
        survey.collect_stats(n_quantile_traces=n_quantile_traces,
                             quantile_precision=quantile_precision,
                             limits=stats_limits,
                             bar=True)

        # stats_limits take priority over init_limits
        stats_limits = init_limits if stats_limits is None else stats_limits
        trace_data = trace_data[:, stats_limits]
        if remove_dead:
            is_dead = np.isclose(trace_data.min(axis=1),
                                 trace_data.max(axis=1))
            trace_data = trace_data[~is_dead].ravel()

        # Perform basic tests of estimated quantiles since fair comparison of interpolators is complicated
        quantiles = survey.quantile_interpolator(np.linspace(0, 1, 11))
        assert np.isclose(quantiles[0], trace_data.min())
        assert np.isclose(quantiles[-1], trace_data.max())
        assert (np.diff(quantiles) >= 0).all()
        survey.quantile_interpolator = None

        # Fill the copy of the survey with actual stats and compare it with the source survey
        survey_copy.has_stats = True
        survey_copy.min = trace_data.min()
        survey_copy.max = trace_data.max()
        survey_copy.mean = trace_data.mean()
        survey_copy.std = trace_data.std()
        assert_surveys_equal(survey, survey_copy)
Esempio n. 3
0
    def test_mark(self, stat_segy, header_index, detection_limits):
        """Check that `mark_dead_traces` properly updates survey `headers` and sets `n_dead_traces` counter."""

        path, trace_data = stat_segy
        survey = Survey(path, header_index=header_index, header_cols="offset")

        traces_pos = survey.headers.reset_index(
        )["TRACE_SEQUENCE_FILE"].values - 1
        trace_data = trace_data[np.argsort(traces_pos)]

        survey_copy = survey.copy()

        survey.mark_dead_traces(limits=detection_limits, bar=False)

        if detection_limits:
            trace_data = trace_data[:, detection_limits]

        is_dead = np.isclose(trace_data.min(axis=1), trace_data.max(axis=1))
        survey_copy.headers[HDR_DEAD_TRACE] = is_dead
        survey_copy.n_dead_traces = np.sum(is_dead)

        assert_surveys_equal(survey, survey_copy)