Exemplo n.º 1
0
 def test_transform(self):
     self.cov_model.dim = 2
     srf = SRF(self.cov_model, mean=self.mean, mode_no=self.mode_no)
     srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
     tf.normal_force_moments(srf)  # force ergodicity of the given field
     self.assertAlmostEqual(srf.field.mean(), srf.mean)
     self.assertAlmostEqual(srf.field.var(), srf.model.var)
     tf.zinnharvey(srf)  # make high values mostly connected
     tf.normal_force_moments(srf)  # force ergodicity of the given field
     tf.normal_to_lognormal(srf)  # log-normal
     srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
     tf.normal_to_arcsin(srf)
     srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
     tf.normal_to_uquad(srf)
     srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
     tf.normal_to_uniform(srf)
Exemplo n.º 2
0
    def test_transform(self):
        self.cov_model.dim = 2
        srf = gs.SRF(self.cov_model, mean=self.mean, mode_no=self.mode_no)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.normal_force_moments(srf)  # force ergodicity of the given field
        self.assertAlmostEqual(srf.field.mean(), srf.mean)
        self.assertAlmostEqual(srf.field.var(), srf.model.var)
        tf.zinnharvey(srf)  # make high values mostly connected
        tf.normal_force_moments(srf)  # force ergodicity of the given field
        tf.normal_to_lognormal(srf)  # log-normal
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.normal_to_arcsin(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.normal_to_uquad(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.normal_to_uniform(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.binary(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        tf.boxcox(srf)
        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = np.linspace(np.min(srf.field), np.max(srf.field), 3)
        tf.discrete(srf, values)

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 1]
        thresholds = [-0.9, 0.1]
        tf.discrete(srf, values, thresholds)
        np.testing.assert_array_equal(np.unique(srf.field), [-1, 0, 1])

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 1]
        tf.discrete(srf, values, thresholds="arithmetic")
        np.testing.assert_array_equal(np.unique(srf.field), [-1.0, 0.0, 1.0])

        srf((self.x_grid, self.y_grid), seed=self.seed, mesh_type="structured")
        values = [-1, 0, 0.5, 1]
        tf.discrete(srf, values, thresholds="equal")
        np.testing.assert_array_equal(np.unique(srf.field), values)
Exemplo n.º 3
0
 # set storativity
 model.mmp.update_block(STORAGE=[1, para[0]])
 model.mmp.write_file()
 # init cov model (truncated power law with gaussian modes)
 cov = gs.TPLGaussian(dim=2, var=para[2], len_scale=para[3], hurst=para[4])
 # init spatial random field class
 srf = gs.SRF(cov, mean=np.log(para[1]), upscaling="coarse_graining")
 # run the ensemble
 for i in range(ens_size):
     # parallel running the right jobs on each core
     if (para_no * ens_size + i) % size != rank:
         continue
     # generate new transmissivity field
     srf.mesh(model.msh, seed=seed(), point_volumes=model.msh.volumes_flat)
     # transfrom to log-normal field
     tf.normal_to_lognormal(srf)
     # add the transmissivity to the ogs project
     model.mpd.update_block(DATA=by_id(srf.field))
     # write the new mpd file
     model.mpd.write_file()
     # set the new output-directory
     model.output_dir = os.path.join(
         task_root, "para{:04}".format(para_no), "seed{:04}".format(i)
     )
     print("  run model {:04}".format(i), end=" ")
     success = model.run_model(print_log=False, save_log=keep_output)
     print("  ...success") if success else print("  ...error!")
     if not success:
         FAIL.append(str(para_no) + "_" + str(i))
     # calculate angular means
     angles_mean(time, rad, angles, model.output_dir)