I was trying with the below code, and I met with the specified error code. Can anyone tell me why is it coming like this?
Code:
import numpy as np
import xarray as xr
from scipy.stats import gamma
import matplotlib.pyplot as plt
data1 = xr.open_dataset('data1.nc')
avg1 = data1.sel(lat=slice(5,38),lon=slice(60,100))
data1_fit = gamma.fit(avg1['variable1'], floc=0)
Error code:
FitDataError: Invalid values in data
. Maximum likelihood estimation with 'gamma' requires that 0 < (x - loc)/scale < inf for each x in data
.
How can I fix this problem?
I was trying to fit a variable of a netcdf data into a gamma distribution. But this is where I get stuck in between.