Skip to content

Commit

Permalink
examples: update examples for geo_scale
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb committed Jun 12, 2023
1 parent b96f844 commit 5486a1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
9 changes: 6 additions & 3 deletions examples/08_geo_coordinates/00_field_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
To generate the field, we simply pass ``(lat, lon)`` as the position tuple
to the :any:`SRF` class.
"""
import numpy as np

import gstools as gs

model = gs.Gaussian(latlon=True, len_scale=777, geo_scale=gs.EARTH_RADIUS)
Expand All @@ -32,7 +34,7 @@
#
# As we will see, everthing went well... phew!

bin_edges = [0.01 * i for i in range(30)]
bin_edges = np.linspace(0, 777 * 3, 30)
bin_center, emp_vario = gs.vario_estimate(
(lat, lon),
field,
Expand All @@ -41,11 +43,12 @@
mesh_type="structured",
sampling_size=2000,
sampling_seed=12345,
geo_scale=gs.EARTH_RADIUS,
)

ax = model.plot("vario_yadrenko", x_max=0.3)
ax = model.plot("vario_yadrenko", x_max=max(bin_center))
model.fit_variogram(bin_center, emp_vario, nugget=False)
model.plot("vario_yadrenko", ax=ax, label="fitted", x_max=0.3)
model.plot("vario_yadrenko", ax=ax, label="fitted", x_max=max(bin_center))
ax.scatter(bin_center, emp_vario, color="k")
print(model)

Expand Down
15 changes: 8 additions & 7 deletions examples/08_geo_coordinates/01_dwd_krige.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ def get_dwd_temperature(date="2020-06-09 12:00:00"):

###############################################################################
# First we will estimate the variogram of our temperature data.
# As the maximal bin distance we choose 8 degrees, which corresponds to a
# chordal length of about 900 km.
# As the maximal bin distance we choose 900 km.

bins = gs.standard_bins((lat, lon), max_dist=np.deg2rad(8), latlon=True)
bin_c, vario = gs.vario_estimate((lat, lon), temp, bins, latlon=True)
bin_center, vario = gs.vario_estimate(
(lat, lon), temp, latlon=True, geo_scale=gs.EARTH_RADIUS, max_dist=900
)

###############################################################################
# Now we can use this estimated variogram to fit a model to it.
Expand All @@ -98,9 +98,9 @@ def get_dwd_temperature(date="2020-06-09 12:00:00"):
# distance.

model = gs.Spherical(latlon=True, geo_scale=gs.EARTH_RADIUS)
model.fit_variogram(bin_c, vario, nugget=False)
ax = model.plot("vario_yadrenko", x_max=bins[-1])
ax.scatter(bin_c, vario)
model.fit_variogram(bin_center, vario, nugget=False)
ax = model.plot("vario_yadrenko", x_max=max(bin_center))
ax.scatter(bin_center, vario)
print(model)

###############################################################################
Expand Down Expand Up @@ -171,3 +171,4 @@ def north_south_drift(lat, lon):

###############################################################################
# Interpretion of the results is now up to you! ;-)
plt.show()

0 comments on commit 5486a1c

Please sign in to comment.