How to use the porespy.metrics.porosity function in porespy

To help you get started, we’ve selected a few porespy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PMEAL / porespy / test / unit / test_metrics.py View on Github external
def test_porosity(self):
        phi = ps.metrics.porosity(im=self.im2D)
        assert phi == 0.6619
github PMEAL / porespy / test / unit / test_metrics.py View on Github external
def test_tpcf_fft_3d(self):
        tpcf_fft = ps.metrics.two_point_correlation_fft(self.im3D)
        t = 0.2
        phi1 = ps.metrics.porosity(im=self.im3D)
        assert sp.sqrt((sp.mean(tpcf_fft.probability[-5:]) - phi1)**2) < t
github PMEAL / porespy / test / unit / test_metrics.py View on Github external
def test_two_point_correlation_bf(self):
        tpcf_bf = ps.metrics.two_point_correlation_bf(self.im2D)
        # autocorrelation fn should level off at around the porosity
        t = 0.2
        phi1 = ps.metrics.porosity(im=self.im2D)
        assert sp.sqrt((sp.mean(tpcf_bf.probability[-5:]) - phi1)**2) < t
github PMEAL / porespy / test / unit / test_filters.py View on Github external
def setup_class(self):
        sp.random.seed(0)
        self.im = ps.generators.blobs(shape=[100, 100, 100], blobiness=2)
        # Ensure that im was generated as expeccted
        assert ps.metrics.porosity(self.im) == 0.499829
        self.im_dt = spim.distance_transform_edt(self.im)
github PMEAL / porespy / test / unit / test_metrics.py View on Github external
def test_tpcf_fft_2d(self):
        tpcf_fft_1 = ps.metrics.two_point_correlation_fft(self.im2D)
        tpcf_fft_2 = ps.metrics.two_point_correlation_fft(self.im2D_big)
        # autocorrelation fn should level off at around the porosity
        t = 0.2
        phi1 = ps.metrics.porosity(im=self.im2D)
        assert sp.sqrt((sp.mean(tpcf_fft_1.probability[-5:]) - phi1)**2) < t
        phi2 = ps.metrics.porosity(im=self.im2D_big)
        assert sp.sqrt((sp.mean(tpcf_fft_2.probability[-5:]) - phi2)**2) < t
github PMEAL / porespy / test / unit / test_metrics.py View on Github external
def test_tpcf_fft_2d(self):
        tpcf_fft_1 = ps.metrics.two_point_correlation_fft(self.im2D)
        tpcf_fft_2 = ps.metrics.two_point_correlation_fft(self.im2D_big)
        # autocorrelation fn should level off at around the porosity
        t = 0.2
        phi1 = ps.metrics.porosity(im=self.im2D)
        assert sp.sqrt((sp.mean(tpcf_fft_1.probability[-5:]) - phi1)**2) < t
        phi2 = ps.metrics.porosity(im=self.im2D_big)
        assert sp.sqrt((sp.mean(tpcf_fft_2.probability[-5:]) - phi2)**2) < t
github PMEAL / porespy / porespy / __BaseClass__.py View on Github external
def _get_phi(self):
        if 'phi' not in self.keys():
            self['phi'] = porosity(self.im)
        return self['phi']
github PMEAL / porespy / porespy / simulations / __RandomWalk__.py View on Github external
def __init__(self, im, walkers=1000, max_steps=5000, stride=10,
                 start_frac=0.2):
        self.im = np.array(im, ndmin=3)
        self._max_steps = max_steps
        self._stride = stride
        self._start_frac = start_frac
        self.porosity = porosity(im)
        self._ndim = np.ndim(im)
        if self._ndim == 3:
            self._z_len = np.size(im, 0)
            self._y_len = np.size(im, 1)
            self._x_len = np.size(im, 2)
        elif self._ndim == 2:
            self._z_len = 1
            self._y_len = np.size(im, 0)
            self._x_len = np.size(im, 1)
        else:
            raise ValueError('image needs to be 2 or 3 dimensional')
        self._shape = (self._z_len, self._y_len, self._x_len)
        self._path_data = None
        self._sd_data = None
        self._sd_updated = False
        self._sterr_data = None