Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.rng = np.random.RandomState(123018)
self.x_tuple = self.rng.uniform(0.0, 10, 100)
self.y_tuple = self.rng.uniform(0.0, 10, 100)
self.z_tuple = self.rng.uniform(0.0, 10, 100)
self.f1_tuple = self.x_tuple
self.f2_tuple = self.x_tuple * self.y_tuple
self.f3_tuple = self.x_tuple * self.y_tuple * self.z_tuple
self.m1_grid = Mesh((self.x_grid,), mesh_type="structured")
self.m2_grid = Mesh((self.x_grid, self.y_grid), mesh_type="structured")
self.m3_grid = Mesh(
(self.x_grid, self.y_grid, self.z_grid), mesh_type="structured"
)
self.m1_tuple = Mesh((self.x_tuple,))
self.m2_tuple = Mesh((self.x_tuple, self.y_tuple))
self.m3_tuple = Mesh((self.x_tuple, self.y_tuple, self.z_tuple))
self.x_grid.reshape((len(self.x_grid), 1, 1))
* self.y_grid.reshape((1, len(self.y_grid), 1))
* self.z_grid.reshape((1, 1, len(self.z_grid)))
)
self.rng = np.random.RandomState(123018)
self.x_tuple = self.rng.uniform(0.0, 10, 100)
self.y_tuple = self.rng.uniform(0.0, 10, 100)
self.z_tuple = self.rng.uniform(0.0, 10, 100)
self.f1_tuple = self.x_tuple
self.f2_tuple = self.x_tuple * self.y_tuple
self.f3_tuple = self.x_tuple * self.y_tuple * self.z_tuple
self.m1_grid = Mesh((self.x_grid,), mesh_type="structured")
self.m2_grid = Mesh((self.x_grid, self.y_grid), mesh_type="structured")
self.m3_grid = Mesh(
(self.x_grid, self.y_grid, self.z_grid), mesh_type="structured"
)
self.m1_tuple = Mesh((self.x_tuple,))
self.m2_tuple = Mesh((self.x_tuple, self.y_tuple))
self.m3_tuple = Mesh((self.x_tuple, self.y_tuple, self.z_tuple))
self.x_tuple = self.rng.uniform(0.0, 10, 100)
self.y_tuple = self.rng.uniform(0.0, 10, 100)
self.z_tuple = self.rng.uniform(0.0, 10, 100)
self.f1_tuple = self.x_tuple
self.f2_tuple = self.x_tuple * self.y_tuple
self.f3_tuple = self.x_tuple * self.y_tuple * self.z_tuple
self.m1_grid = Mesh((self.x_grid,), mesh_type="structured")
self.m2_grid = Mesh((self.x_grid, self.y_grid), mesh_type="structured")
self.m3_grid = Mesh(
(self.x_grid, self.y_grid, self.z_grid), mesh_type="structured"
)
self.m1_tuple = Mesh((self.x_tuple,))
self.m2_tuple = Mesh((self.x_tuple, self.y_tuple))
self.m3_tuple = Mesh((self.x_tuple, self.y_tuple, self.z_tuple))
* self.y_grid.reshape((1, len(self.y_grid), 1))
* self.z_grid.reshape((1, 1, len(self.z_grid)))
)
self.rng = np.random.RandomState(123018)
self.x_tuple = self.rng.uniform(0.0, 10, 100)
self.y_tuple = self.rng.uniform(0.0, 10, 100)
self.z_tuple = self.rng.uniform(0.0, 10, 100)
self.f1_tuple = self.x_tuple
self.f2_tuple = self.x_tuple * self.y_tuple
self.f3_tuple = self.x_tuple * self.y_tuple * self.z_tuple
self.m1_grid = Mesh((self.x_grid,), mesh_type="structured")
self.m2_grid = Mesh((self.x_grid, self.y_grid), mesh_type="structured")
self.m3_grid = Mesh(
(self.x_grid, self.y_grid, self.z_grid), mesh_type="structured"
)
self.m1_tuple = Mesh((self.x_tuple,))
self.m2_tuple = Mesh((self.x_tuple, self.y_tuple))
self.m3_tuple = Mesh((self.x_tuple, self.y_tuple, self.z_tuple))
self.f3_grid = (
self.x_grid.reshape((len(self.x_grid), 1, 1))
* self.y_grid.reshape((1, len(self.y_grid), 1))
* self.z_grid.reshape((1, 1, len(self.z_grid)))
)
self.rng = np.random.RandomState(123018)
self.x_tuple = self.rng.uniform(0.0, 10, 100)
self.y_tuple = self.rng.uniform(0.0, 10, 100)
self.z_tuple = self.rng.uniform(0.0, 10, 100)
self.f1_tuple = self.x_tuple
self.f2_tuple = self.x_tuple * self.y_tuple
self.f3_tuple = self.x_tuple * self.y_tuple * self.z_tuple
self.m1_grid = Mesh((self.x_grid,), mesh_type="structured")
self.m2_grid = Mesh((self.x_grid, self.y_grid), mesh_type="structured")
self.m3_grid = Mesh(
(self.x_grid, self.y_grid, self.z_grid), mesh_type="structured"
)
self.m1_tuple = Mesh((self.x_tuple,))
self.m2_tuple = Mesh((self.x_tuple, self.y_tuple))
self.m3_tuple = Mesh((self.x_tuple, self.y_tuple, self.z_tuple))
self.assertRaises(ValueError, self.m2_grid.add_field, self.f2_tuple)
self.assertRaises(ValueError, self.m2_grid.add_field, self.f3_tuple)
self.assertRaises(ValueError, self.m3_grid.add_field, self.f1_tuple)
self.assertRaises(ValueError, self.m3_grid.add_field, self.f2_tuple)
self.assertRaises(ValueError, self.m3_grid.add_field, self.f3_tuple)
x_tuple2 = self.rng.uniform(0.0, 10, 100)
y_tuple2 = self.rng.uniform(0.0, 10, 100)
f_tuple2 = np.vstack((x_tuple2, y_tuple2))
x_tuple3 = self.rng.uniform(0.0, 10, (3, 100))
y_tuple3 = self.rng.uniform(0.0, 10, (3, 100))
z_tuple3 = self.rng.uniform(0.0, 10, (3, 100))
f_tuple3 = np.vstack((x_tuple2, y_tuple2, z_tuple3))
m2_tuple = Mesh((x_tuple2, y_tuple2))
m3_tuple = Mesh((x_tuple3, y_tuple3, z_tuple3))
self.assertRaises(ValueError, m2_tuple.add_field, f_tuple3)
self.assertRaises(ValueError, m3_tuple.add_field, f_tuple2)
f_grid2 = np.zeros((2, len(self.x_grid), len(self.y_grid)))
f_grid3 = np.zeros(
(3, len(self.x_grid), len(self.y_grid), len(self.z_grid))
)
self.assertRaises(ValueError, self.m2_grid.add_field, f_grid3)
self.assertRaises(ValueError, self.m3_grid.add_field, f_grid2)
self.assertRaises(ValueError, self.m2_grid.add_field, self.f1_tuple)
self.assertRaises(ValueError, self.m2_grid.add_field, self.f2_tuple)
self.assertRaises(ValueError, self.m2_grid.add_field, self.f3_tuple)
self.assertRaises(ValueError, self.m3_grid.add_field, self.f1_tuple)
self.assertRaises(ValueError, self.m3_grid.add_field, self.f2_tuple)
self.assertRaises(ValueError, self.m3_grid.add_field, self.f3_tuple)
x_tuple2 = self.rng.uniform(0.0, 10, 100)
y_tuple2 = self.rng.uniform(0.0, 10, 100)
f_tuple2 = np.vstack((x_tuple2, y_tuple2))
x_tuple3 = self.rng.uniform(0.0, 10, (3, 100))
y_tuple3 = self.rng.uniform(0.0, 10, (3, 100))
z_tuple3 = self.rng.uniform(0.0, 10, (3, 100))
f_tuple3 = np.vstack((x_tuple2, y_tuple2, z_tuple3))
m2_tuple = Mesh((x_tuple2, y_tuple2))
m3_tuple = Mesh((x_tuple3, y_tuple3, z_tuple3))
self.assertRaises(ValueError, m2_tuple.add_field, f_tuple3)
self.assertRaises(ValueError, m3_tuple.add_field, f_tuple2)
f_grid2 = np.zeros((2, len(self.x_grid), len(self.y_grid)))
f_grid3 = np.zeros(
(3, len(self.x_grid), len(self.y_grid), len(self.z_grid))
)
self.assertRaises(ValueError, self.m2_grid.add_field, f_grid3)
self.assertRaises(ValueError, self.m3_grid.add_field, f_grid2)
self.rng = np.random.RandomState(123018)
self.x_tuple = self.rng.uniform(0.0, 10, 100)
self.y_tuple = self.rng.uniform(0.0, 10, 100)
self.z_tuple = self.rng.uniform(0.0, 10, 100)
self.f1_tuple = self.x_tuple
self.f2_tuple = self.x_tuple * self.y_tuple
self.f3_tuple = self.x_tuple * self.y_tuple * self.z_tuple
self.m1_grid = Mesh((self.x_grid,), mesh_type="structured")
self.m2_grid = Mesh((self.x_grid, self.y_grid), mesh_type="structured")
self.m3_grid = Mesh(
(self.x_grid, self.y_grid, self.z_grid), mesh_type="structured"
)
self.m1_tuple = Mesh((self.x_tuple,))
self.m2_tuple = Mesh((self.x_tuple, self.y_tuple))
self.m3_tuple = Mesh((self.x_tuple, self.y_tuple, self.z_tuple))
tmp_model = gs.Exponential(dim=2, var=1.5, len_scale=10.0)
tmp_srf = gs.SRF(tmp_model)
field = tmp_srf((x, y))
tmp_srf.plot()
# Now that we have our data, let's delete everything GSTools related and pretend
# that this has never happend
del(tmp_model)
del(tmp_srf)
# Creating the Mesh
# ^^^^^^^^^^^^^^^^^
#
# Starting out fresh, we want to feed the mesh with our data
mesh = gs.Mesh(pos=(x, y), values=field)
# We can add meta data too
mesh.set_field_data("Süderbrarup", "location")
mesh.set_field_data(date(year=2020, month=2, day=28), "date")
# This can be conviniently accessed
print(mesh.location)
print(mesh.date)
# But the meta data is also collected as a dictionary in case you want to export
# it
print(mesh.field_data)
# Estimating the Variogram
# ^^^^^^^^^^^^^^^^^^^^^^^^