Skip to content

Commit 04c1bbb

Browse files
committed
Update readme example
1 parent e96848b commit 04c1bbb

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

Diff for: CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
All notable changes to **GSTools** will be documented in this file.
44

55

6-
## [1.3.3] - Pure Pink - ?
6+
## [1.3.3] - Pure Pink - 2021-08
77

88
### Enhancements
99
See: [#197](https://github.com/GeoStat-Framework/GSTools/issues/197)

Diff for: README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,19 @@ import gstools as gs
228228
cond_pos = [0.3, 1.9, 1.1, 3.3, 4.7]
229229
cond_val = [0.47, 0.56, 0.74, 1.47, 1.74]
230230

231-
gridx = np.linspace(0.0, 15.0, 151)
232-
233231
# conditioned spatial random field class
234232
model = gs.Gaussian(dim=1, var=0.5, len_scale=2)
235233
krige = gs.krige.Ordinary(model, cond_pos, cond_val)
236234
cond_srf = gs.CondSRF(krige)
235+
# same output positions for all ensemble members
236+
grid_pos = np.linspace(0.0, 15.0, 151)
237+
cond_srf.set_pos(grid_pos)
237238

238-
# generate the ensemble of field realizations
239-
fields = []
239+
# seeded ensemble generation
240+
seed = gs.random.MasterRNG(20170519)
240241
for i in range(100):
241-
fields.append(cond_srf(gridx, seed=i))
242-
plt.plot(gridx, fields[i], color="k", alpha=0.1)
242+
field = cond_srf(seed=seed(), store=f"field_{i}")
243+
plt.plot(grid_pos, field, color="k", alpha=0.1)
243244
plt.scatter(cond_pos, cond_val, color="k")
244245
plt.show()
245246
```

Diff for: docs/source/index.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,19 @@ generate 100 realizations and plot them:
268268
cond_pos = [0.3, 1.9, 1.1, 3.3, 4.7]
269269
cond_val = [0.47, 0.56, 0.74, 1.47, 1.74]
270270
271-
gridx = np.linspace(0.0, 15.0, 151)
272-
273271
# conditioned spatial random field class
274272
model = gs.Gaussian(dim=1, var=0.5, len_scale=2)
275273
krige = gs.krige.Ordinary(model, cond_pos, cond_val)
276274
cond_srf = gs.CondSRF(krige)
275+
# same output positions for all ensemble members
276+
grid_pos = np.linspace(0.0, 15.0, 151)
277+
cond_srf.set_pos(grid_pos)
277278
278-
# generate the ensemble of field realizations
279-
fields = []
279+
# seeded ensemble generation
280+
seed = gs.random.MasterRNG(20170519)
280281
for i in range(100):
281-
fields.append(cond_srf(gridx, seed=i))
282-
plt.plot(gridx, fields[i], color="k", alpha=0.1)
282+
field = cond_srf(seed=seed(), store=f"field_{i}")
283+
plt.plot(grid_pos, field, color="k", alpha=0.1)
283284
plt.scatter(cond_pos, cond_val, color="k")
284285
plt.show()
285286

0 commit comments

Comments
 (0)