/// <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); }
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)); }
public AirQualityRecorder( ILog log, IAirQualityServiceClient airQualityServiceClient, IForecastRepository forecastRepository) { this.log = log; this.airQualityServiceClient = airQualityServiceClient; this.forecastRepository = forecastRepository; }
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; }
/// <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; }
//TODO: migrate this to a dependency injection implementation public PredictController() { this.repository = new AzureTableForecastRepository(); }
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; }
//TODO: migrate this to a dependency injection implementation public WestUSv1Controller() { this.repository = new AzureTableForecastRepository(); }
public ForecastController(IForecastRepository forecastRepository) { _forecastRepository = forecastRepository; }
public WeatherService(IForecastRepository repo) { _repo = repo; }
public ForecastService(IForecastRepository forecastRepository) : base(forecastRepository, "ForecastPostSaveValidate", "ForecastSaveRelative", null, null, null, "GetForecastViewDetails") { }
private ITerm _enquiryRange; // 排班期扩展范围 public StaffingCalculatorModel(IForecastRepository forecastRepository) { _forecastRepository = forecastRepository; }
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; }
public ForecastService(IForecastClient client, IForecastRepository repository) { _client = client; _repository = repository; }
public ForecastService(IForecastRepository forecastRepository) { _forecastRepository = forecastRepository; }
// Dependency Injection. lembrar de criar a private acima antes de injetar. public ForecastAppController(IForecastRepository forecastAppRepo) { _forecastRepository = forecastAppRepo; }
public FetchCurrentForecastService(IForecastRepository repository) { this._repository = repository; }
//TODO: migrate this to a dependency injection implementation public NavigationController() { this.repository = new AzureTableForecastRepository(); }
public ForecastService(IForecastRepository forecastRepository) { _forecastRepository = forecastRepository ?? throw new ArgumentNullException(nameof(forecastRepository)); }
public Helper(IForecastRepository forecastRepository) { _forecastRepository = forecastRepository; }
private ITerm _enquiryRange; // 排班期扩展范围 public StaffingCalculatorModel(IForecastRepository forecastRepository) { _forecastRepository = forecastRepository; }
public ForecastService(IForecastRepository repository, IGeoNamesWebService geoWebservice, IOpenWeatherMapWebService owmWebservice ) { _repository = repository; _owmWebservice = owmWebservice; _geoWebservice = geoWebservice; }