DataPoint _pair(VariablePricesAndRenewable amberVars, Forecast dp)
        {
            var t = amberVars.period;

            var ds = dp.Hourly.Data.OrderByDescending(_ => _.DateTime).FirstOrDefault(_ => _.DateTime.ToLocalTime() <= t.AddMinutes(30));

            //if (ds == null)
            //{
            //   ds = dp.Hourly.Data.OrderByDescending(_ => _.DateTime).First();
            //}
            return(ds);
        }
        EnergyFuture _getEnergyFuture(VariablePricesAndRenewable amberVars, DataPoint dp, DateTime sunrise, DateTime sunset, bool isForecast, List <DateDouble> history)
        {
            var obj = new EnergyFuture()
            {
                AmberSource        = amberVars.periodType,
                AmberPrices        = amberVars,
                Cloudiness         = dp?.CloudCover ?? 1,
                Temperature        = dp?.Temperature ?? 0,
                DarkSkyDataPoint   = dp,
                PrecipIntensity    = dp?.PrecipIntensity ?? 0,
                PrecipProbability  = dp?.PrecipProbability ?? 0,
                Period             = amberVars.period,
                PriceIn            = amberVars.InPrice,
                PriceInNormalised  = amberVars.InPriceNormal,
                PriceOut           = amberVars.OutPrice,
                PriceOutNormalised = amberVars.OutPriceNormal,
                IsForecast         = isForecast,
            };

            var historyRange = history.Where(e => e.Interval.Hour == amberVars.period.ToUniversalTime().Hour&& e.Interval.Minute == amberVars.period.ToUniversalTime().Minute).Where(e => e.Value < 10).Select(e => e.Value).ToList();

            var aggregate = historyRange.Count > 0 ? historyRange.Average() : 0;

            //Debug.WriteLine(aggregate);

            obj.SolarHistory = aggregate;

            var solarNormalised = _normalise(aggregate, 0, 3);

            obj.Value = _normalise(solarNormalised - obj.Cloudiness - obj.PriceInNormalised, 0, 3);

            obj.SolarValue = solarNormalised - (obj.Cloudiness / 4);

            if (obj.SolarValue < 0)
            {
                obj.SolarValue = 0;
            }

            obj.GridValue = (1 - obj.PriceInNormalised);

            obj.UsageSuggestion = obj.GridValue + obj.SolarValue;
            obj.CostSuggestion  = 2 - obj.UsageSuggestion;

            return(obj);
        }
Ejemplo n.º 3
0
        public double _outPrice(AmberData data, VariablePricesAndRenewable variables)
        {
            var price = (data.data.staticPrices.B1.totalfixedKWHPrice + data.data.staticPrices.B1.lossFactor * variables.wholesaleKWHPrice) / 1.1;

            return(price);
        }