28
28
from scipy .spatial .distance import cdist
29
29
30
30
from . import core , variogram_models
31
+ from .compat_gstools import validate_gstools
31
32
from .core import (
32
33
P_INV ,
33
34
_adjust_for_anisotropy ,
@@ -217,12 +218,20 @@ def __init__(
217
218
raise ValueError ("exact_values has to be boolean True or False" )
218
219
self .exact_values = exact_values
219
220
221
+ self .coordinates_type = coordinates_type
222
+
220
223
# check if a GSTools covariance model is given
221
224
if hasattr (self .variogram_model , "pykrige_kwargs" ):
222
225
# save the model in the class
223
226
self .model = self .variogram_model
224
- if self .model .dim == 3 :
227
+ validate_gstools (self .model )
228
+ if self .model .field_dim == 3 :
225
229
raise ValueError ("GSTools: model dim is not 1 or 2" )
230
+ # check if coordinate types match
231
+ if self .model .latlon and (self .coordinates_type == "euclidean" ):
232
+ raise ValueError (
233
+ "GSTools: latlon models require geographic coordinates"
234
+ )
226
235
self .variogram_model = "custom"
227
236
variogram_function = self .model .pykrige_vario
228
237
variogram_parameters = []
@@ -265,7 +274,7 @@ def __init__(
265
274
266
275
# adjust for anisotropy... only implemented for euclidean (rectangular)
267
276
# coordinates, as anisotropy is ambiguous for geographic coordinates...
268
- if coordinates_type == "euclidean" :
277
+ if self . coordinates_type == "euclidean" :
269
278
self .XCENTER = (np .amax (self .X_ORIG ) + np .amin (self .X_ORIG )) / 2.0
270
279
self .YCENTER = (np .amax (self .Y_ORIG ) + np .amin (self .Y_ORIG )) / 2.0
271
280
self .anisotropy_scaling = anisotropy_scaling
@@ -278,7 +287,7 @@ def __init__(
278
287
[self .anisotropy_scaling ],
279
288
[self .anisotropy_angle ],
280
289
).T
281
- elif coordinates_type == "geographic" :
290
+ elif self . coordinates_type == "geographic" :
282
291
# Leave everything as is in geographic case.
283
292
# May be open to discussion?
284
293
if anisotropy_scaling != 1.0 :
@@ -298,7 +307,6 @@ def __init__(
298
307
"Only 'euclidean' and 'geographic' are valid "
299
308
"values for coordinates-keyword."
300
309
)
301
- self .coordinates_type = coordinates_type
302
310
303
311
if self .verbose :
304
312
print ("Initializing variogram model..." )
@@ -422,8 +430,14 @@ def update_variogram_model(
422
430
if hasattr (self .variogram_model , "pykrige_kwargs" ):
423
431
# save the model in the class
424
432
self .model = self .variogram_model
425
- if self .model .dim == 3 :
433
+ validate_gstools (self .model )
434
+ if self .model .field_dim == 3 :
426
435
raise ValueError ("GSTools: model dim is not 1 or 2" )
436
+ # check if coordinate types match
437
+ if self .model .latlon and (self .coordinates_type == "euclidean" ):
438
+ raise ValueError (
439
+ "GSTools: latlon models require geographic coordinates"
440
+ )
427
441
self .variogram_model = "custom"
428
442
variogram_function = self .model .pykrige_vario
429
443
variogram_parameters = []
0 commit comments