GeoStat-Framework / GSTools

GSTools - A geostatistical toolbox: random fields, variogram estimation, covariance models, kriging and much more
https://geostat-framework.org
GNU Lesser General Public License v3.0
544 stars 71 forks source link

[Error] Normalize Fit with ValueError: Each lower bound must be strictly less than each upper bound. #329

Closed Jimmy-KL closed 10 months ago

Jimmy-KL commented 11 months ago

Here is the code for this example:

import numpy as np
import gstools as gs

x_coords = np.array([630438.6, 630874.0, 630875.0, 630860.85, 630874.75, 630876.35, 630838.05, 630834.85, 630669.1, 630645.05, 630665.8, 630486.45, 630715.3, 630658.2, 630696.85, 630705.8, 630762.4, 630914.25, 630950.25, 630804.05, 630762.65, 630831.1, 630549.95, 630645.45, 630709.25, 630660.15, 630451.85, 630468.2, 630511.3, 630581.6, 630866.35, 630430.0, 630764.9, 630612.9, 630586.35, 630474.35, 630664.95, 630716.05, 630752.75, 630786.1, 630763.4, 630770.9, 630758.05])
y_coords = np.array([4272028.71, 4271975.54, 4272007.46, 4272057.93, 4272087.44, 4272109.35, 4272111.83, 4272085.23, 4272230.24, 4272176.02, 4272160.76, 4271972.71, 4272181.38, 4272151.03, 4272153.41, 4272079.77, 4272075.43, 4271998.47, 4272062.83, 4271900.08, 4272014.78, 4271962.45, 4271956.71, 4272001.13, 4272056.15, 4272129.86, 4272071.13, 4272082.89, 4272192.16, 4272233.63, 4272102.35, 4272100.28, 4271960.21, 4271957.41, 4272223.8, 4272081.63, 4271957.17, 4271957.87, 4271957.76, 4271962.56, 4271984.29, 4271957.52, 4271956.82])
values = np.array([31.95, 30.75, 30.46, 30.47, 30.14, 31.24, 31.18, 31.55, 31.12, 31.0, 30.4, 30.95, 31.37, 31.58, 30.69, 31.22, 30.69, 31.18, 31.18, 30.53, 31.22, 30.47, 30.94, 31.66, 30.72, 31.7, 30.8, 31.75, 30.23, 31.79, 31.34, 30.62, 31.05, 30.86, 30.46, 31.83, 30.77, 30.81, 30.82, 30.75, 30.75, 30.59, 30.58])

krig = gs.krige.Ordinary(
    model=gs.Spherical(dim=2),
    cond_pos=[x_coords, y_coords],
    cond_val=boring_tops,
    normalizer=gs.normalizer.BoxCox(),
    fit_normalizer=True,
    fit_variogram=True,
)

print(krig.model)

Run the above code, and the following error will be got: ValueError: Each lower bound must be strictly less than each upper bound. I tried other types of normalizer, only the base Normalizer can work.

Is it a bug or something wrong with my code or data?

LSchueler commented 10 months ago

Hi Jimmy-KL,

I'm very sorry for the late reply. I think the variance of your values is too small, which leads to divisions by zero. I just manually doubled some of the values in your example and set some to nearly zero and the script successfully finds the parameters.