Пример #1
0
    def get_fill(self, _from, to):
        constants.validate_date(_from)
        constants.validate_date(to)

        # waarden zijn in cm onder overstortbuis
        ts = self._get_timeseries_as_pd_series(
            constants.fill_filter_id,
            constants.fill_location_id,
            constants.fill_parameter_id,
            _from, to, 'fill'
        )

        # deal with NaN values
        #if np.NaN in ts:
        #    raise Exception('Found NaN in results')
        #ts = ts.fillna(0)

        # zet om in cm vanaf bodem bak
        ts += constants.hoogte_niveaumeter_cm
        # zet om naar fractie totale bak
        ts /= constants.bovenkant_bak_cm
        # zet om naar m3
        ts *= constants.max_berging_m3

        return ts
Пример #2
0
    def get_demand(self, _from, to):
        constants.validate_date(_from)
        constants.validate_date(to)

        # ensure we deal with values for _from which are mid-week
        from_adj = _from - 2 * one_week
        to_adj = to + 2 * one_week
        weekly = pd.date_range(from_adj, to_adj, freq='W-MON', tz=pytz.utc) # week changes on monday
        values = [self.get_week_demand_on(date) for date in weekly]

        ts = pd.Series(values, weekly, name='demand')
        ts = ts.resample('15min')
        ts = ts.interpolate()
        # divide by amount of quarter hours in a week
        ts /= 7 * 24 * 4
        #import pdb; pdb.set_trace()
        return ts[_from:to]
Пример #3
0
    def get_rain(self, which, _from, to):
        constants.validate_date(_from)
        constants.validate_date(to)

        rain = self._get_timeseries_as_pd_series(
            constants.rain_filter_id,
            constants.rain_location_id,
            constants.rain_parameter_ids[which],
            _from, to, 'rain_' + which
        )

        # convert to quarterly figures
        rain = rain.resample('15min', fill_method='ffill')
        # 4 quarters in an hour
        rain /= 4
        # deal with NaN values
        #if np.nan in rain:
        #    raise Exception('Found NaN in results')
        #rain = rain.fillna(0)

        return rain