I want to use scipy.interpolate.SmoothSphereBivariateSpline to interpolate temperature on a map (I'm not familiar with data interpolation, so this maybe not a good choice but I'd like to give it a go).
These are what I did:
latitude longitude temperature city
30.22 120.14 39 2caves
30.26 120.13 39 3caves
30.23 120.13 39 Anlong
33.48 108.5 30 Anda
37.2 100.74 15 Anan
...
into pandas
data = pandas.read_table('temp.tsv')
Get radians from lat, lon:
theta = numpy.array(data.latitude) / 180 * numpy.pi # the lat, lon domain is safe here so
phi = numpy.array(data.longitude) / 180 * numpy.pi # I won't adjust for the output range
temp = numpy.array(data.temperature)
Feed them into scipy:
lut = SmoothSphereBivariateSpline(theta, phi, temps)
Then the function throws a ValueError:
ValueError: The required storage space exceeds the available storage space: nxest or nyest too small, or s too small. The weighted least-squares spline corresponds to the current set of knots.
I've tried to adjust the s parameter with different values, from 1, 2, 3 to 7000, 8000, it just kept being too small. What should I do to make the interpolation work?
Just for the records: following the documentation there is a smoothing parameter s
to be chosen; the default value is s=0
, but sometimes it is critical to select it manually as suggested in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With