Exemple #1
0
        /// <summary>
        /// Main method to calculate predictions
        /// Created to be called via webapi
        /// </summary>
        /// <param name="db">Repository to use; if null we will use default repo</param>
        /// <param name="dateOfForecast">Date of forecast to create; if null we use use current date</param>
        public static void MakePredictions(IForecastRepository db, string dateOfForecast)
        {
            IForecastRepository theDb;

            if (db == null)
            {
                theDb = new AzureTableForecastRepository();
            }
            else
            {
                theDb = db;
            }

            string localFileName = Path.GetTempFileName();
            //CloudBlobContainer container = AzureUtilities.FeaturesBlobContainer;
            string cloudFileName = "V1Features" + dateOfForecast + ".csv";
            var    adlsClient    = AzureUtilities.AdlsClient;

            adlsClient.FileSystem.DownloadFile(
                WebConfigurationManager.AppSettings["ADLSAccountName"],
                "/inputfeatures-csv-westus-v1/" + cloudFileName,
                localFileName, overwrite: true);


            var values  = PredictionUtilities.CreatePredictionFormat(localFileName);
            var latLons = values.Item1;

            ExecutePredictionAndStore(theDb, dateOfForecast, values, latLons, Constants.ModelDangerAboveTreelineV1);
            ExecutePredictionAndStore(theDb, dateOfForecast, values, latLons, Constants.ModelDangerBelowTreelineV1);
            ExecutePredictionAndStore(theDb, dateOfForecast, values, latLons, Constants.ModelDangerNearTreelineV1);
        }
Exemple #2
0
        private static void ExecutePredictionAndStore(IForecastRepository db, string date, Tuple <float[][], float[][]> values, float[][] latLons, String ModelName)
        {
            DateTime dateToAdd   = DateTime.ParseExact(date, "yyyyMMdd", null);
            var      predictions = PredictionUtilities.PredictDangerV1(values.Item2, ModelName);

            if (latLons.Length != predictions.Count())
            {
                throw new Exception("Predictions don't have the same lenth as LatLon");
            }
            var mappedPredictions = new List <ForecastPoint>();
            var mappedPredictionsOnlyNorthWest = new List <ForecastPoint>();

            for (int i = 0; i < latLons.Length; i++)
            {
                mappedPredictions.Add(new ForecastPoint(dateToAdd, ModelName, latLons[i][0], latLons[i][1], predictions[i]));
                if (latLons[i][0] > 42.0 && latLons[i][1] < -118.0)
                {
                    mappedPredictionsOnlyNorthWest.Add(new ForecastPoint(dateToAdd, ModelName + "NW", latLons[i][0], latLons[i][1], predictions[i]));
                }
            }

            //upload the predictions to table storage
            var forecast   = new Forecast(mappedPredictions);
            var forecastNw = new Forecast(mappedPredictionsOnlyNorthWest);

            db.SaveForecast(forecast);
            db.SaveForecast(forecastNw);
            db.SaveForecastDate(new ForecastDate(dateToAdd));
        }
Exemple #3
0
 public AirQualityRecorder(
     ILog log,
     IAirQualityServiceClient airQualityServiceClient,
     IForecastRepository forecastRepository)
 {
     this.log = log;
     this.airQualityServiceClient = airQualityServiceClient;
     this.forecastRepository      = forecastRepository;
 }
Exemple #4
0
 public HomeController(ILogger <HomeController> logger, IActionContextAccessor accessor, IForecastRepository forecastAppRepo, IConfiguration config, IHttpContextAccessor httpContextAccessor, LeadHornetDbContext leadHornetDbContext)
 {
     _logger              = logger;
     _accessor            = accessor;
     _forecastRepository  = forecastAppRepo;
     _config              = config;
     _httpContextAccessor = httpContextAccessor;
     _leadHornetDbContext = leadHornetDbContext;
 }
Exemple #5
0
        /// <summary>
        /// Init new instance
        /// </summary>
        /// <param name="client">Http client</param>
        /// <param name="config">Configuration</param>
        /// <exception cref="ArgumentNullException">Throws exception if config is null</exception>
        public OpenWeatherDatabase(HttpClient client, IOpenWeatherConfig config)
        {
            if (config is null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Weather  = new WeatherRepository(new WeatherClient(client, config.ApiKey));
            Forecast = new ForecastRepository(new ForecastClient(client, config.ApiKey));
        }
 public WeatherForecastAggregateService(
     IForecastRepository forecastRepository,
     IObservationRepository observationRepository,
     IForecastsServiceRepository forecastsServiceRepository,
     IObservationsServiceRepository observationsServiceRepository)
 {
     ForecastRepository            = forecastRepository;
     ObservationRepository         = observationRepository;
     ForecastsServiceRepository    = forecastsServiceRepository;
     ObservationsServiceRepository = observationsServiceRepository;
 }
 public ForecastService(IForecastRepository forecastRepository,
                        IValorForecastRepository valorForecastRepository,
                        IOptions <ConnectionStrings> connectionStrings,
                        ICalendarioService calendarioService,
                        IConfiguration configuration,
                        IUnitOfWork unitOfWork,
                        MicroServicosUrls microServicosUrls)
 {
     _forecastRepository      = forecastRepository;
     _valorForecastRepository = valorForecastRepository;
     _unitOfWork        = unitOfWork;
     _microServicosUrls = microServicosUrls;
     _connectionStrings = connectionStrings;
     _calendarioService = calendarioService;
     _configuration     = configuration;
 }
Exemple #8
0
 //TODO: migrate this to a dependency injection implementation
 public PredictController()
 {
     this.repository = new AzureTableForecastRepository();
 }
Exemple #9
0
 public OpenWeatherService(ForecastRepository repository, OpenWeatherWebService webservice)
 {
     _repository = repository;
     _webservice = webservice;
 }
 public ForecastStatisticsService(IForecastRepository forecastRepository
                                  , IDomainSettings domainSettings)
 {
     _forecastRepo   = forecastRepository;
     _domainSettings = domainSettings;
 }
 public GetAllRequestHandler(IForecastRepository repository, IMapper mapper)
 {
     _repository = repository;
     _mapper     = mapper;
 }
 public WeatherForecastController(ILogger <WeatherForecastController> logger, IForecastRepository forecastRepository)
 {
     _logger             = logger;
     _forecastRepository = forecastRepository;
 }
 public TestService(IForecastRepository forecasts)
 {
     _forecasts = forecasts;
 }
 public WeatherController([NotNull] IForecastRepository repository, [NotNull] IConfiguration configuration, ILogger <WeatherController> logger)
     : base(configuration, logger)
 {
     _repository = repository;
 }
Exemple #15
0
 //TODO: migrate this to a dependency injection implementation
 public WestUSv1Controller()
 {
     this.repository = new AzureTableForecastRepository();
 }
 public ForecastController(IForecastRepository forecastRepository)
 {
     _forecastRepository = forecastRepository;
 }
Exemple #17
0
 public WeatherService(IForecastRepository repo)
 {
     _repo = repo;
 }
Exemple #18
0
 public ForecastService(IForecastRepository forecastRepository)
     : base(forecastRepository, "ForecastPostSaveValidate", "ForecastSaveRelative", null, null, null, "GetForecastViewDetails")
 {
 }
Exemple #19
0
        private ITerm _enquiryRange; // 排班期扩展范围

        public StaffingCalculatorModel(IForecastRepository forecastRepository)
        {
            _forecastRepository = forecastRepository;
        }
Exemple #20
0
 public ForecastService(IForecastRepository repository, IGeoNamesWebService geoWebservice, IOpenWeatherMapWebService owmWebservice)
 {
     _repository    = repository;
     _owmWebservice = owmWebservice;
     _geoWebservice = geoWebservice;
 }
 public GismeteoParser(IOptions <GismeteoParserSettings> gismeteoParserSettings,
                       IForecastRepository forecastRepository)
 {
     _forecastRepository = forecastRepository;
     _parserSettings     = gismeteoParserSettings.Value;
 }
Exemple #22
0
 public ForecastService(IForecastClient client, IForecastRepository repository)
 {
     _client     = client;
     _repository = repository;
 }
Exemple #23
0
 public ForecastService(IForecastRepository forecastRepository)
 {
     _forecastRepository = forecastRepository;
 }
Exemple #24
0
 // Dependency Injection. lembrar de criar a private acima antes de injetar.
 public ForecastAppController(IForecastRepository forecastAppRepo)
 {
     _forecastRepository = forecastAppRepo;
 }
Exemple #25
0
 public FetchCurrentForecastService(IForecastRepository repository)
 {
     this._repository = repository;
 }
 //TODO: migrate this to a dependency injection implementation
 public NavigationController()
 {
     this.repository = new AzureTableForecastRepository();
 }
Exemple #27
0
 public ForecastService(IForecastRepository forecastRepository)
 {
     _forecastRepository = forecastRepository ?? throw new ArgumentNullException(nameof(forecastRepository));
 }
Exemple #28
0
 public Helper(IForecastRepository forecastRepository)
 {
     _forecastRepository = forecastRepository;
 }
        private ITerm _enquiryRange; // 排班期扩展范围

        public StaffingCalculatorModel(IForecastRepository forecastRepository)
        {
            _forecastRepository = forecastRepository;
        }
Exemple #30
0
 public ForecastService(IForecastRepository repository, IGeoNamesWebService geoWebservice, IOpenWeatherMapWebService owmWebservice )
 {
     _repository = repository;
     _owmWebservice = owmWebservice;
     _geoWebservice = geoWebservice;
 }