# HG changeset patch # User Daniel O'Connor # Date 1317186503 -34200 # Node ID 184ea77c10e7259764bd38833491301f8cc19858 # Parent df1b4d7e988fa6b8bbf1c39dcb193938ddce81bb Use scipys interpolation routines rather than hand rolling. diff -r df1b4d7e988f -r 184ea77c10e7 sitesurvey.py --- a/sitesurvey.py Wed Sep 28 13:35:45 2011 +0930 +++ b/sitesurvey.py Wed Sep 28 14:38:23 2011 +0930 @@ -31,6 +31,7 @@ import exceptions import numpy import os +import scipy.interpolate import scpi import specan import sys @@ -86,21 +87,8 @@ self.calfreqs = freqs self.calgains = gains - def interp(self, freqs): - '''Interoplate the calibration over freqs and return an array''' - deltas = numpy.zeros(freqs.shape) - - for i in range(len(freqs)): - if freqs[i] < self.calfreqs[0] or freqs[i] > self.calfreqs[-1]: - raise exceptions.SyntaxError("Frequency %.1f is out of range of calibration %f - %f" % (f, calfreqs[0], calfreqs[-1])) - - # Find idx such that calfreqs[idx - 1] < freqs[i] <= calfreqs[idx] - idx = self.calfreqs.searchsorted(freqs[i]) - sf = (freqs[i] - self.calfreqs[idx - 1]) / (self.calfreqs[idx] - self.calfreqs[idx - 1]) - delta = ((self.calgains[idx] - self.calgains[idx - 1]) * sf) + self.calgains[idx] - deltas[i] = delta - return deltas - + # Create interpolation function + self.interp = scipy.interpolate.interp1d(self.calfreqs, self.calgains, bound_error = True) def getexpt(sequence): '''Given a sequence return the experiment which should be run next and how long until it should start'''