pyVisualCrossing 1.0.0__tar.gz → 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/PKG-INFO +130 -10
- pyvisualcrossing-1.0.1/README.md +202 -0
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/pyVisualCrossing/__init__.py +1 -1
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/pyVisualCrossing/api.py +98 -50
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/pyVisualCrossing/data.py +168 -0
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/pyVisualCrossing.egg-info/PKG-INFO +130 -10
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/setup.py +1 -1
- pyvisualcrossing-1.0.0/README.md +0 -82
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/LICENSE +0 -0
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/pyVisualCrossing/const.py +0 -0
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/pyVisualCrossing.egg-info/SOURCES.txt +0 -0
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/pyVisualCrossing.egg-info/dependency_links.txt +0 -0
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/pyVisualCrossing.egg-info/top_level.txt +0 -0
- {pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyVisualCrossing
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Gets the weather data from Visual Crossing
|
|
5
5
|
Home-page: https://github.com/briis/pyVisualCrossing
|
|
6
6
|
Author: briis
|
|
@@ -32,7 +32,7 @@ In order to get started you must create an Account with Visual Crossing and then
|
|
|
32
32
|
|
|
33
33
|
Install the module by using this command in a terminal: `pip install pyVisualCrossing`
|
|
34
34
|
|
|
35
|
-
And then see `test_module.py`
|
|
35
|
+
And then see `test_module.py` for a usage example.
|
|
36
36
|
|
|
37
37
|
## Parameters
|
|
38
38
|
|
|
@@ -45,7 +45,7 @@ vcapi = VisualCrossing(
|
|
|
45
45
|
days=7,
|
|
46
46
|
language="da"
|
|
47
47
|
)
|
|
48
|
-
|
|
48
|
+
```
|
|
49
49
|
|
|
50
50
|
| Parameter | Required | Default | Description |
|
|
51
51
|
| --------- | -------- | ------- | ----------- |
|
|
@@ -54,11 +54,136 @@ vcapi = VisualCrossing(
|
|
|
54
54
|
| `longitude` | Yes | `None` | Longitude for the location position |
|
|
55
55
|
| `days` | No | `14` | Numbers of days to retrieve forecast for. 14 days means today plus the next 14 days. On the Free plan, this is the maximum number of days |
|
|
56
56
|
| `language` | No | `en` | The language in which text strings should be returned. Se below for list of valid languages. |
|
|
57
|
-
| `session` | No | `None` |
|
|
57
|
+
| `session` | No | `None` | An `aiohttp.ClientSession` to reuse for the async function. If not supplied, a session is created and closed automatically. |
|
|
58
58
|
|
|
59
|
+
For an in-depth description of the Visual Crossing API, go [here](https://www.visualcrossing.com/resources/documentation/weather-api/timeline-weather-api/)
|
|
59
60
|
|
|
61
|
+
## Fetching Data
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
Once initialised, call either the synchronous or the async method to retrieve data. Both return a single `ForecastData` object (or `None` if the request failed), holding the current conditions plus a daily and an hourly forecast list.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# Synchronous
|
|
67
|
+
data = vcapi.fetch_data()
|
|
68
|
+
|
|
69
|
+
# Async
|
|
70
|
+
data = await vcapi.async_fetch_data()
|
|
71
|
+
|
|
72
|
+
print(data.temperature)
|
|
73
|
+
for day in data.forecast_daily:
|
|
74
|
+
print(day.datetime, day.temperature, day.condition)
|
|
75
|
+
|
|
76
|
+
for hour in data.forecast_hourly:
|
|
77
|
+
print(hour.datetime, hour.temperature, hour.condition)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Exceptions
|
|
81
|
+
|
|
82
|
+
If the API request fails, one of these exceptions (all importable from `pyVisualCrossing`) is raised:
|
|
83
|
+
|
|
84
|
+
| Exception | Description |
|
|
85
|
+
| --------- | ----------- |
|
|
86
|
+
| `VisualCrossingBadRequest` | The request was invalid (invalid dates, bad location parameter, etc.) |
|
|
87
|
+
| `VisualCrossingUnauthorized` | The API key is incorrect, or the account is inactive or disabled |
|
|
88
|
+
| `VisualCrossingTooManyRequests` | Too many daily requests for the current plan |
|
|
89
|
+
| `VisualCrossingInternalServerError` | Visual Crossing's servers encountered an unexpected error |
|
|
90
|
+
| `VisualCrossingException` | Generic base exception for failing to access the API |
|
|
91
|
+
|
|
92
|
+
## Data
|
|
93
|
+
|
|
94
|
+
### Current Conditions (`ForecastData`)
|
|
95
|
+
|
|
96
|
+
| Property | Description |
|
|
97
|
+
| -------- | ----------- |
|
|
98
|
+
| `datetime` | Valid time (UTC) |
|
|
99
|
+
| `temperature` | Air temperature |
|
|
100
|
+
| `apparent_temperature` | Feels-like temperature |
|
|
101
|
+
| `dew_point` | Dew point |
|
|
102
|
+
| `condition` | Weather condition text |
|
|
103
|
+
| `icon` | Weather condition icon id |
|
|
104
|
+
| `cloud_cover` | Cloud coverage (%) |
|
|
105
|
+
| `humidity` | Humidity (%) |
|
|
106
|
+
| `precipitation` | Precipitation |
|
|
107
|
+
| `precipitation_probability` | Probability of precipitation (%) |
|
|
108
|
+
| `pressure` | Sea level pressure |
|
|
109
|
+
| `solarradiation` | Solar radiation (W/m2) |
|
|
110
|
+
| `visibility` | Visibility |
|
|
111
|
+
| `uv_index` | UV index |
|
|
112
|
+
| `wind_bearing` | Wind bearing (degrees) |
|
|
113
|
+
| `wind_speed` | Wind speed |
|
|
114
|
+
| `wind_gust_speed` | Wind gust speed |
|
|
115
|
+
| `location_name` | Name of the location |
|
|
116
|
+
| `description` | Weather description |
|
|
117
|
+
| `snow` | Snowfall |
|
|
118
|
+
| `snow_depth` | Snow depth |
|
|
119
|
+
| `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
|
|
120
|
+
| `solarenergy` | Solar energy (MJ/m2) |
|
|
121
|
+
| `sunrise` | Sunrise time |
|
|
122
|
+
| `sunset` | Sunset time |
|
|
123
|
+
| `moon_phase` | Moon phase, as a fraction between 0 and 1 |
|
|
124
|
+
| `update_time` | Timestamp of when the data was fetched |
|
|
125
|
+
| `forecast_daily` | List of `ForecastDailyData` |
|
|
126
|
+
| `forecast_hourly` | List of `ForecastHourlyData` |
|
|
127
|
+
|
|
128
|
+
### Daily Forecast (`ForecastDailyData`)
|
|
129
|
+
|
|
130
|
+
| Property | Description |
|
|
131
|
+
| -------- | ----------- |
|
|
132
|
+
| `datetime` | Valid date (UTC) |
|
|
133
|
+
| `temperature` | Max air temperature for the day |
|
|
134
|
+
| `temp_low` | Min air temperature for the day |
|
|
135
|
+
| `apparent_temperature` | Feels-like temperature |
|
|
136
|
+
| `condition` | Weather condition text |
|
|
137
|
+
| `icon` | Weather condition icon id |
|
|
138
|
+
| `cloud_cover` | Cloud coverage (%) |
|
|
139
|
+
| `dew_point` | Dew point |
|
|
140
|
+
| `humidity` | Humidity (%) |
|
|
141
|
+
| `precipitation` | Precipitation |
|
|
142
|
+
| `precipitation_probability` | Probability of precipitation (%) |
|
|
143
|
+
| `pressure` | Sea level pressure |
|
|
144
|
+
| `uv_index` | UV index |
|
|
145
|
+
| `wind_bearing` | Wind bearing (degrees) |
|
|
146
|
+
| `wind_speed` | Wind speed |
|
|
147
|
+
| `wind_gust` | Wind gust speed |
|
|
148
|
+
| `snow` | Snowfall |
|
|
149
|
+
| `snow_depth` | Snow depth |
|
|
150
|
+
| `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
|
|
151
|
+
| `precipitation_cover` | Percentage of the day with precipitation (%) |
|
|
152
|
+
| `solarradiation` | Solar radiation (W/m2) |
|
|
153
|
+
| `solarenergy` | Solar energy (MJ/m2) |
|
|
154
|
+
| `severe_risk` | Risk score of severe weather |
|
|
155
|
+
| `sunrise` | Sunrise time |
|
|
156
|
+
| `sunset` | Sunset time |
|
|
157
|
+
| `moon_phase` | Moon phase, as a fraction between 0 and 1 |
|
|
158
|
+
|
|
159
|
+
### Hourly Forecast (`ForecastHourlyData`)
|
|
160
|
+
|
|
161
|
+
Only hours later than the current time are included.
|
|
162
|
+
|
|
163
|
+
| Property | Description |
|
|
164
|
+
| -------- | ----------- |
|
|
165
|
+
| `datetime` | Valid date and time (UTC) |
|
|
166
|
+
| `temperature` | Air temperature |
|
|
167
|
+
| `apparent_temperature` | Feels-like temperature |
|
|
168
|
+
| `condition` | Weather condition text |
|
|
169
|
+
| `icon` | Weather condition icon id |
|
|
170
|
+
| `cloud_cover` | Cloud coverage (%) |
|
|
171
|
+
| `dew_point` | Dew point |
|
|
172
|
+
| `humidity` | Humidity (%) |
|
|
173
|
+
| `precipitation` | Precipitation |
|
|
174
|
+
| `precipitation_probability` | Probability of precipitation (%) |
|
|
175
|
+
| `pressure` | Sea level pressure |
|
|
176
|
+
| `uv_index` | UV index |
|
|
177
|
+
| `wind_bearing` | Wind bearing (degrees) |
|
|
178
|
+
| `wind_speed` | Wind speed |
|
|
179
|
+
| `wind_gust_speed` | Wind gust speed |
|
|
180
|
+
| `snow` | Snowfall |
|
|
181
|
+
| `snow_depth` | Snow depth |
|
|
182
|
+
| `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
|
|
183
|
+
| `solarradiation` | Solar radiation (W/m2) |
|
|
184
|
+
| `solarenergy` | Solar energy (MJ/m2) |
|
|
185
|
+
| `severe_risk` | Risk score of severe weather |
|
|
186
|
+
| `visibility` | Visibility |
|
|
62
187
|
|
|
63
188
|
## Languages
|
|
64
189
|
Available languages include: **ar** (Arabic), **bg** (Bulgiarian), **cs** (Czech), **da** (Danish), **de** (German), **el** (Greek Modern), **en** (English), **es** (Spanish), **fa** (Farsi), **fi** (Finnish), **fr** (French), **he** (Hebrew), **hu**, (Hungarian), **it** (Italian), **ja** (Japanese), **ko** (Korean), **nl** (Dutch), **pl** (Polish), **pt** (Portuguese), **sr** (Serbian), **sv** (Swedish), **tr** (Turkish), **uk** (Ukranian), **vi** (Vietnamese) and **zh** (Chinese).
|
|
@@ -99,8 +224,3 @@ We use the Iconset *icons2*, which gives a more detailed description of the cond
|
|
|
99
224
|
| partly-cloudy-night | Cloud cover is greater than 20% cover during night time. |
|
|
100
225
|
| clear-day | Cloud cover is less than 20% cover during day time |
|
|
101
226
|
| clear-night | Cloud cover is less than 20% cover during night time |
|
|
102
|
-
|
|
103
|
-
## TODO
|
|
104
|
-
|
|
105
|
-
- Add all available items to the Data Structure
|
|
106
|
-
- Create `async_test_module.py` in the samples directory
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Python Wrapper for Visual Crossing Weather API
|
|
2
|
+
|
|
3
|
+
This Python Wrapper retrives data from the [Visual Crossing](https://www.visualcrossing.com/) API. Visual Crossing has an extensive Weather API for both historical and forecast weather data, and they have a Free Tier API Key which enables up to 1000 calls per day.
|
|
4
|
+
|
|
5
|
+
In order to get started you must create an Account with Visual Crossing and then create an API Key. You do this by accessing [this website](https://www.visualcrossing.com/weather-data-editions) and clicking on the **Free** plan. Then follow the instructions to create and account and store your key in a safe place.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Install the module by using this command in a terminal: `pip install pyVisualCrossing`
|
|
10
|
+
|
|
11
|
+
And then see `test_module.py` for a usage example.
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
# Initialise the module
|
|
17
|
+
vcapi = VisualCrossing(
|
|
18
|
+
api_key,
|
|
19
|
+
latitude,
|
|
20
|
+
longitude,
|
|
21
|
+
days=7,
|
|
22
|
+
language="da"
|
|
23
|
+
)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Parameter | Required | Default | Description |
|
|
27
|
+
| --------- | -------- | ------- | ----------- |
|
|
28
|
+
| `api_key` | Yes | `None` | This is the API Key you signed up for from Visual Crossing. See above for instructions |
|
|
29
|
+
| `latitude` | Yes | `None` | Latitude for the location position |
|
|
30
|
+
| `longitude` | Yes | `None` | Longitude for the location position |
|
|
31
|
+
| `days` | No | `14` | Numbers of days to retrieve forecast for. 14 days means today plus the next 14 days. On the Free plan, this is the maximum number of days |
|
|
32
|
+
| `language` | No | `en` | The language in which text strings should be returned. Se below for list of valid languages. |
|
|
33
|
+
| `session` | No | `None` | An `aiohttp.ClientSession` to reuse for the async function. If not supplied, a session is created and closed automatically. |
|
|
34
|
+
|
|
35
|
+
For an in-depth description of the Visual Crossing API, go [here](https://www.visualcrossing.com/resources/documentation/weather-api/timeline-weather-api/)
|
|
36
|
+
|
|
37
|
+
## Fetching Data
|
|
38
|
+
|
|
39
|
+
Once initialised, call either the synchronous or the async method to retrieve data. Both return a single `ForecastData` object (or `None` if the request failed), holding the current conditions plus a daily and an hourly forecast list.
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
# Synchronous
|
|
43
|
+
data = vcapi.fetch_data()
|
|
44
|
+
|
|
45
|
+
# Async
|
|
46
|
+
data = await vcapi.async_fetch_data()
|
|
47
|
+
|
|
48
|
+
print(data.temperature)
|
|
49
|
+
for day in data.forecast_daily:
|
|
50
|
+
print(day.datetime, day.temperature, day.condition)
|
|
51
|
+
|
|
52
|
+
for hour in data.forecast_hourly:
|
|
53
|
+
print(hour.datetime, hour.temperature, hour.condition)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Exceptions
|
|
57
|
+
|
|
58
|
+
If the API request fails, one of these exceptions (all importable from `pyVisualCrossing`) is raised:
|
|
59
|
+
|
|
60
|
+
| Exception | Description |
|
|
61
|
+
| --------- | ----------- |
|
|
62
|
+
| `VisualCrossingBadRequest` | The request was invalid (invalid dates, bad location parameter, etc.) |
|
|
63
|
+
| `VisualCrossingUnauthorized` | The API key is incorrect, or the account is inactive or disabled |
|
|
64
|
+
| `VisualCrossingTooManyRequests` | Too many daily requests for the current plan |
|
|
65
|
+
| `VisualCrossingInternalServerError` | Visual Crossing's servers encountered an unexpected error |
|
|
66
|
+
| `VisualCrossingException` | Generic base exception for failing to access the API |
|
|
67
|
+
|
|
68
|
+
## Data
|
|
69
|
+
|
|
70
|
+
### Current Conditions (`ForecastData`)
|
|
71
|
+
|
|
72
|
+
| Property | Description |
|
|
73
|
+
| -------- | ----------- |
|
|
74
|
+
| `datetime` | Valid time (UTC) |
|
|
75
|
+
| `temperature` | Air temperature |
|
|
76
|
+
| `apparent_temperature` | Feels-like temperature |
|
|
77
|
+
| `dew_point` | Dew point |
|
|
78
|
+
| `condition` | Weather condition text |
|
|
79
|
+
| `icon` | Weather condition icon id |
|
|
80
|
+
| `cloud_cover` | Cloud coverage (%) |
|
|
81
|
+
| `humidity` | Humidity (%) |
|
|
82
|
+
| `precipitation` | Precipitation |
|
|
83
|
+
| `precipitation_probability` | Probability of precipitation (%) |
|
|
84
|
+
| `pressure` | Sea level pressure |
|
|
85
|
+
| `solarradiation` | Solar radiation (W/m2) |
|
|
86
|
+
| `visibility` | Visibility |
|
|
87
|
+
| `uv_index` | UV index |
|
|
88
|
+
| `wind_bearing` | Wind bearing (degrees) |
|
|
89
|
+
| `wind_speed` | Wind speed |
|
|
90
|
+
| `wind_gust_speed` | Wind gust speed |
|
|
91
|
+
| `location_name` | Name of the location |
|
|
92
|
+
| `description` | Weather description |
|
|
93
|
+
| `snow` | Snowfall |
|
|
94
|
+
| `snow_depth` | Snow depth |
|
|
95
|
+
| `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
|
|
96
|
+
| `solarenergy` | Solar energy (MJ/m2) |
|
|
97
|
+
| `sunrise` | Sunrise time |
|
|
98
|
+
| `sunset` | Sunset time |
|
|
99
|
+
| `moon_phase` | Moon phase, as a fraction between 0 and 1 |
|
|
100
|
+
| `update_time` | Timestamp of when the data was fetched |
|
|
101
|
+
| `forecast_daily` | List of `ForecastDailyData` |
|
|
102
|
+
| `forecast_hourly` | List of `ForecastHourlyData` |
|
|
103
|
+
|
|
104
|
+
### Daily Forecast (`ForecastDailyData`)
|
|
105
|
+
|
|
106
|
+
| Property | Description |
|
|
107
|
+
| -------- | ----------- |
|
|
108
|
+
| `datetime` | Valid date (UTC) |
|
|
109
|
+
| `temperature` | Max air temperature for the day |
|
|
110
|
+
| `temp_low` | Min air temperature for the day |
|
|
111
|
+
| `apparent_temperature` | Feels-like temperature |
|
|
112
|
+
| `condition` | Weather condition text |
|
|
113
|
+
| `icon` | Weather condition icon id |
|
|
114
|
+
| `cloud_cover` | Cloud coverage (%) |
|
|
115
|
+
| `dew_point` | Dew point |
|
|
116
|
+
| `humidity` | Humidity (%) |
|
|
117
|
+
| `precipitation` | Precipitation |
|
|
118
|
+
| `precipitation_probability` | Probability of precipitation (%) |
|
|
119
|
+
| `pressure` | Sea level pressure |
|
|
120
|
+
| `uv_index` | UV index |
|
|
121
|
+
| `wind_bearing` | Wind bearing (degrees) |
|
|
122
|
+
| `wind_speed` | Wind speed |
|
|
123
|
+
| `wind_gust` | Wind gust speed |
|
|
124
|
+
| `snow` | Snowfall |
|
|
125
|
+
| `snow_depth` | Snow depth |
|
|
126
|
+
| `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
|
|
127
|
+
| `precipitation_cover` | Percentage of the day with precipitation (%) |
|
|
128
|
+
| `solarradiation` | Solar radiation (W/m2) |
|
|
129
|
+
| `solarenergy` | Solar energy (MJ/m2) |
|
|
130
|
+
| `severe_risk` | Risk score of severe weather |
|
|
131
|
+
| `sunrise` | Sunrise time |
|
|
132
|
+
| `sunset` | Sunset time |
|
|
133
|
+
| `moon_phase` | Moon phase, as a fraction between 0 and 1 |
|
|
134
|
+
|
|
135
|
+
### Hourly Forecast (`ForecastHourlyData`)
|
|
136
|
+
|
|
137
|
+
Only hours later than the current time are included.
|
|
138
|
+
|
|
139
|
+
| Property | Description |
|
|
140
|
+
| -------- | ----------- |
|
|
141
|
+
| `datetime` | Valid date and time (UTC) |
|
|
142
|
+
| `temperature` | Air temperature |
|
|
143
|
+
| `apparent_temperature` | Feels-like temperature |
|
|
144
|
+
| `condition` | Weather condition text |
|
|
145
|
+
| `icon` | Weather condition icon id |
|
|
146
|
+
| `cloud_cover` | Cloud coverage (%) |
|
|
147
|
+
| `dew_point` | Dew point |
|
|
148
|
+
| `humidity` | Humidity (%) |
|
|
149
|
+
| `precipitation` | Precipitation |
|
|
150
|
+
| `precipitation_probability` | Probability of precipitation (%) |
|
|
151
|
+
| `pressure` | Sea level pressure |
|
|
152
|
+
| `uv_index` | UV index |
|
|
153
|
+
| `wind_bearing` | Wind bearing (degrees) |
|
|
154
|
+
| `wind_speed` | Wind speed |
|
|
155
|
+
| `wind_gust_speed` | Wind gust speed |
|
|
156
|
+
| `snow` | Snowfall |
|
|
157
|
+
| `snow_depth` | Snow depth |
|
|
158
|
+
| `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
|
|
159
|
+
| `solarradiation` | Solar radiation (W/m2) |
|
|
160
|
+
| `solarenergy` | Solar energy (MJ/m2) |
|
|
161
|
+
| `severe_risk` | Risk score of severe weather |
|
|
162
|
+
| `visibility` | Visibility |
|
|
163
|
+
|
|
164
|
+
## Languages
|
|
165
|
+
Available languages include: **ar** (Arabic), **bg** (Bulgiarian), **cs** (Czech), **da** (Danish), **de** (German), **el** (Greek Modern), **en** (English), **es** (Spanish), **fa** (Farsi), **fi** (Finnish), **fr** (French), **he** (Hebrew), **hu**, (Hungarian), **it** (Italian), **ja** (Japanese), **ko** (Korean), **nl** (Dutch), **pl** (Polish), **pt** (Portuguese), **sr** (Serbian), **sv** (Swedish), **tr** (Turkish), **uk** (Ukranian), **vi** (Vietnamese) and **zh** (Chinese).
|
|
166
|
+
|
|
167
|
+
## Metrics
|
|
168
|
+
All records are returned using the *Metric* unit system. There is no conversion possible at the moment.
|
|
169
|
+
|
|
170
|
+
| Weather variable | Measurement Unit |
|
|
171
|
+
| ----------------------------------- | ------------------------ |
|
|
172
|
+
| Datetime | UTC datetime |
|
|
173
|
+
| Temperature, Heat Index & Wind Chill | Degrees Celcius |
|
|
174
|
+
| Precipitation | Millimeters |
|
|
175
|
+
| snow | Centimeters |
|
|
176
|
+
| Wind & Wind Gust | Kilometers Per Hour |
|
|
177
|
+
| Visibility | Kilometers |
|
|
178
|
+
| Pressure | Millibars (Hectopascals) |
|
|
179
|
+
| Solar Radiation | W/m2 |
|
|
180
|
+
| Solar Energy | MJ/m2 |
|
|
181
|
+
|
|
182
|
+
## Icons
|
|
183
|
+
We use the Iconset *icons2*, which gives a more detailed description of the conditions.
|
|
184
|
+
|
|
185
|
+
| Icon id | Weather Conditions |
|
|
186
|
+
| -------------------- | ---------------------------- |
|
|
187
|
+
| snow | Amount of snow is greater than zero |
|
|
188
|
+
| snow-showers-day | Periods of snow during the day |
|
|
189
|
+
| snow-showers-night | Periods of snow during the night |
|
|
190
|
+
| thunder-rain | Thunderstorms throughout the day or night |
|
|
191
|
+
| thunder-showers-day | Possible thunderstorms throughout the day |
|
|
192
|
+
| thunder-showers-night | Possible thunderstorms throughout the night |
|
|
193
|
+
| rain | Amount of rainfall is greater than zero |
|
|
194
|
+
| showers-day | Rain showers during the day |
|
|
195
|
+
| showers-night | Rain showers during the night |
|
|
196
|
+
| fog | Visibility is low (lower than one kilometer or mile) |
|
|
197
|
+
| wind | Wind speed is high (greater than 30 kph or mph) |
|
|
198
|
+
| cloudy | Cloud cover is greater than 90% cover |
|
|
199
|
+
| partly-cloudy-day | Cloud cover is greater than 20% cover during day time. |
|
|
200
|
+
| partly-cloudy-night | Cloud cover is greater than 20% cover during night time. |
|
|
201
|
+
| clear-day | Cloud cover is less than 20% cover during day time |
|
|
202
|
+
| clear-night | Cloud cover is less than 20% cover during night time |
|
|
@@ -234,30 +234,50 @@ def _fetch_data(api_result: dict[str, Any] | None) -> ForecastData | None:
|
|
|
234
234
|
apparent_temperature = item.get("feelslike", None)
|
|
235
235
|
precipitation = item.get("precip", None)
|
|
236
236
|
precipitation_probability = item.get("precipprob", None)
|
|
237
|
+
precipitation_type = item.get("preciptype", None)
|
|
238
|
+
precipitation_cover = item.get("precipcover", None)
|
|
237
239
|
humidity = item.get("humidity", None)
|
|
238
240
|
pressure = item.get("pressure", None)
|
|
239
241
|
uv_index = item.get("uvindex", None)
|
|
240
242
|
wind_speed = item.get("windspeed", None)
|
|
241
243
|
wind_gust_speed = item.get("windgust", None)
|
|
242
244
|
wind_bearing = item.get("winddir", None)
|
|
245
|
+
snow = item.get("snow", None)
|
|
246
|
+
snow_depth = item.get("snowdepth", None)
|
|
247
|
+
solarradiation = item.get("solarradiation", None)
|
|
248
|
+
solarenergy = item.get("solarenergy", None)
|
|
249
|
+
severe_risk = item.get("severerisk", None)
|
|
250
|
+
sunrise = item.get("sunrise", None)
|
|
251
|
+
sunset = item.get("sunset", None)
|
|
252
|
+
moon_phase = item.get("moonphase", None)
|
|
243
253
|
|
|
244
254
|
day_data = ForecastDailyData(
|
|
245
|
-
day_obj,
|
|
246
|
-
temperature,
|
|
247
|
-
temp_low,
|
|
248
|
-
apparent_temperature,
|
|
249
|
-
condition,
|
|
250
|
-
icon,
|
|
251
|
-
cloudcover,
|
|
252
|
-
dew_point,
|
|
253
|
-
humidity,
|
|
254
|
-
precipitation_probability,
|
|
255
|
-
precipitation,
|
|
256
|
-
pressure,
|
|
257
|
-
wind_bearing,
|
|
258
|
-
wind_speed,
|
|
259
|
-
wind_gust_speed,
|
|
260
|
-
uv_index,
|
|
255
|
+
datetime=day_obj,
|
|
256
|
+
temperature=temperature,
|
|
257
|
+
temp_low=temp_low,
|
|
258
|
+
apparent_temperature=apparent_temperature,
|
|
259
|
+
condition=condition,
|
|
260
|
+
icon=icon,
|
|
261
|
+
cloud_cover=cloudcover,
|
|
262
|
+
dew_point=dew_point,
|
|
263
|
+
humidity=humidity,
|
|
264
|
+
precipitation_probability=precipitation_probability,
|
|
265
|
+
precipitation=precipitation,
|
|
266
|
+
pressure=pressure,
|
|
267
|
+
wind_bearing=wind_bearing,
|
|
268
|
+
wind_speed=wind_speed,
|
|
269
|
+
wind_gust=wind_gust_speed,
|
|
270
|
+
uv_index=uv_index,
|
|
271
|
+
snow=snow,
|
|
272
|
+
snow_depth=snow_depth,
|
|
273
|
+
precipitation_type=precipitation_type,
|
|
274
|
+
precipitation_cover=precipitation_cover,
|
|
275
|
+
solarradiation=solarradiation,
|
|
276
|
+
solarenergy=solarenergy,
|
|
277
|
+
severe_risk=severe_risk,
|
|
278
|
+
sunrise=sunrise,
|
|
279
|
+
sunset=sunset,
|
|
280
|
+
moon_phase=moon_phase,
|
|
261
281
|
)
|
|
262
282
|
forecast_daily.append(day_data)
|
|
263
283
|
|
|
@@ -277,29 +297,43 @@ def _fetch_data(api_result: dict[str, Any] | None) -> ForecastData | None:
|
|
|
277
297
|
apparent_temperature = row.get("feelslike", None)
|
|
278
298
|
precipitation = row.get("precip", None)
|
|
279
299
|
precipitation_probability = row.get("precipprob", None)
|
|
300
|
+
precipitation_type = row.get("preciptype", None)
|
|
280
301
|
humidity = row.get("humidity", None)
|
|
281
302
|
pressure = row.get("pressure", None)
|
|
282
303
|
uv_index = row.get("uvindex", None)
|
|
283
304
|
wind_speed = row.get("windspeed", None)
|
|
284
305
|
wind_gust_speed = row.get("windgust", None)
|
|
285
306
|
wind_bearing = row.get("winddir", None)
|
|
307
|
+
snow = row.get("snow", None)
|
|
308
|
+
snow_depth = row.get("snowdepth", None)
|
|
309
|
+
solarradiation = row.get("solarradiation", None)
|
|
310
|
+
solarenergy = row.get("solarenergy", None)
|
|
311
|
+
severe_risk = row.get("severerisk", None)
|
|
312
|
+
visibility = row.get("visibility", None)
|
|
286
313
|
|
|
287
314
|
hour_data = ForecastHourlyData(
|
|
288
|
-
day_hour_obj,
|
|
289
|
-
temperature,
|
|
290
|
-
apparent_temperature,
|
|
291
|
-
condition,
|
|
292
|
-
cloudcover,
|
|
293
|
-
icon,
|
|
294
|
-
dew_point,
|
|
295
|
-
humidity,
|
|
296
|
-
precipitation,
|
|
297
|
-
precipitation_probability,
|
|
298
|
-
pressure,
|
|
299
|
-
wind_bearing,
|
|
300
|
-
wind_gust_speed,
|
|
301
|
-
wind_speed,
|
|
302
|
-
uv_index,
|
|
315
|
+
datetime=day_hour_obj,
|
|
316
|
+
temperature=temperature,
|
|
317
|
+
apparent_temperature=apparent_temperature,
|
|
318
|
+
condition=condition,
|
|
319
|
+
cloud_cover=cloudcover,
|
|
320
|
+
icon=icon,
|
|
321
|
+
dew_point=dew_point,
|
|
322
|
+
humidity=humidity,
|
|
323
|
+
precipitation=precipitation,
|
|
324
|
+
precipitation_probability=precipitation_probability,
|
|
325
|
+
pressure=pressure,
|
|
326
|
+
wind_bearing=wind_bearing,
|
|
327
|
+
wind_gust_speed=wind_gust_speed,
|
|
328
|
+
wind_speed=wind_speed,
|
|
329
|
+
uv_index=uv_index,
|
|
330
|
+
snow=snow,
|
|
331
|
+
snow_depth=snow_depth,
|
|
332
|
+
precipitation_type=precipitation_type,
|
|
333
|
+
solarradiation=solarradiation,
|
|
334
|
+
solarenergy=solarenergy,
|
|
335
|
+
severe_risk=severe_risk,
|
|
336
|
+
visibility=visibility,
|
|
303
337
|
)
|
|
304
338
|
forecast_hourly.append(hour_data)
|
|
305
339
|
|
|
@@ -328,37 +362,51 @@ def _get_current_data(api_result: dict[str, Any]) -> ForecastData:
|
|
|
328
362
|
apparent_temperature = item.get("feelslike", None)
|
|
329
363
|
precipitation = item.get("precip", None)
|
|
330
364
|
precipitation_probability = item.get("precipprob", None)
|
|
365
|
+
precipitation_type = item.get("preciptype", None)
|
|
331
366
|
humidity = item.get("humidity", None)
|
|
332
367
|
solarradiation = item.get("solarradiation", None)
|
|
368
|
+
solarenergy = item.get("solarenergy", None)
|
|
333
369
|
visibility = item.get("visibility", None)
|
|
334
370
|
pressure = item.get("pressure", None)
|
|
335
371
|
uv_index = item.get("uvindex", None)
|
|
336
372
|
wind_speed = item.get("windspeed", None)
|
|
337
373
|
wind_gust_speed = item.get("windgust", None)
|
|
338
374
|
wind_bearing = item.get("winddir", None)
|
|
375
|
+
snow = item.get("snow", None)
|
|
376
|
+
snow_depth = item.get("snowdepth", None)
|
|
377
|
+
sunrise = item.get("sunrise", None)
|
|
378
|
+
sunset = item.get("sunset", None)
|
|
379
|
+
moon_phase = item.get("moonphase", None)
|
|
339
380
|
location = api_result.get("address", "")
|
|
340
381
|
description = api_result.get("description", "")
|
|
341
382
|
|
|
342
383
|
current_condition = ForecastData(
|
|
343
|
-
day_hour_obj,
|
|
344
|
-
apparent_temperature,
|
|
345
|
-
condition,
|
|
346
|
-
cloudcover,
|
|
347
|
-
dew_point,
|
|
348
|
-
humidity,
|
|
349
|
-
icon,
|
|
350
|
-
precipitation,
|
|
351
|
-
precipitation_probability,
|
|
352
|
-
pressure,
|
|
353
|
-
solarradiation,
|
|
354
|
-
temperature,
|
|
355
|
-
visibility,
|
|
356
|
-
uv_index,
|
|
357
|
-
wind_bearing,
|
|
358
|
-
wind_gust_speed,
|
|
359
|
-
wind_speed,
|
|
360
|
-
location,
|
|
361
|
-
description,
|
|
384
|
+
datetime=day_hour_obj,
|
|
385
|
+
apparent_temperature=apparent_temperature,
|
|
386
|
+
condition=condition,
|
|
387
|
+
cloud_cover=cloudcover,
|
|
388
|
+
dew_point=dew_point,
|
|
389
|
+
humidity=humidity,
|
|
390
|
+
icon=icon,
|
|
391
|
+
precipitation=precipitation,
|
|
392
|
+
precipitation_probability=precipitation_probability,
|
|
393
|
+
pressure=pressure,
|
|
394
|
+
solarradiation=solarradiation,
|
|
395
|
+
temperature=temperature,
|
|
396
|
+
visibility=visibility,
|
|
397
|
+
uv_index=uv_index,
|
|
398
|
+
wind_bearing=wind_bearing,
|
|
399
|
+
wind_gust_speed=wind_gust_speed,
|
|
400
|
+
wind_speed=wind_speed,
|
|
401
|
+
location_name=location,
|
|
402
|
+
description=description,
|
|
403
|
+
snow=snow,
|
|
404
|
+
snow_depth=snow_depth,
|
|
405
|
+
precipitation_type=precipitation_type,
|
|
406
|
+
solarenergy=solarenergy,
|
|
407
|
+
sunrise=sunrise,
|
|
408
|
+
sunset=sunset,
|
|
409
|
+
moon_phase=moon_phase,
|
|
362
410
|
)
|
|
363
411
|
|
|
364
412
|
return current_condition
|
|
@@ -29,6 +29,13 @@ class ForecastData:
|
|
|
29
29
|
wind_speed: float,
|
|
30
30
|
location_name: str,
|
|
31
31
|
description: str,
|
|
32
|
+
snow: float | None = None,
|
|
33
|
+
snow_depth: float | None = None,
|
|
34
|
+
precipitation_type: list[str] | None = None,
|
|
35
|
+
solarenergy: float | None = None,
|
|
36
|
+
sunrise: str | None = None,
|
|
37
|
+
sunset: str | None = None,
|
|
38
|
+
moon_phase: float | None = None,
|
|
32
39
|
forecast_daily: list[ForecastDailyData] | None = None,
|
|
33
40
|
forecast_hourly: list[ForecastHourlyData] | None = None,
|
|
34
41
|
) -> None:
|
|
@@ -52,6 +59,13 @@ class ForecastData:
|
|
|
52
59
|
self._wind_speed = wind_speed
|
|
53
60
|
self._location_name = location_name
|
|
54
61
|
self._description = description
|
|
62
|
+
self._snow = snow
|
|
63
|
+
self._snow_depth = snow_depth
|
|
64
|
+
self._precipitation_type = precipitation_type
|
|
65
|
+
self._solarenergy = solarenergy
|
|
66
|
+
self._sunrise = sunrise
|
|
67
|
+
self._sunset = sunset
|
|
68
|
+
self._moon_phase = moon_phase
|
|
55
69
|
self._forecast_daily = forecast_daily
|
|
56
70
|
self._forecast_hourly = forecast_hourly
|
|
57
71
|
|
|
@@ -100,6 +114,11 @@ class ForecastData:
|
|
|
100
114
|
"""Posobility of Precipiation (%)."""
|
|
101
115
|
return self._precipitation_probability
|
|
102
116
|
|
|
117
|
+
@property
|
|
118
|
+
def precipitation_type(self) -> list[str] | None:
|
|
119
|
+
"""Type(s) of precipitation, if any."""
|
|
120
|
+
return self._precipitation_type
|
|
121
|
+
|
|
103
122
|
@property
|
|
104
123
|
def pressure(self) -> float:
|
|
105
124
|
"""Sea Level Pressure (MB)."""
|
|
@@ -110,6 +129,11 @@ class ForecastData:
|
|
|
110
129
|
"""Solar Radiation (w/m2)."""
|
|
111
130
|
return self._solarradiation
|
|
112
131
|
|
|
132
|
+
@property
|
|
133
|
+
def solarenergy(self) -> float | None:
|
|
134
|
+
"""Solar Energy (MJ/m2)."""
|
|
135
|
+
return self._solarenergy
|
|
136
|
+
|
|
113
137
|
@property
|
|
114
138
|
def visibility(self) -> int:
|
|
115
139
|
"""Visibility (km)."""
|
|
@@ -135,6 +159,31 @@ class ForecastData:
|
|
|
135
159
|
"""UV Index."""
|
|
136
160
|
return self._uv_index
|
|
137
161
|
|
|
162
|
+
@property
|
|
163
|
+
def snow(self) -> float | None:
|
|
164
|
+
"""Snowfall (cm)."""
|
|
165
|
+
return self._snow
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def snow_depth(self) -> float | None:
|
|
169
|
+
"""Snow Depth (cm)."""
|
|
170
|
+
return self._snow_depth
|
|
171
|
+
|
|
172
|
+
@property
|
|
173
|
+
def sunrise(self) -> str | None:
|
|
174
|
+
"""Sunrise time."""
|
|
175
|
+
return self._sunrise
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def sunset(self) -> str | None:
|
|
179
|
+
"""Sunset time."""
|
|
180
|
+
return self._sunset
|
|
181
|
+
|
|
182
|
+
@property
|
|
183
|
+
def moon_phase(self) -> float | None:
|
|
184
|
+
"""Moon phase, as a fraction between 0 and 1."""
|
|
185
|
+
return self._moon_phase
|
|
186
|
+
|
|
138
187
|
@property
|
|
139
188
|
def datetime(self) -> datetime:
|
|
140
189
|
"""Valid time."""
|
|
@@ -198,6 +247,16 @@ class ForecastDailyData:
|
|
|
198
247
|
wind_speed: float,
|
|
199
248
|
wind_gust: float,
|
|
200
249
|
uv_index: int,
|
|
250
|
+
snow: float | None = None,
|
|
251
|
+
snow_depth: float | None = None,
|
|
252
|
+
precipitation_type: list[str] | None = None,
|
|
253
|
+
precipitation_cover: float | None = None,
|
|
254
|
+
solarradiation: float | None = None,
|
|
255
|
+
solarenergy: float | None = None,
|
|
256
|
+
severe_risk: float | None = None,
|
|
257
|
+
sunrise: str | None = None,
|
|
258
|
+
sunset: str | None = None,
|
|
259
|
+
moon_phase: float | None = None,
|
|
201
260
|
) -> None:
|
|
202
261
|
"""Dataset constructor."""
|
|
203
262
|
self._datetime = datetime
|
|
@@ -216,6 +275,16 @@ class ForecastDailyData:
|
|
|
216
275
|
self._wind_gust = wind_gust
|
|
217
276
|
self._wind_speed = wind_speed
|
|
218
277
|
self._uv_index = uv_index
|
|
278
|
+
self._snow = snow
|
|
279
|
+
self._snow_depth = snow_depth
|
|
280
|
+
self._precipitation_type = precipitation_type
|
|
281
|
+
self._precipitation_cover = precipitation_cover
|
|
282
|
+
self._solarradiation = solarradiation
|
|
283
|
+
self._solarenergy = solarenergy
|
|
284
|
+
self._severe_risk = severe_risk
|
|
285
|
+
self._sunrise = sunrise
|
|
286
|
+
self._sunset = sunset
|
|
287
|
+
self._moon_phase = moon_phase
|
|
219
288
|
|
|
220
289
|
@property
|
|
221
290
|
def datetime(self) -> datetime:
|
|
@@ -272,11 +341,36 @@ class ForecastDailyData:
|
|
|
272
341
|
"""Precipitation (mm)."""
|
|
273
342
|
return self._precipitation
|
|
274
343
|
|
|
344
|
+
@property
|
|
345
|
+
def precipitation_type(self) -> list[str] | None:
|
|
346
|
+
"""Type(s) of precipitation, if any."""
|
|
347
|
+
return self._precipitation_type
|
|
348
|
+
|
|
349
|
+
@property
|
|
350
|
+
def precipitation_cover(self) -> float | None:
|
|
351
|
+
"""Percentage of the day with precipitation (%)."""
|
|
352
|
+
return self._precipitation_cover
|
|
353
|
+
|
|
275
354
|
@property
|
|
276
355
|
def pressure(self) -> float:
|
|
277
356
|
"""Sea Level Pressure (MB)."""
|
|
278
357
|
return self._pressure
|
|
279
358
|
|
|
359
|
+
@property
|
|
360
|
+
def solarradiation(self) -> float | None:
|
|
361
|
+
"""Solar Radiation (w/m2)."""
|
|
362
|
+
return self._solarradiation
|
|
363
|
+
|
|
364
|
+
@property
|
|
365
|
+
def solarenergy(self) -> float | None:
|
|
366
|
+
"""Solar Energy (MJ/m2)."""
|
|
367
|
+
return self._solarenergy
|
|
368
|
+
|
|
369
|
+
@property
|
|
370
|
+
def severe_risk(self) -> float | None:
|
|
371
|
+
"""Risk score of severe weather."""
|
|
372
|
+
return self._severe_risk
|
|
373
|
+
|
|
280
374
|
@property
|
|
281
375
|
def uv_index(self) -> float:
|
|
282
376
|
"""UV Index."""
|
|
@@ -297,6 +391,31 @@ class ForecastDailyData:
|
|
|
297
391
|
"""Wind speed (m/s)."""
|
|
298
392
|
return self._wind_speed
|
|
299
393
|
|
|
394
|
+
@property
|
|
395
|
+
def snow(self) -> float | None:
|
|
396
|
+
"""Snowfall (cm)."""
|
|
397
|
+
return self._snow
|
|
398
|
+
|
|
399
|
+
@property
|
|
400
|
+
def snow_depth(self) -> float | None:
|
|
401
|
+
"""Snow Depth (cm)."""
|
|
402
|
+
return self._snow_depth
|
|
403
|
+
|
|
404
|
+
@property
|
|
405
|
+
def sunrise(self) -> str | None:
|
|
406
|
+
"""Sunrise time."""
|
|
407
|
+
return self._sunrise
|
|
408
|
+
|
|
409
|
+
@property
|
|
410
|
+
def sunset(self) -> str | None:
|
|
411
|
+
"""Sunset time."""
|
|
412
|
+
return self._sunset
|
|
413
|
+
|
|
414
|
+
@property
|
|
415
|
+
def moon_phase(self) -> float | None:
|
|
416
|
+
"""Moon phase, as a fraction between 0 and 1."""
|
|
417
|
+
return self._moon_phase
|
|
418
|
+
|
|
300
419
|
|
|
301
420
|
class ForecastHourlyData:
|
|
302
421
|
"""Class to hold hourly forecast data."""
|
|
@@ -319,6 +438,13 @@ class ForecastHourlyData:
|
|
|
319
438
|
wind_gust_speed: int,
|
|
320
439
|
wind_speed: int,
|
|
321
440
|
uv_index: float,
|
|
441
|
+
snow: float | None = None,
|
|
442
|
+
snow_depth: float | None = None,
|
|
443
|
+
precipitation_type: list[str] | None = None,
|
|
444
|
+
solarradiation: float | None = None,
|
|
445
|
+
solarenergy: float | None = None,
|
|
446
|
+
severe_risk: float | None = None,
|
|
447
|
+
visibility: float | None = None,
|
|
322
448
|
) -> None:
|
|
323
449
|
"""Dataset constructor."""
|
|
324
450
|
self._datetime = datetime
|
|
@@ -336,6 +462,13 @@ class ForecastHourlyData:
|
|
|
336
462
|
self._wind_gust_speed = wind_gust_speed
|
|
337
463
|
self._wind_speed = wind_speed
|
|
338
464
|
self._uv_index = uv_index
|
|
465
|
+
self._snow = snow
|
|
466
|
+
self._snow_depth = snow_depth
|
|
467
|
+
self._precipitation_type = precipitation_type
|
|
468
|
+
self._solarradiation = solarradiation
|
|
469
|
+
self._solarenergy = solarenergy
|
|
470
|
+
self._severe_risk = severe_risk
|
|
471
|
+
self._visibility = visibility
|
|
339
472
|
|
|
340
473
|
@property
|
|
341
474
|
def temperature(self) -> float:
|
|
@@ -382,11 +515,36 @@ class ForecastHourlyData:
|
|
|
382
515
|
"""Posobility of Precipiation (%)."""
|
|
383
516
|
return self._precipitation_probability
|
|
384
517
|
|
|
518
|
+
@property
|
|
519
|
+
def precipitation_type(self) -> list[str] | None:
|
|
520
|
+
"""Type(s) of precipitation, if any."""
|
|
521
|
+
return self._precipitation_type
|
|
522
|
+
|
|
385
523
|
@property
|
|
386
524
|
def pressure(self) -> float:
|
|
387
525
|
"""Sea Level Pressure (MB)."""
|
|
388
526
|
return self._pressure
|
|
389
527
|
|
|
528
|
+
@property
|
|
529
|
+
def solarradiation(self) -> float | None:
|
|
530
|
+
"""Solar Radiation (w/m2)."""
|
|
531
|
+
return self._solarradiation
|
|
532
|
+
|
|
533
|
+
@property
|
|
534
|
+
def solarenergy(self) -> float | None:
|
|
535
|
+
"""Solar Energy (MJ/m2)."""
|
|
536
|
+
return self._solarenergy
|
|
537
|
+
|
|
538
|
+
@property
|
|
539
|
+
def severe_risk(self) -> float | None:
|
|
540
|
+
"""Risk score of severe weather."""
|
|
541
|
+
return self._severe_risk
|
|
542
|
+
|
|
543
|
+
@property
|
|
544
|
+
def visibility(self) -> float | None:
|
|
545
|
+
"""Visibility (km)."""
|
|
546
|
+
return self._visibility
|
|
547
|
+
|
|
390
548
|
@property
|
|
391
549
|
def wind_bearing(self) -> float:
|
|
392
550
|
"""Wind bearing (degrees)."""
|
|
@@ -407,6 +565,16 @@ class ForecastHourlyData:
|
|
|
407
565
|
"""UV Index."""
|
|
408
566
|
return self._uv_index
|
|
409
567
|
|
|
568
|
+
@property
|
|
569
|
+
def snow(self) -> float | None:
|
|
570
|
+
"""Snowfall (cm)."""
|
|
571
|
+
return self._snow
|
|
572
|
+
|
|
573
|
+
@property
|
|
574
|
+
def snow_depth(self) -> float | None:
|
|
575
|
+
"""Snow Depth (cm)."""
|
|
576
|
+
return self._snow_depth
|
|
577
|
+
|
|
410
578
|
@property
|
|
411
579
|
def datetime(self) -> datetime:
|
|
412
580
|
"""Valid time."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyVisualCrossing
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Gets the weather data from Visual Crossing
|
|
5
5
|
Home-page: https://github.com/briis/pyVisualCrossing
|
|
6
6
|
Author: briis
|
|
@@ -32,7 +32,7 @@ In order to get started you must create an Account with Visual Crossing and then
|
|
|
32
32
|
|
|
33
33
|
Install the module by using this command in a terminal: `pip install pyVisualCrossing`
|
|
34
34
|
|
|
35
|
-
And then see `test_module.py`
|
|
35
|
+
And then see `test_module.py` for a usage example.
|
|
36
36
|
|
|
37
37
|
## Parameters
|
|
38
38
|
|
|
@@ -45,7 +45,7 @@ vcapi = VisualCrossing(
|
|
|
45
45
|
days=7,
|
|
46
46
|
language="da"
|
|
47
47
|
)
|
|
48
|
-
|
|
48
|
+
```
|
|
49
49
|
|
|
50
50
|
| Parameter | Required | Default | Description |
|
|
51
51
|
| --------- | -------- | ------- | ----------- |
|
|
@@ -54,11 +54,136 @@ vcapi = VisualCrossing(
|
|
|
54
54
|
| `longitude` | Yes | `None` | Longitude for the location position |
|
|
55
55
|
| `days` | No | `14` | Numbers of days to retrieve forecast for. 14 days means today plus the next 14 days. On the Free plan, this is the maximum number of days |
|
|
56
56
|
| `language` | No | `en` | The language in which text strings should be returned. Se below for list of valid languages. |
|
|
57
|
-
| `session` | No | `None` |
|
|
57
|
+
| `session` | No | `None` | An `aiohttp.ClientSession` to reuse for the async function. If not supplied, a session is created and closed automatically. |
|
|
58
58
|
|
|
59
|
+
For an in-depth description of the Visual Crossing API, go [here](https://www.visualcrossing.com/resources/documentation/weather-api/timeline-weather-api/)
|
|
59
60
|
|
|
61
|
+
## Fetching Data
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
Once initialised, call either the synchronous or the async method to retrieve data. Both return a single `ForecastData` object (or `None` if the request failed), holding the current conditions plus a daily and an hourly forecast list.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# Synchronous
|
|
67
|
+
data = vcapi.fetch_data()
|
|
68
|
+
|
|
69
|
+
# Async
|
|
70
|
+
data = await vcapi.async_fetch_data()
|
|
71
|
+
|
|
72
|
+
print(data.temperature)
|
|
73
|
+
for day in data.forecast_daily:
|
|
74
|
+
print(day.datetime, day.temperature, day.condition)
|
|
75
|
+
|
|
76
|
+
for hour in data.forecast_hourly:
|
|
77
|
+
print(hour.datetime, hour.temperature, hour.condition)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Exceptions
|
|
81
|
+
|
|
82
|
+
If the API request fails, one of these exceptions (all importable from `pyVisualCrossing`) is raised:
|
|
83
|
+
|
|
84
|
+
| Exception | Description |
|
|
85
|
+
| --------- | ----------- |
|
|
86
|
+
| `VisualCrossingBadRequest` | The request was invalid (invalid dates, bad location parameter, etc.) |
|
|
87
|
+
| `VisualCrossingUnauthorized` | The API key is incorrect, or the account is inactive or disabled |
|
|
88
|
+
| `VisualCrossingTooManyRequests` | Too many daily requests for the current plan |
|
|
89
|
+
| `VisualCrossingInternalServerError` | Visual Crossing's servers encountered an unexpected error |
|
|
90
|
+
| `VisualCrossingException` | Generic base exception for failing to access the API |
|
|
91
|
+
|
|
92
|
+
## Data
|
|
93
|
+
|
|
94
|
+
### Current Conditions (`ForecastData`)
|
|
95
|
+
|
|
96
|
+
| Property | Description |
|
|
97
|
+
| -------- | ----------- |
|
|
98
|
+
| `datetime` | Valid time (UTC) |
|
|
99
|
+
| `temperature` | Air temperature |
|
|
100
|
+
| `apparent_temperature` | Feels-like temperature |
|
|
101
|
+
| `dew_point` | Dew point |
|
|
102
|
+
| `condition` | Weather condition text |
|
|
103
|
+
| `icon` | Weather condition icon id |
|
|
104
|
+
| `cloud_cover` | Cloud coverage (%) |
|
|
105
|
+
| `humidity` | Humidity (%) |
|
|
106
|
+
| `precipitation` | Precipitation |
|
|
107
|
+
| `precipitation_probability` | Probability of precipitation (%) |
|
|
108
|
+
| `pressure` | Sea level pressure |
|
|
109
|
+
| `solarradiation` | Solar radiation (W/m2) |
|
|
110
|
+
| `visibility` | Visibility |
|
|
111
|
+
| `uv_index` | UV index |
|
|
112
|
+
| `wind_bearing` | Wind bearing (degrees) |
|
|
113
|
+
| `wind_speed` | Wind speed |
|
|
114
|
+
| `wind_gust_speed` | Wind gust speed |
|
|
115
|
+
| `location_name` | Name of the location |
|
|
116
|
+
| `description` | Weather description |
|
|
117
|
+
| `snow` | Snowfall |
|
|
118
|
+
| `snow_depth` | Snow depth |
|
|
119
|
+
| `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
|
|
120
|
+
| `solarenergy` | Solar energy (MJ/m2) |
|
|
121
|
+
| `sunrise` | Sunrise time |
|
|
122
|
+
| `sunset` | Sunset time |
|
|
123
|
+
| `moon_phase` | Moon phase, as a fraction between 0 and 1 |
|
|
124
|
+
| `update_time` | Timestamp of when the data was fetched |
|
|
125
|
+
| `forecast_daily` | List of `ForecastDailyData` |
|
|
126
|
+
| `forecast_hourly` | List of `ForecastHourlyData` |
|
|
127
|
+
|
|
128
|
+
### Daily Forecast (`ForecastDailyData`)
|
|
129
|
+
|
|
130
|
+
| Property | Description |
|
|
131
|
+
| -------- | ----------- |
|
|
132
|
+
| `datetime` | Valid date (UTC) |
|
|
133
|
+
| `temperature` | Max air temperature for the day |
|
|
134
|
+
| `temp_low` | Min air temperature for the day |
|
|
135
|
+
| `apparent_temperature` | Feels-like temperature |
|
|
136
|
+
| `condition` | Weather condition text |
|
|
137
|
+
| `icon` | Weather condition icon id |
|
|
138
|
+
| `cloud_cover` | Cloud coverage (%) |
|
|
139
|
+
| `dew_point` | Dew point |
|
|
140
|
+
| `humidity` | Humidity (%) |
|
|
141
|
+
| `precipitation` | Precipitation |
|
|
142
|
+
| `precipitation_probability` | Probability of precipitation (%) |
|
|
143
|
+
| `pressure` | Sea level pressure |
|
|
144
|
+
| `uv_index` | UV index |
|
|
145
|
+
| `wind_bearing` | Wind bearing (degrees) |
|
|
146
|
+
| `wind_speed` | Wind speed |
|
|
147
|
+
| `wind_gust` | Wind gust speed |
|
|
148
|
+
| `snow` | Snowfall |
|
|
149
|
+
| `snow_depth` | Snow depth |
|
|
150
|
+
| `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
|
|
151
|
+
| `precipitation_cover` | Percentage of the day with precipitation (%) |
|
|
152
|
+
| `solarradiation` | Solar radiation (W/m2) |
|
|
153
|
+
| `solarenergy` | Solar energy (MJ/m2) |
|
|
154
|
+
| `severe_risk` | Risk score of severe weather |
|
|
155
|
+
| `sunrise` | Sunrise time |
|
|
156
|
+
| `sunset` | Sunset time |
|
|
157
|
+
| `moon_phase` | Moon phase, as a fraction between 0 and 1 |
|
|
158
|
+
|
|
159
|
+
### Hourly Forecast (`ForecastHourlyData`)
|
|
160
|
+
|
|
161
|
+
Only hours later than the current time are included.
|
|
162
|
+
|
|
163
|
+
| Property | Description |
|
|
164
|
+
| -------- | ----------- |
|
|
165
|
+
| `datetime` | Valid date and time (UTC) |
|
|
166
|
+
| `temperature` | Air temperature |
|
|
167
|
+
| `apparent_temperature` | Feels-like temperature |
|
|
168
|
+
| `condition` | Weather condition text |
|
|
169
|
+
| `icon` | Weather condition icon id |
|
|
170
|
+
| `cloud_cover` | Cloud coverage (%) |
|
|
171
|
+
| `dew_point` | Dew point |
|
|
172
|
+
| `humidity` | Humidity (%) |
|
|
173
|
+
| `precipitation` | Precipitation |
|
|
174
|
+
| `precipitation_probability` | Probability of precipitation (%) |
|
|
175
|
+
| `pressure` | Sea level pressure |
|
|
176
|
+
| `uv_index` | UV index |
|
|
177
|
+
| `wind_bearing` | Wind bearing (degrees) |
|
|
178
|
+
| `wind_speed` | Wind speed |
|
|
179
|
+
| `wind_gust_speed` | Wind gust speed |
|
|
180
|
+
| `snow` | Snowfall |
|
|
181
|
+
| `snow_depth` | Snow depth |
|
|
182
|
+
| `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
|
|
183
|
+
| `solarradiation` | Solar radiation (W/m2) |
|
|
184
|
+
| `solarenergy` | Solar energy (MJ/m2) |
|
|
185
|
+
| `severe_risk` | Risk score of severe weather |
|
|
186
|
+
| `visibility` | Visibility |
|
|
62
187
|
|
|
63
188
|
## Languages
|
|
64
189
|
Available languages include: **ar** (Arabic), **bg** (Bulgiarian), **cs** (Czech), **da** (Danish), **de** (German), **el** (Greek Modern), **en** (English), **es** (Spanish), **fa** (Farsi), **fi** (Finnish), **fr** (French), **he** (Hebrew), **hu**, (Hungarian), **it** (Italian), **ja** (Japanese), **ko** (Korean), **nl** (Dutch), **pl** (Polish), **pt** (Portuguese), **sr** (Serbian), **sv** (Swedish), **tr** (Turkish), **uk** (Ukranian), **vi** (Vietnamese) and **zh** (Chinese).
|
|
@@ -99,8 +224,3 @@ We use the Iconset *icons2*, which gives a more detailed description of the cond
|
|
|
99
224
|
| partly-cloudy-night | Cloud cover is greater than 20% cover during night time. |
|
|
100
225
|
| clear-day | Cloud cover is less than 20% cover during day time |
|
|
101
226
|
| clear-night | Cloud cover is less than 20% cover during night time |
|
|
102
|
-
|
|
103
|
-
## TODO
|
|
104
|
-
|
|
105
|
-
- Add all available items to the Data Structure
|
|
106
|
-
- Create `async_test_module.py` in the samples directory
|
pyvisualcrossing-1.0.0/README.md
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# Python Wrapper for Visual Crossing Weather API
|
|
2
|
-
|
|
3
|
-
This Python Wrapper retrives data from the [Visual Crossing](https://www.visualcrossing.com/) API. Visual Crossing has an extensive Weather API for both historical and forecast weather data, and they have a Free Tier API Key which enables up to 1000 calls per day.
|
|
4
|
-
|
|
5
|
-
In order to get started you must create an Account with Visual Crossing and then create an API Key. You do this by accessing [this website](https://www.visualcrossing.com/weather-data-editions) and clicking on the **Free** plan. Then follow the instructions to create and account and store your key in a safe place.
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
Install the module by using this command in a terminal: `pip install pyVisualCrossing`
|
|
10
|
-
|
|
11
|
-
And then see `test_module.py` and `async_test_module.py` for usage examples, both standard and async. (Async example not yet created)
|
|
12
|
-
|
|
13
|
-
## Parameters
|
|
14
|
-
|
|
15
|
-
```python
|
|
16
|
-
# Initialise the module
|
|
17
|
-
vcapi = VisualCrossing(
|
|
18
|
-
api_key,
|
|
19
|
-
latitude,
|
|
20
|
-
longitude,
|
|
21
|
-
days=7,
|
|
22
|
-
language="da"
|
|
23
|
-
)
|
|
24
|
-
````
|
|
25
|
-
|
|
26
|
-
| Parameter | Required | Default | Description |
|
|
27
|
-
| --------- | -------- | ------- | ----------- |
|
|
28
|
-
| `api_key` | Yes | `None` | This is the API Key you signed up for from Visual Crossing. See above for instructions |
|
|
29
|
-
| `latitude` | Yes | `None` | Latitude for the location position |
|
|
30
|
-
| `longitude` | Yes | `None` | Longitude for the location position |
|
|
31
|
-
| `days` | No | `14` | Numbers of days to retrieve forecast for. 14 days means today plus the next 14 days. On the Free plan, this is the maximum number of days |
|
|
32
|
-
| `language` | No | `en` | The language in which text strings should be returned. Se below for list of valid languages. |
|
|
33
|
-
| `session` | No | `None` | A session variable. Only used when using the async function. |
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
For an in-depth description of the Visual Crossing API, go [here](https://www.visualcrossing.com/resources/documentation/weather-api/timeline-weather-api/)
|
|
38
|
-
|
|
39
|
-
## Languages
|
|
40
|
-
Available languages include: **ar** (Arabic), **bg** (Bulgiarian), **cs** (Czech), **da** (Danish), **de** (German), **el** (Greek Modern), **en** (English), **es** (Spanish), **fa** (Farsi), **fi** (Finnish), **fr** (French), **he** (Hebrew), **hu**, (Hungarian), **it** (Italian), **ja** (Japanese), **ko** (Korean), **nl** (Dutch), **pl** (Polish), **pt** (Portuguese), **sr** (Serbian), **sv** (Swedish), **tr** (Turkish), **uk** (Ukranian), **vi** (Vietnamese) and **zh** (Chinese).
|
|
41
|
-
|
|
42
|
-
## Metrics
|
|
43
|
-
All records are returned using the *Metric* unit system. There is no conversion possible at the moment.
|
|
44
|
-
|
|
45
|
-
| Weather variable | Measurement Unit |
|
|
46
|
-
| ----------------------------------- | ------------------------ |
|
|
47
|
-
| Datetime | UTC datetime |
|
|
48
|
-
| Temperature, Heat Index & Wind Chill | Degrees Celcius |
|
|
49
|
-
| Precipitation | Millimeters |
|
|
50
|
-
| snow | Centimeters |
|
|
51
|
-
| Wind & Wind Gust | Kilometers Per Hour |
|
|
52
|
-
| Visibility | Kilometers |
|
|
53
|
-
| Pressure | Millibars (Hectopascals) |
|
|
54
|
-
| Solar Radiation | W/m2 |
|
|
55
|
-
| Solar Energy | MJ/m2 |
|
|
56
|
-
|
|
57
|
-
## Icons
|
|
58
|
-
We use the Iconset *icons2*, which gives a more detailed description of the conditions.
|
|
59
|
-
|
|
60
|
-
| Icon id | Weather Conditions |
|
|
61
|
-
| -------------------- | ---------------------------- |
|
|
62
|
-
| snow | Amount of snow is greater than zero |
|
|
63
|
-
| snow-showers-day | Periods of snow during the day |
|
|
64
|
-
| snow-showers-night | Periods of snow during the night |
|
|
65
|
-
| thunder-rain | Thunderstorms throughout the day or night |
|
|
66
|
-
| thunder-showers-day | Possible thunderstorms throughout the day |
|
|
67
|
-
| thunder-showers-night | Possible thunderstorms throughout the night |
|
|
68
|
-
| rain | Amount of rainfall is greater than zero |
|
|
69
|
-
| showers-day | Rain showers during the day |
|
|
70
|
-
| showers-night | Rain showers during the night |
|
|
71
|
-
| fog | Visibility is low (lower than one kilometer or mile) |
|
|
72
|
-
| wind | Wind speed is high (greater than 30 kph or mph) |
|
|
73
|
-
| cloudy | Cloud cover is greater than 90% cover |
|
|
74
|
-
| partly-cloudy-day | Cloud cover is greater than 20% cover during day time. |
|
|
75
|
-
| partly-cloudy-night | Cloud cover is greater than 20% cover during night time. |
|
|
76
|
-
| clear-day | Cloud cover is less than 20% cover during day time |
|
|
77
|
-
| clear-night | Cloud cover is less than 20% cover during night time |
|
|
78
|
-
|
|
79
|
-
## TODO
|
|
80
|
-
|
|
81
|
-
- Add all available items to the Data Structure
|
|
82
|
-
- Create `async_test_module.py` in the samples directory
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyvisualcrossing-1.0.0 → pyvisualcrossing-1.0.1}/pyVisualCrossing.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|