def pushhandler(self, yyyyddd, weather, baseyear, func, skip_on_missing): """ Returns an interator of (yyyy, value, ...). """ for yearresult in self.subapp.push(yyyyddd, weather): year = yearresult[0] result = yearresult[1] # Should we base everything off this year? if year == self.year2: self.denomterms.append(result) self.denom = np.mean(self.denomterms) # Print out all past results, re-based for pastresult in self.pastresults: diagnostic.record(self.region, pastresult[0], 'baseline', self.denom) yield [pastresult[0], func(pastresult[1], self.denom)] + list(pastresult[1:]) if self.denom is None: # Keep track of this until we have a base self.pastresults.append(yearresult) if year >= self.year1: self.denomterms.append(result) else: diagnostic.record(self.region, year, 'baseline', self.denom) # calculate this and tack it on yield [year, func(result, self.denom)] + list(yearresult[1:])
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)