Meteorology - Current Weather And Forecast Observations

Meteorology - Current Weather And Forecast Observations

" Since its creation, the human being adapts its life to weather conditions or 'weather troubles'.

Probably since then there is a desire that weather events are brought under control or prediction.

I guess that from such desire in the course of development of our civilization, emerged the idea

of creation the science known today under the name of Meteorology and later development of different

technologies for study, prediction and possibly control of the weather events. Regardless of the achieved level

of the development of all scientific disciplines and technologies used for the study of meteorological events,

there has not yet been made a one hundred percent accurate weather forecast or the announcement of meteorological events.

In accordance with that, every form of announcements of meteorological events should be accepted with reserve. "

Author Željko Perić

If you are interested in a scientific discipline called Meteorology, and all that it involves, refer to the articles at the following addresses

Wikipedia the free enciklopedia ( https://en.wikipedia.org/wiki/Meteorology )

Republic Hydrometeorological Service of Serbia ( http://www.hidmet.gov.rs/eng/meteorologija )

World Meteorological Organisation ( http://public.wmo.int/en )

Program 'Current Weather&Forecast Observations'

Program is designed to download and display specific meteorological data from a remote server. It is a brief description of current weather conditions and measured temperatures for selected location that is determined by its longitude and latitude, as well as data about the weather forecast for the next few days, a brief description of anticipated weather conditions and the predicted minimum and maximum daily temperatures.

Data are stored on a remote Internet server, which is accessible trough hyper text transfer protocol (HTTP). Using this protocol, connection to the server is estabilished and the request is placed for the specific data. Adequate applications on the server, processes the request and returns the desired information within a document, which is in standard, generally accepted, format (CSV, XML, JSON). The obtained data are processed and displayed in a format that is understandable to the user.

How to create this kind of program ?

First, it is necessary to choose a company on the Internet that allows us to access the server, with the relevant meteorological data. Among many, here are presented only four, which differ according to prescribed conditions of access to data, as well as the quality of the data. The quality of the data means the quantity of various meteorological data, the frequency of updating and access to data, the coverage of the territory of our planet with network of automatic measuring stations for data collection. All four companies allow free access to data, with limited number of inquiries on a daily basis and use of the server application for the formation of HTTP requests for specific data. For some of them it is compulsory to open an account and to obtain personal user key codes to access the data. HTTP request consists of two parts, the address of the server and a set of parameters that represent the requirements to the server application for specific data. Server address is self-evident. A set of parameters that the server application can process, recognize, is different from application to application, and it is necessary to study the user manual at the given addresses. The popular term for the HTTP request is 'server endpoint' or 'endpoint'. Some server applications allows formation of HTTP queries by simply filling out a questionnaire, by checking the data that we want to download (current observations, forecasts for a number of days, etc.) example is World Weather Online application, while for others it is necessary to know the syntax of the application language, which is mostly very similar to SQL, such as for the YAHOO! Weather application. The frequency of updating data from automated weather stations and establishing new reports, weather forecasts, varies from server to server and it is average every two to four hours. This is the case where the data you want to download are free of charge. If you want a higher quality of service, you will have to pay for it. Look at the price of services at the following websites. The accuracy of meteorological data for the desired location on the planet, depends on the proximity of automatic weather stations to that coordinates for which we want information. In particular, in the example below, for the location of the city of Smederevo, the data are coming from Surcin airport, which is nearly fifty kilometers north-west, and it can be said that information is completely incorrect, especially when it comes to the current temperature, wind direction and velocity, etc. Author of this article was interested in the average percentual accuracy of announcements of certain weather events for a shorter period of time. It is the announcement of the temperature range and a short description of weather events for the next four days. The results of monitoring weather forecasts can be seen in the accompanying charts, noting that the period of accuracy control of upcoming weather events is only one month. The precision is very high, in the view that the monitored four days weather forecast was for the town of Smederevo in the Republic of Serbia in Europe, and that some companies that have created a weather forecast are stationed on another continent.

YAHOO! Weather

( notice : this service has changed its user polices and do not works since Thursday, Jan. 3, 2019 , more info at https://developer.yahoo.com/weather/ )

- Free access to the meteorological data with a daily limit of 2,000 queries per day- Access key is not necessary

- Link to the server application for the formation of HTML requests for specific data

( https://developer.yahoo.com/weather )

Example of HTTP query for the current weather data for the city of Smederevo in the metric system, in JSON format

- Server adress http://query.yahooapis.com/

- Parameters v1/public/yql?q=select%20item.yweather:condition%20from%20weather.forecast

%20where%20woeid%20in%20%28select%20woeid%20from%20geo.places%281%29%20where%20text%3D%22Smederevo%2C%20RS%22%29%20and%20u%20%3D%22c%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

Try HTTP query

Weather Underground

( notice : this service has started changing its user polices trough year 2019 , more info at End of Service for the Weather Underground API )

- Free access to the meteorological data with a daily limit of 500 queries per day- Access key is necessary for data access

- Link for opening account and obtaining user passwords or key

( https://www.wunderground.com/weather/api )

- Link to the server application for the formation of HTML requests for specific data

( http://www.wunderground.com/weather/api/d/docs?d=data/index )

Example of HTTP query for the current weather data and a ten-day weather forecast period

in Serbian language with meteorological station located closest to the coordinates

long = 44.662778 and lat = 20.93, which corresponds to the town of Smederevo, in JSON format

- Server adress http://api.wunderground.com/

- Parameters api/Acces_Key/conditions/forecast10day/lang:SR/q/44.662778,20.93.json

Try HTTP query

https://sites.google.com/site/periczeljkosmederevoenglish/Free-programs/Meteorology---Current-Weather-And-Forecast-Observations/Current%20Weather%26Forecast%20Observations%20program.zip?attredirects=0&d=1

World Weather Online

- Important Notice : WWO has dissmised its own free weather API service since 2017.- 60 days TRIAL free access to the meteorological data with a daily limit of 500 queries per day

- Access key is necessary for data access

- Link for opening account and obtaining user passwords or key

( http://developer.worldweatheronline.com/api/docs/ )

- Link to the server application for the formation of HTML requests for specific data

( http://developer.worldweatheronline.com/premium-api-explorer.aspx )

Example of HTTP query for the current weather data and the five-day weather forecasts

in Serbian language for the city of Smederevo, in JSON format

- Server adress http://api.worldweatheronline.com/

- Parameters premium/v1/weather.ashx?q=Smederevo&format=json&num_of_days=5&fx=yes&

cc=yes&mca=no&fx24=yes&includelocation=yes&show_comments=yes&

tp=24&showlocaltime=yes&lang=sr&key=Access_Key

Try HTTP query

https://sites.google.com/site/periczeljkosmederevoenglish/Free-programs/Meteorology---Current-Weather-And-Forecast-Observations/Current%20Weather%26Forecast%20Observations%20program.zip?attredirects=0&d=1

AERIS Weather (former HAM Weather )

- 60 days TRIAL free access to the meteorological data- Access key is necessary for data access and it consists of two parts

- Link for opening account and obtaining user passwords or key

( http://www.aerisweather.com/signup/ )

- Link to the server application for the formation of HTML requests for specific data

( http://www.aerisweather.com/support/docs/api/reference/endpoints/forecasts/ )

Example of HTTP query for the current weather data from the weather station located closest to the coordinates long = 44.662778, lat = 20.93, which corresponds to the town of Smederevo, in JSONformat, with time of last data reading, the current temperature, a brief description of the weather, thethumbnail of picture that represents graphical description of weather conditions

- Server adress http://api.aerisapi.com/

- Parameters observations/closest?p=44.66,20.93&fields=ob.dateTimeISO, ob.tempC,ob.weatherShort, ob.icon&client_id=Acsess_Key_1&client_secret=Access_Key_2

Try HTTP query

https://sites.google.com/site/periczeljkosmederevoenglish/Free-programs/Meteorology---Current-Weather-And-Forecast-Observations/Current%20Weather%26Forecast%20Observations%20program.zip?attredirects=0&d=1

The chart of the average percentual accuracy of the announcements of meteorological events for a period of four days

* Period of control of four-day weather forecast accuracy of the above companies was only one month.

When You have selected one of many companies, and formed HTTP request, 'endpoint', with a request for specific data, advance to writing program code.

Here is an example of program in the programming language C # 4.0, with the necessary .Net framework 4.0, and refers to the connection and download of the required weather data from YAHOO! Weather servers.

The basis for access to a remote server using HTTP queries make HttpWebRequest class for the formation of queries and

HttpWebResponse for connection and acceptance of response from the server, System.Net Namespace.

void Yahoo_Current_Weather()

{

string Yahoo_Server_Adress = "http://query.yahooapis.com/";

string YQL_Query = "v1/public/yql?q=select%20item.yweather:condition%20" +

"from%20weather.forecast%20where%20woeid%20in%20" +

"(select%20woeid%20from%20geo.places(1)%20where%20" +

"text%3D%22(44.66%2C20.93)%22)%20and%20u%20%3D%22c%22" +

"&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";

string Document = string.Empty;

// Forms HTTP request

HttpWebRequest query = (HttpWebRequest) WebRequest.Create(Yahoo_Server_Adress + YQL_Query);

// Connect to the server and make request for informations

// Declaration of a variable "response", type of HttpWebResponse

// must be derived from HttpWebRequest.GetResponse () instance

HttpWebResponse response = (HttpWebResponse) query.GetResponse();

// Create a variable "data", type of Stream and

// transfers the requested data from the

// instance of variable "response" type of Stream

Stream data = response.GetResponseStream();

// Create a variable "reader" to access data

StreamReader reader = new StreamReader(data,Encoding.UTF8);

// Read all the data and transfer them to the variable 'Document'

Document = reader.ReadToEnd();

// Save data to a text file

File.WriteAllText("YahooCurrentWeather.txt",Document,Encoding.UTF8);

// Closes and frees up all resources

// that occupies the variable 'reader'

reader.Close ();

reader.Dispose();

// Closes and frees up all resources

// that occupies the variable 'data'

data.Close ();

data.Dispose();

// Closes and frees up resources that occupies the variable 'response'

// Frees connection to the Internet for reuse

response.Close ();

}

When the method or subroutine 'void Yahoo_Current_Weather ()' executes, all the data that YAHOO! Weather server forwarded to your computer, were first placed in the variable 'Document' type of string, and then recorded in the file "YahooCurrentWeather.txt" in UTF8 Format which allows you to work with the Cyrillic alphabet.

If you do not want to, recording data is not necessary. This would also be a template for the connection and the realization of HTTP request to a remote server.

What has not been done is Try / Cach structure in order to prevent the violent interruption of program execution if the connection with server is interrupted or there is a redirection from the requested address to another server or application server can not process the request for information ...

Now you need to access the meteorological data that are formated like this, when JSON format of the document is in the question:

{

"query":

{

"count":1,

"created":"2014-11-22T19:33:24Z",

"lang":"en-US",

"results":

{

"channel":

{

"item":

{

"condition":

{

"code":"27",

"date":"Sat, 22 Nov 2014 7:00 pm CET",

"temp":"6",

"text":"Mostly Cloudy"

}

}

}

}

}

}

The figure shows the structure of the text within a text document with the names of variables and their values. This arrangement was made by an author to improve the readability. If the data was observed as how they are stored within the document, it would look like this, all the data in one line:

{"query":{"count":1,"created":"2014-11-22T21:20:51Z","lang":"en-US","results":{"channel":{"item":{"condition":{"code":"27","date":"Sat, 22 Nov 2014 7:00 pm CET","temp":"6","text":"Mostly Cloudy"}}}}}}

Date and time of creation of the document string created = "2014-11-22T19: 33: 24Z"

Code of the Image which represents the weather description string code = "27"

Date and time of last weather data update string date = "Sat, 22 Nov 2014 7:00 pm CET"

Current temperature string temp = "6"

A brief description of the weather conditions string text = "Mostly Cloudy"

Access to the values of variables can be done by deserialization data in the JSON document, which is done as shown on the following address

Microsoft MSDN ( http://msdn.microsoft.com/en-us/library/bb412179%28v=vs.110%29.aspx ),

or to get the necessary values by a simple search trough text of the document by keyword, name of the variable, and direct reading of the variable value, what was done in the program, by using the method ' Search_Result Find_Text(string Dokument, string Text, int Position) ', which returns a ' Search_Result ' class- type object with two instances, the variable value and location.

class Search_Result

{

public string value = string.Empty;

public int position = 0;

}

Search_Result Find_Text(string Dokument, string Text, int Position)

{

// Variable Document contains text from JSON document

// Variable Text contains search keyword

// If we need Image code value, the key word for search should be

//

// "code":"

//

// quotation marks included

// Variable Position contains letter position inside the text from which method starts search

Search_Result result = new Search_Result();

int document_length = 0;

int text_length = 0;

int letter_position = 0;

document_length = Dokument.Length;

text_length = Text.Length;

letter_position = Position;

while(letter_position<document_length-text_length)

{

if(Dokument.Substring(letter_position,text_length) == Text)

{

letter_position+=text_length;

break;

}

else

{

letter_position++;

}

}

while(Dokument[letter_position] != '"')

{

result.value += Dokument[letter_position];

letter_position++;

}

result.position = letter_position;

return result;

// Returns the value of the variable and the letter position inside the text

// where the value ends, due to the successive search

}

When you find and read the values of variables inside the JSON document, perform their presentation to the user via the user interface of the program.

Finally thoroughly review the ' Terms & Conditions ' of service, so that selected company do not prohibit the use of it to You, because for breaking it.

A program that can be downloaded by clicking on any image or the link below, requires .Net 4.0 framevork ( ^ ),

and high-quality Internet connection. Given that it is forbidden to use someone else's access key to get the access to the meteorological data,

you will need to obtain Your own key codes to use the program in full and unimpeded access to the data.

All the best,

Author.