def generate(region, year, temps, **kw): temps2 = self.weather_change(temps) result = np.nansum(curve(temps2)) / len(temps2) if diagnostic.is_recording(): diagnostic.record(region, year, 'avgv', float(np.nansum(temps2)) / len(temps2)) if not np.isnan(result): yield (year, result) if isinstance(curve, AdaptableCurve): curve.update(year, temps) # XXX: pass the original temps (labor decision, generalize?)
def generate(region, year, temps, **kw): coeffs = self.getter(region, year, temps, curve) if len(temps) == len(coeffs): result = np.sum(self.weather_change(region, temps).dot(coeffs)) else: raise RuntimeError("Unknown format for temps: " + str(temps.shape) + " <> len " + str(coeffs)) if diagnostic.is_recording(): for ii in range(temps.shape[0]): diagnostic.record(region, year, 'var-' + str(ii), temps[ii]) if not np.isnan(result): yield (year, result) if isinstance(curve, AdaptableCurve): curve.update(year, temps) # Passing in original (not weather-changed data)
def generate(region, year, temps, **kw): temps = self.weather_change(temps) assert temps.shape[1] == len(curve.curr_curve.ccs), "%d <> %d" % (temps.shape[1], len(curve.curr_curve.ccs)) #result = np.nansum(np.dot(temps, curve.curr_curve.ccs)) / len(temps) result = np.dot(np.sum(temps, axis=0), curve.curr_curve.ccs) / len(temps) if diagnostic.is_recording(): sumtemps = np.sum(temps, axis=0) / len(temps) for ii in range(temps.shape[1]): diagnostic.record(region, year, 'avgtk_' + str(ii+1), sumtemps[ii]) if not np.isnan(result): yield (year, result) if isinstance(curve, AdaptableCurve): curve.update(year, temps)