International Journal of Research and Innovation in Applied Science (IJRIAS)

Submission Deadline-26th September 2025
September Issue of 2025 : Publication Fee: 30$ USD Submit Now
Submission Deadline-03rd October 2025
Special Issue on Economics, Management, Sociology, Communication, Psychology: Publication Fee: 30$ USD Submit Now
Submission Deadline-19th September 2025
Special Issue on Education, Public Health: Publication Fee: 30$ USD Submit Now

Development of an Enhanced Bayesian Model Averaging Technique for Weather Forecasting

Development of an Enhanced Bayesian Model Averaging Technique for Weather Forecasting

Oluyinka E. Farombi1,2, Abigael B. Adetunji1,2,3, Funmilola A. Ajala1

Research Assistant, Professor, Professor Department of Computer Science, Faculty of Computing and Informatics, Ladoke Akintola University of Technology, Ogbomoso, Nigeria

1Advanced Software Research Laboratory Group (ASRLG), Ladoke Akintola University of Technology, Ogbomoso, Nigeria

DOI: https://doi.org/10.51584/IJRIAS.2025.100800141

Received: 11 August 2025; Accepted: 24 August 2025; Published: 23 September 2025

ABSTRACT

This study has been undertaken to investigate Weather Forecasting using an Enhanced Bayesian Model Averaging Technique. Seventy (70%) percent of data in Ibadan was retrieved from OpenWeatherMap Application Programming Interface (API) online data repository which was used for training and the remaining thirty percent (30%) was used for the testing process. The EBMA was developed by introducing the operators of Ant Colony Optimization Algorithm (ACO). The Max-Min Ant System (MMAS) technique was used for feature normalization. Evaluation of the developed EBMA technique was investigated by benchmarking its performance with BMA using Mean Square Error (MSE) and Mean Absolute Error (MAE). The developed EBMA has effectively reduced the problems of poor weather forecasting with associated high accuracy in weather forecasting.

Keywords: Enhanced BMA, Numerical Weather forecasting, Ant Colony Optimization

INTRODUCTION

Weather forecasts are generated by collecting quantitative data about the state of the atmosphere and using a scientific understanding of atmospheric process to extrapolate how the atmosphere will evolve. This can also be defined as a scientific estimate of the weather conditions at subsequent time, conveyed in terms of temperature, precipitation, wind etc. It is generally achieved through three major steps: i) observation and data collection, ii) assimilation, processing and analysis and iii) extrapolation to predict the future state of the atmosphere. The totality of observations, analysis, and model constitute a forecast system.

Weather forecasts have always played an important role to humankind in their everyday life activities. For example, forecasts help people determine what to wear or what activities to do on a given day; whether the weekend will permit an outing, rally, school bash, or an outdoor for a wedding reception and whether or not to put on a coat or carry an umbrella. People can also know and be aware of atmospheric changes through variables such as temperature, wind speed and direction, humidity, sunshine, cloudiness and precipitation. Variations in these parameters describe weather the state of the atmosphere at a particular time. However, different terminologies are used to describe weather in terms of sets of fundamental quantities and various characterizations proposed and employed in weather forecasting.

Need Of The Study

Impacts of global warming on the climate and weather conditions that occur at these days are unstable and fluctuate. This causes many environmental problems and social issues which directly impact livings. Therefore, forecasting techniques to predict weather with diverging outputs are necessary; such method which output is mapped into each coordinate of a region presenting detailed information on the status of the weather. Presently, accurate weather forecasting has been a major problem in Nigeria. Some methods have met many unresolved challenges which have become a major concern for the Meteorology Department in Nigeria. The task is complicated in the field of meteorology because all decisions are made within a visage of uncertainty associated with the weather system. Chaotic features associated with atmospheric phenomenal has also attracted the attention of modern scientist.

RESEARCH METHODOLOGY

The methodology section outlined the plan and method of how the study is conducted. This includes Data and sources of data, Data pre-processing, Data cleaning, Data selection.

Data and Sources of Data

In the data processing, 70% of the total Countries data in the world was used for training and the remaining 30% was used for the testing process. The dataset employed are weather data that are obtained from OpenWeatherMap Application Programming Interface (API) and API. The data collected are data that are passed as preprocessing data. The data collected are data that are passed as preprocessing data. Historical data and Classification data are required.  Historical data acquired are the weather data at some geographical points of the city’s districts Nigeria. The collection comes from a raw data list which was retrieved from the site of the OpenWeatherMap Application Programming Interface (API) server. The next data sources are sorted and stored in a database application. Preprocessing consists of two stages; namely Data cleaning and Data selection. Then subsequently these data are entered into the forecasting process consisting of several stages of training data normalization, determining activation function process, calculating on each weight difference, and calculating on net weight and output. The testing process are performed.

Theoretical Framework

Variables of the study contains dependent and independent variable. The study used pre-specified method for selection of variables.

Enhanced Bayesian Model Averaging is a method that is capable to predict the best model based on the weighted average of all models. Enhanced BMA evenly averages the posterior distribution of all the possibly formed models. The purpose of the Enhanced BMA is to combine uncertain models to get the best model. The estimation result includes all models that may have formed so they can get a better estimation (Montgomery and Nyhan, 2010). Since the data has undergone a series of pre-processing, the data are then stored as initial data used in the forecasting process. There is a chronology of the forecasting process using Enhanced Bayesian Model Averaging (EBMA).

Ant Colony Optimization (ACO) is based on the natural behavior of ant colonies and their individual worker ants. When ants forage, they naturally seem to find a “logical” and “effective” route between their nest and the food source; in other words, they seem to determine an optimum route. Ant Colony Optimization (ACO) employs artificial ants that corporate to find good solutions for discrete optimization problems. These software agents mimic the foraging behavior of their biological equal in finding the shortest path to the source of the food (David et al., 2007).

The Max-Min Ant system (MMAS) algorithm controls the maximum and minimum pheromone amounts on each trail. Only the global best tour or the iteration best tour are allowed to add pheromone to its trail. To avoid stagnation of the search algorithm, the range of possible pheromone amounts on each trail is limited to an interval [τmax,τmin]. All edges are initialized to τmax to force a higher exploration of solutions. The trails are reinitialized to τmax when nearing stagnation.

Statistical tools and Econometric Models

This section elaborates the proper statistical/econometric/models which are being used to forward the study from data towards inferences. The detail of methodology is given as follows.

Descriptive Statistics

Descriptive statistics has been used to find the maximum, minimum, standard deviation, mean and normally distribution of the data of all the variables of the study.

Linear Regression Model of Bayesian Model Averaging

The implementation of BMA, which was first proposed by (Leamer, 1978), for linear regression models is as follows. Consider a Linear Regression model with a constant term, β0, and k potential explanatory variables x1, x2, . . . ,xk,

y = β0 + β1 x1 + β2 x2 + · · · + βk xk + ε  (1)

Given the number of regressions, we will have 2k different combinations of right hand side variable indexed by 𝑀𝑗 for j = 1, 2, 3, . . . , 2k . Once the model space has been constructed, the posterior distribution for any coefficient of interest, say βh, given the data D is

Pr( 𝛽h|𝐷 ) = ∑ 𝑃𝑟 ( 𝛽h|𝑀𝑗 ) 𝑃𝑟 ( 𝑀𝑗|𝐷 ) j:𝛽h∈𝑀𝑗                                         (1.2)

BMA uses each model’s posterior probability, 𝑃𝑟 ( 𝑀𝑗|𝐷 ), as weights. The posterior model probability of Mj is the ratio of its marginal likelihood to the sum of marginal likelihoods over the entire model space and is given by

𝑃𝑟 ( 𝑀𝑗|𝐷 ) = 𝑃𝑟 ( 𝐷|𝑀𝑗 ) 𝑃𝑟 (𝑀𝑗) 𝑃𝑟 (𝐷)

𝑃𝑟 ( 𝐷|𝑀𝑗 ) 𝑃𝑟 (𝑀𝑗 ) ∑ 2𝑘 𝑖=1 𝑃𝑟 (     𝐷|𝑀𝑗 ) 𝑃𝑟 (𝑀𝑖)                                              (1.3)

Where: 𝑃𝑟 ( 𝐷|𝑀𝑗 ) = ⎰ 𝑃𝑟 ( 𝐷| 𝛽j, 𝑀𝑗 ) 𝑃𝑟 (𝛽j, 𝑀𝑗 ) 𝑑𝛽j

and βj is the vector of parameters from model Mj, Pr (βj, Mj) is a prior probability distribution assigned to the parameters of model Mj, and Pr (Mj) is the prior probability that Mj is the true model. The estimated posterior means and standard deviations of βˆ = (βˆ0, βˆ1, . . . , βˆk) are then constructed as:

E [ 𝛽ˆ|𝐷 ] = ∑ 2𝑘 𝑗=1 𝛽ˆ 𝑃𝑟 ( 𝑀𝑗|𝐷 ),

V[ 𝛽ˆ|𝐷 ] = ∑ 2𝑘 𝑗=1 (𝑉𝑎𝑟[𝛽|𝐷, 𝑀𝑗] + 𝛽ˆ 2 ) 𝑃𝑟 ( 𝑀𝑗|𝐷 ) – E [ 𝛽ˆ|𝐷 ] 2                   (1.4)

Performance Evaluation

The system was assessed based on its overall accuracy and other characteristics of the system using the performance metrics stated below:

Mean Square Error (MSE)

This is defined as Mean or Average of the square of the difference between actual and estimated values of dataset. The error value was known at Minimum temperature which was rated and Maximum temperature was also rated. Meanwhile, the error value of Minimum humidity was rated and the error value of Maximum humidity was rated. After all, the forecasting error rate of wind speed was also rated.

Equ 3.1      (3.1)

n = number of data points

Yi = Observed values

Y ^ i = Predicted value

Mean Absolute Error (MAE)

This is calculated by taking the mean of the absolute Differences between the actual values (also called y) and the predicted values.

Equ 3.2          (3.2)

n = total number of data points

yi = Prediction

y ^ = True value

RESULTS AND DISCUSSION

The new system was improved by adding the Max-min Ant System (MMAS) feature which has a default value of ‘MSE’ i.e. Mean Square Error which is the function to measure the quality of a split and changing it to ‘MAE’ which stands for Mean Absolute Error, adding and setting the bootstrap value which has a default value of True to False. The activation function for the weather forecasting process is the bipolar threshold activation function. The modification of the threshold function has three output values, Rangeley -1, 0, or 1. Calculating the value of each node activation function is by setting with a random value that outputs the value of -1, 0, or 1.

In the prediction process, 70% of the data was used for training and the remaining 30% was used for the testing process. The respective dataset was imported into Visual Studio Code (VS-code) environment using JavaScript Object Notation (JSON) library. The dataset was analyzed and pre-processed using JavaScript Object Notation (JSON) library, visualized using Matplotlib and Numpy packages libraries and subsequent prediction result was gotten. This result gives an insight into the prediction carried out and the metrics for performance evaluation. The weather data retrieved from the OpenWeatherMap server which has been stored in the database earlier. Forecasting the weather data begins by opening the Weather forecasting application on the browser page. Then on the same page, system requires users to input the city location to forecast the weather.

Table 4.1. Weather Forecasting Results for Existing system

Table 4.1. Weather Forecasting Results for Existing system

Table 4.2. Weather Forecasting Results for Enhanced system

Table 4.2. Weather Forecasting Results for Enhanced system

Performance Evaluation Results

Forecasting error for Existing system is calculated by Mean Square Error (MSE) diverging at 0.85% of Minimum Temperature parameter, 0.198% of Maximum Temperature parameter, 0.073% of Normal Temperature parameter, 0.178% of Humidity parameter, 0.244% of Wind Speed parameter, 0.277% of Precipitation parameter and 0.189% of Heat Index parameters respectively. Forecasting error for Enhanced system is calculated by Mean Square Error (MSE) diverging at 0.75% of Minimum Temperature parameter, 0.196% of Maximum Temperature parameter, 0.070% of Normal Temperature parameter, 0.168% of Humidity parameter, 0.144% of Wind Speed parameter, 0.257% of Precipitation parameter and 0.179% of Heat Index parameters respectively. Mean Square Error (MSE) is a method for measuring Forecasting Error. In this method, each error or residual is squared, then summed or divided by the number of observations. Table 3.2 shows the Mean Square Error (MSE) calculations and Averaged Absolute Forecast Error against its actual data. Error calculation results using the Mean Square Error (MSE) are provided.

Forecasting error for Existing system is calculated by Mean Absolute Error (MAE) diverging at 0.322% of Minimum Temperature parameter, 0.261% of Maximum Temperature parameter, 0.0867% of Normal Temperature parameter, 0.143% of Humidity parameter, 0.37% of Wind Speed parameter, 0.27% of Precipitation parameter and 1.0333% of Heat Index parameter respectively. Forecasting error for Enhanced system is calculated by Mean Absolute Error (MAE) diverging at 0.21% of Minimum Temperature parameter, 0.141% of Maximum Temperature parameter, 0.002% of Normal Temperature parameter, 0.011% of Humidity parameter, 0.25% of Wind Speed parameter, 0.18% of Precipitation parameter and 0.021% of Heat Index parameter respectively. Mean Absolute Error (MAE) is a method for measuring Forecasting Error. In this method, each error or residual is squared, then summed or divided by the number of observations.

Forecasting error for Existing system is calculated by Mean Square Error (MSE) diverging at 0.85% of Minimum Temperature parameter, 0.198% of Maximum Temperature parameter, 0.073% of Normal Temperature parameter, 0.178% of Humidity parameter, 0.244% of Wind Speed parameter, 0.277% of Precipitation parameter and 0.189% of Heat Index parameters respectively. Forecasting error for Enhanced system is calculated by Mean Square Error (MSE) diverging at 0.75% of Minimum Temperature parameter, 0.196% of Maximum Temperature parameter, 0.070% of Normal Temperature parameter, 0.168% of Humidity parameter, 0.144% of Wind Speed parameter, 0.257% of Precipitation parameter and 0.179% of Heat Index parameters respectively. Mean Square Error (MSE) is a method for measuring Forecasting Error. In this method, each error or residual is squared, then summed or divided by the number of observations. Table 3.2 shows the Mean Square Error (MSE) calculations and Averaged Absolute Forecast Error against its actual data. Error calculation results using the Mean Square Error (MSE) are provided.

Forecasting error for Existing system is calculated by Mean Absolute Error (MAE) diverging at 0.322% of Minimum Temperature parameter, 0.261% of Maximum Temperature parameter, 0.0867% of Normal Temperature parameter, 0.143% of Humidity parameter, 0.37% of Wind Speed parameter, 0.27% of Precipitation parameter and 1.0333% of Heat Index parameter respectively. Forecasting error for Enhanced system is calculated by Mean Absolute Error (MAE) diverging at 0.21% of Minimum Temperature parameter, 0.141% of Maximum Temperature parameter, 0.002% of Normal Temperature parameter, 0.011% of Humidity parameter, 0.25% of Wind Speed parameter, 0.18% of Precipitation parameter and 0.021% of Heat Index parameter respectively. Mean Absolute Error (MAE) is a method for measuring Forecasting Error. In this method, each error or residual is squared, then summed or divided by the number of observations.

Figure 4.1: Real time-forecasting for Maximum Temperature

Figure 4.1: Real time-forecasting for Maximum Temperature

Figure 4.2: Real time-forecasting for Minimum Humidity

Figure 4.2: Real time-forecasting for Minimum Humidity

 Figure 4.3: Real time-forecasting for Maximum Humidity

 Figure 4.3: Real time-forecasting for Maximum Humidity

Figure 4.1 shows the real time-forecasting chart parameters of Minimum temperature which is 24 degrees Celsius. From the chart, three days (Day 1, Day 2 and Day 3) weather forecasting was implemented with the respective days. Figure 4.2 shows the real time-forecasting chart parameters of Maximum temperature which is 32 degrees Celsius. From the chart, three days (Day 1, Day 2 and Day 3) weather forecasting was implemented with respective days. Figure 4.2 shows the real time-forecasting chart parameters of Minimum humidity which is 50g/kg. From the chart, three days (Day 1, Day 2 and Day 3) weather forecasting was implemented using the respective days. Figure 4.3 shows real time-forecasting chart parameters of Maximum humidity which is 92g/kg. From the chart, three days (Day 1, Day 2 and Day 3) weather forecasting was implemented using the respective days. Figure 4.4 shows Actual-forecasting chart of wind speed which is 23 km/h. From the chart, three days (Day 1, Day 2 and Day 3) weather forecasting was implemented using the respective days.

Figure 4.4: Actual-forecasting chart of wind speed

Figure 4.4: Actual-forecasting chart of wind speed

CONCLUSION

According to Weather Forecasting system using an Enhanced Bayesian Model Averaging, forecasting error values generated by the Existing system yielded Mean Square Error diverging at 0.85% of Minimum Temperature parameter, 0.198% of Maximum Temperature parameter, 0.073% of Normal Temperature parameter, 0.178% of Humidity parameter, 0.244% of Wind Speed parameter, 0.277% of Precipitation parameter and 0.189% of Heat Index parameters respectively.  The result of the Enhanced Weather Forecasting System yielded Mean Square Error (MSE) diverging at 0.75% of Minimum Temperature parameter, 0.196% of Maximum Temperature parameter, 0.070% of Normal Temperature parameter, 0.168% of Humidity parameter, 0.144% of Wind Speed parameter, 0.257% of Precipitation parameter and 0.179% of Heat Index parameters respectively. The Existing system has higher error value of Mean Square Error (MSE) and Mean Absolute Error (MAE). However, the Enhanced system has lower error value for Mean Square Error (MSE) and Mean Absolute Error (MAE). The lower the value of MSE and MAE shows the more optimal in forecasting accuracy. Therefore, the Enhanced system performed better than the Existing system in all the performance evaluation metrics used.

In the future study, we would like to do forecasting using our classification engine such as Distributed Adaptive Neural Network and improved by using fast learning algorithm.

REFERENCES

  1. Aaron, O.S., Sitompul and Rahmat, R.F., (2014). Implementation of Bayesian model averaging on the weather data forecasting applications utilizing open weather map. Conference on Engineering, Science and Technology 2017 (TALENTA-CEST 2017) 7–8 September 2017, Volume 309 Sumatera Utara, Indonesia
  2. Abhishek, K., Singh, M.P., Ghosh, S., Anand, A., (2012). Weather forecasting model using Artificial Neural Network. Second International Conference on Computer, Comm. Control and Information Tech (C3IT-2012) on February 25-26, 2012 vol 23
  3. Abrajano, G., Ahiduzzaman, M. D., Ching, R., Krismianto, and Zhang, L., (2009). Weather/Climate Prediction. IEEE Instrumentation and Measurement Tech Conference 2009
  4. Adetunji A. B., Akande O, Ajala F. A, Oyewo O, Ayoola J, Akande Y. F., (2020). House Price Prediction using Random Forest Machine Learning Technique, Information Technology and Quantitative Management (ITQM 2020&2021), Procedia Computer Science 00 (2018) 000–000
  5. Allen and Vermon, (2015). An Intellectual History of the Common Heritage of Mankind as Applied to the Oceans. Open Access Master’s Theses. Paper 1088.
  6. Alwajeeh, T., Alharthi, A. F., Rahmat, R.F., and Budiarto, R., (2017). Wind Speed Ensemble Forecasting Based on Deep Learning Using Adaptive Dynamic Optimization Algorithm. IOP Conference Series Material Science Engineering 190 120.
  7. Belousov, S. L, Berkovoich, L. V (2006). Mathematical Modeling in Meteorology and Weather Forecasting. Mathematical models of life support systems – I
  8. Binachi, A. C., Carlos, H. C., and Anna, (2009). Relation between Ant Colony and Heuristically Accelerated Reinforcement Learning. Taylor & Francis Group, London, ISBN 978-0-415-62123-6 2012
  9. Conti, D. V., Cortessis, V., Molitor, J., and Thomas, D. C. (2003). Bayesian modeling of Complex metabolic pathways, Human heredity 56(1-3): 83–93.
  10. Diehl, A., Bruckner, S., Grolle, M. E., (2013). Visual Trend Analysis in Weather Forecast Wiley On line Library. Computer Graphics Forum Volume36, Issue7
  11. David, M., Manu B., and Raf., (2007). “Classification with Ant Colony Optimization”,IEEE Transactions on Evolutionary Computation,11, NO.5.
  12. Edwin, (2008). Multivariable Adaptive Neuro-Fuzzy Inference System (ANFIS) in predicting Daily Rainfall using several surface weather parameters. Published online by Cambridge University Press: 30 September 2009
  13. Lynch, (2010). Early Numerical Weather Prediction Journal of Computational PhysicsVolume 227, Issue 7, 20 March 2008, Pages 3431-3444 (NWP) 4:4-17.
  14. Lorenz, (2014). Day Wise Rainfall Prediction System Using Weather Application Programming Interface. International Journal of Advanced Research in Computer Science and Software Engineering, Volume 4.
  15. Montgomery, J., and Nyhan, (2010). Bayesian Model Averaging: Theoretical developments and Practical applications, Political Analysis 18(2): 245-270.
  16. Plummer, M., (2003). Jags: A program for analysis of Bayesian Graphical Models using Gibbs Sampling, Proceedings of the 3rd international workshop on distributed statistical Computing, 124, Technische Universit at Wien, p. 125.
  17. Rahmat, R. F., Rizki, A., Alharthi, A. F., and Budiarto. R., (2016). The 4th Saudi Int. Conf. on Information Technology (Big Data Analysis) 1–5.
  18. Rahmat, R., Syahputra, M. F., and Lydia, M. S., (2016). Adaptive neuro-fuzzy inference system for forecasting rubber milk production, The International Conference on Informatics and Computing 383–38.
  19. Tektas, M., (2012). “Weather API approach for weather prediction using back propagation.” International Journal of Engineering Trends and Technology 3.1 (2012).
  20. Walter Maner, (2013). “Rainfall Spatial Analysis using GIS.” International Journal of Advanced Research in Computer and Communication Engineering Vol. 2.7

APPENDICES

  1. Html And Boostrap: Bottom of Form

<!DOCTYPE html>

<html lang=”en”>

<head>

<meta charset=”utf-8″ />

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″ />

<title>Weather in App</title>

<link rel=”stylesheet” href=”https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-

beta1/dist/css/bootstrap.min.css” integrity=”sha384-

giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1″

crossorigin=”anonymous” />

<link rel=”stylesheet” href=”style.css” />

</head>

<body>

<div class=”container my-5″>

<h1 class=”text-center title”>Weather in</h1>

<form class=”search-location”>

<input type=”text” name=”city” placeholder=”what city?” autocomplete=”off” class=”formcontrol text-muted form-rounded p-4 shadow-sm” />

</form>

<div class=”card rounded my-3 shadow-lg back-card”>

<div class=”card-top text-center”>

<div class=”city-name my-3″>

<p class=”text-white text-black”>Abuja</p>

<span class=”text-white text-black”>…</span>

</div>

<img src=”img/night_image 3.jpg” alt=”” class=”card-img-top time” />

</div>

<div class=”card-body”>

<div class=”card-mid row”>

<div class=”col-8 text-center temp”>

<span>30&deg;C</span>

</div>

<div class=”col-4 condition-temp”>

<p class=”condition”>Thunder Storm</p>

<p class=”high”>30&deg;C</p>

<p class=”low”>27&deg;C</p>

</div>

<div class=”icon-container card shadow mx-auto”>

<img src=”img/Cloud 3.png” alt=”” />

</div>

<div class=”card-bottom px-5 py-4 row”>

<div class=”col text-center”>

<p>30&deg;C</p>

<span>Feels like</span>

</div>

<div class=”col text-center”>

<p>55%</p>

<span>Humidity</span>

</div>

</div>

</div>

</div>

</div>

<script src=”request.js”></script>

<script src=”index.js”></script>

</body>

</html>

</div>

2. Cascaded Styling Sheet (Css)

@import url(‘https://fonts.googleapis.com/css2?family=Raleway:wght@100;400;700&display=swap’);

body {

font-family: ‘Raleway’, sans-serif;

background: #e0e0e0;

color: #707070;

margin: 0;

padding: 0;

}

.container {

max-width: 400px;

min-width: 400px;

}

.title {

font-weight: 700;

font-size: 50px;

}

.form-rounded {

border-radius: 2em;

}

.back-card {

border-radius: 40px !important;

}

.city-name {

position: absolute;

width: 100%;

}

.city-name p {

font-size: 16pt;

font-weight: 400;

}

.city-name span {

font-weight: 400;

font-size: 36pt;

font-family: ‘Times New Roman’, serif;

position: relative;

top: -60px;

}

.temp span {

font-weight: 100;

font-size: 5em;

letter-spacing: -5px;

white-space: nowrap;

}

.card-mid {

line-height: 0.5;

}

3. Javascript

const searchForm = document.querySelector(‘.search-location’);

const cityValue = document.querySelector(‘.search-location input’);

80

const cityName = document.querySelector(‘.city-name p’);

const cardBody = document.querySelector(‘.card-body’);

const timeImage = document.querySelector(‘.card-top img’);

const cardInfo = document.querySelector(‘.back-card’);

const spitOutCelcius = (kelvin) => {

celcius = Math.round(kelvin – 273.15);

return celcius;

}

const isDayTime = (icon) => {

if (icon.include(‘day’)) {

return true;

} else {

return false;

}

}

updateWeatherApp = (city) => {

console.log(city);

const imageName = city.weather[0].icon;

const iconSrc = `http://openweathermap.org/img/wn/${imageName}@2x.png`

cityName.textContent = city.name;

cardBody.innerHTML = `

<div class=”card-mid row”>

<div class=”col-8 text-center temp”>

<span>${spitOutCelcius(city.main.temp)}&deg;C</span>

</div>

<div class=”col-4 condition-temp”>

<p class=”condition”>${city.weather[0].description}</p>

<p class=”high”>${spitOutCelcius(city.main.temp_max)}&deg;C</p>

81

<p class=”low”>${spitOutCelcius(city.main.temp_min)}&deg;C</p>

</div>

</div>

<div class=”icon-container card shadow mx-auto”>

<img src=”${iconSrc}” alt=”” />

</div>

<div class=”card-bottom px-5 py-4 row”>

<div class=”col text-center”>

<p>${spitOut Celcius(city.main.feels_like)}& deg;C</p>

<span>Feels like</span>

  1. Request. Js

const key = ‘918609eb25f4c18a84b3811104429460’;

// const base URL =

‘http://api.openweathermap.org/data/2.5/weather?q=Lagos&appid=918609eb25f4c18a84b381110442

9460′

// fetch(base URL)

//.then ((data) => {console.log (‘response’, data. json ())})

//.catch ((error) => {

// console.log(error);

// });

const request City = async(city) => {

const base URL = ‘http://api.openweathermap.org/data/2.5/weather’

const query = `?q=${city}& appid=${key}`;

//Make fetch call (promise call)

const response = await fetch (base URL + query);

//Promise data

const data = await response. json();

return data

Article Statistics

Track views and downloads to measure the impact and reach of your article.

0

PDF Downloads

[views]

Metrics

PlumX

Altmetrics

Paper Submission Deadline

Track Your Paper

Enter the following details to get the information about your paper

GET OUR MONTHLY NEWSLETTER