def test_wennerResistivity(self):

        apparentResistivity = wennerResistivity(
            self.voltageSpacing, self.Vm, self.I)

        assert_array_almost_equal(
            apparentResistivity,
            np.array([1844.114888, 924.884877, 420.101877], dtype=np.float64))
Exemple #2
0
    def compute(self, suppress=False):
        """Compute apparent resistivity

        Parameters
        ----------
        suppress: bool
            If True, message boxes should be suppressed. Implemented to allow
            cross platform testing between Mac OS X and Ubuntu. Not currently
            working, likely going to ditch it

        Notes
        -----
        This is where all of the numerical crunching happens. The radioboxes
        in the main window define whether the schlumberger or wenner equation
        is employed, and there are warnings when the data do not fit the
        assumptions of the model. That is, when all of the spacings are not
        equal in a Wenner array, there is a warning. When at least 2 of the
        Schlumberger spacings are equal, there is a warning. Finally, if the
        operator forgets to select a radio button, there is a warning.

        """
        # Suppress msgBox if this module is not called directly for testing
        if __name__ != '__main__':
            suppress = True

        self.apparentResistivity = None
        self.aggregateTableForPlot()

        # Calculate apparent resistivity using the Wenner array
        if self.wennerLayout == True:

            # Test and let user know spacing does not indicate Wenner Array
            if not np.all(
                self.voltageSpacing * 2 == self.voltageSpacing[0] * 2):
                self.wennerMessageBox(suppress)

            self.apparentResistivity = wennerResistivity(
                self.voltageSpacing, self.meanVoltage, self.meanCurrent)
            self.canvas.addPointsAndLine(
                self.voltageSpacing, self.apparentResistivity)

            voltageSpacingExtrapolated, newResistivity = interpolateFieldData(
                self.voltageSpacing, self.apparentResistivity, 'wenner')
            self.voltageSpacingExtrapolated = voltageSpacingExtrapolated
            self.newResistivity = newResistivity

            self.filteredResistivity = applyFilter(
                self.newResistivity,
                self.wennerCoefficients)

            sampleInterval = np.log(10) / 3.
            self.samplePoints = np.arange(
                start=(-sampleInterval * 2),
                stop=(sampleInterval * 20),
                step=sampleInterval)

        # Calculate apparent resistivity using the Schlumberger array
        elif self.schlumbergerLayout == True:

            # Test and let user know spacing does not indicate Schlum. array
            if np.any(self.voltageSpacing[1:] == self.voltageSpacing[0]):
                self.schlumbergerMessageBox(suppress)

            self.apparentResistivity = schlumbergerResistivityModified(
                self.voltageSpacing, self.meanVoltage, self.meanCurrent)
            self.canvas.addPointsAndLine(
                self.voltageSpacing, self.apparentResistivity)

            voltageSpacingExtrapolated, newResistivity = interpolateFieldData(
                self.voltageSpacing, self.apparentResistivity, 'schlumberger')
            self.voltageSpacingExtrapolated = voltageSpacingExtrapolated
            self.newResistivity = newResistivity

            self.filteredResistivity = applyFilter(
                self.newResistivity,
                self.longFilterCoefficients)

            sampleInterval = np.log(10) / 3.
            self.samplePoints = np.arange(
                start=(-sampleInterval * 2),
                stop=(sampleInterval * 20),
                step=sampleInterval)

        # Provide a message box if neither Wenner nor Schlumberger are selected
        else:
            self.noSpacingMessageBox(suppress)
            return

        return self.apparentResistivity