Skip to content

Commit ee7cb7d

Browse files
committed
added usage
1 parent 6dabc98 commit ee7cb7d

File tree

3 files changed

+64
-13
lines changed

3 files changed

+64
-13
lines changed

README.md

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WeatherKit ☀️
22
## What is It?
3-
WeatherKit is a python pacakge that provides a simple interface to get weather data without any API key or any other credentials. It is a simple and easy to use package that provides the current weather data of any location in the world. It can get weather details from address, city, country, or even from the latitude and longitude of the location.
3+
WeatherKit is a python pacakge that provides a simple interface to get weather data without any API key or any other credentials. It is a simple and easy to use package that provides the current weather data of any location in the world. It can get weather details from address, city, country, or latitude and longitude of the location.
44

55
Currently it Provies the following weather details for current time and forecast for 7 days:
66
- Temperature ☀️
@@ -36,8 +36,69 @@ Install the package using the following command:
3636
pip install dist/*.whl
3737
```
3838

39-
## Documentation
40-
The documentation of WeatherKit can be found [here](example.com)
39+
## Usage
40+
### Current Weather
41+
Sample usage providing city name
42+
```python
43+
import weatherkit
44+
NYC = weatherkit.current_weather('New York')
45+
print(NYC.temperature())
46+
# Output: 20.0
47+
print(NYC.temperature(units='imperial'))
48+
# Output: 68.0
49+
print(NYC.humidity())
50+
# Output: 50
51+
print(NYC.weather_code())
52+
# Output: 3
53+
print(NYC.precipitation())
54+
# Output: 0.0
55+
```
56+
Sample usage providing latitude and longitude
57+
58+
```python
59+
import weatherkit
60+
NYC = weatherkit.current_weather(40.7128, -74.0060)
61+
print(NYC.temperature())
62+
# Output: 20.0
63+
print(NYC.temperature(units='imperial'))
64+
# Output: 68.0
65+
print(NYC.humidity())
66+
# Output: 50
67+
print(NYC.weather_code())
68+
# Output: 3
69+
print(NYC.precipitation())
70+
# Output: 0.0
71+
```
72+
### Daily Forecast
73+
Sample usage providing city name
74+
```python
75+
import weatherkit
76+
NYC = weatherkit.daily_forecast('New York')
77+
print(NYC.max_temperature())
78+
# Output: 20.0
79+
print(NYC.max_temperature(units='imperial'))
80+
# Output: 68.0
81+
print(NYC.min_temperature())
82+
# Output: 10.0
83+
print(NYC.max_temperature(day_offset=3))
84+
# Output: 20.0
85+
print(NYC.max_temperature(day_offset=3, units='imperial'))
86+
# Output: 68.0
87+
print(NYC.prediction_sum())
88+
# Output: 0.0
89+
print(NYC.prediction_sum(day_offset=3))
90+
# Output: 3.2
91+
print(NYC.prediction_sum(units='imperial'))
92+
# Output: 0.0 (in Inches)
93+
print(NYC.weather_code())
94+
# Output: 3
95+
print(NYC.weather_code(day_offset=3))
96+
# Output: 3
97+
```
98+
#### Note
99+
- Similar to current weather, daily forecast can also be used by providing latitude and longitude.
100+
101+
- day_offset is the number of days from today for which the forecast is required. day_offset=0 (which is default) will give the forecast for today, day_offset=1 will give the forecast for tomorrow and so on.
41102

42103
## Contributing
43104
Contributions are welcome, and they are greatly appreciated! just fork the repository, make changes and create a pull request.

test/test_current_weather.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,26 @@
33

44
class TestCurrentWeather(unittest.TestCase):
55
def setUp(self):
6-
# Create an instance of current_weather with latitude and longitude
76
self.weather = current_weather(37.7749, -122.4194)
87

98
def test_temperature(self):
10-
# Test getting the current temperature
119
temperature = self.weather.temperature()
1210
self.assertIsInstance(temperature, float)
1311
self.assertGreaterEqual(temperature, -100)
1412
self.assertLessEqual(temperature, 100)
1513

1614
def test_humidity(self):
17-
# Test getting the current humidity
1815
humidity = self.weather.humidity()
1916
self.assertIsInstance(humidity, int)
2017
self.assertGreaterEqual(humidity, 0)
2118
self.assertLessEqual(humidity, 100)
2219

2320
def test_precipitation(self):
24-
# Test getting the current precipitation
2521
precipitation = self.weather.precipitation()
2622
self.assertIsInstance(precipitation, float)
2723
self.assertGreaterEqual(precipitation, 0)
2824

2925
def test_weather_code(self):
30-
# Test getting the current weather code
3126
weather_code = self.weather.weather_code()
3227
self.assertIsInstance(weather_code, int)
3328
self.assertGreaterEqual(weather_code, 0)

test/test_daily_weather.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,26 @@
33

44
class TestDailyWeather(unittest.TestCase):
55
def setUp(self):
6-
# Create an instance of daily_weather with latitude and longitude
76
self.weather = daily_weather(37.7749, -122.4194)
87

98
def test_max_temperature(self):
10-
# Test getting the maximum temperature
119
temperature = self.weather.max_temperature()
1210
self.assertIsInstance(temperature, float)
1311
self.assertGreaterEqual(temperature, -100)
1412
self.assertLessEqual(temperature, 100)
1513

1614
def test_min_temperature(self):
17-
# Test getting the minimum temperature
1815
temperature = self.weather.min_temperature()
1916
self.assertIsInstance(temperature, float)
2017
self.assertGreaterEqual(temperature, -100)
2118
self.assertLessEqual(temperature, 100)
2219

2320
def test_precipitation_sum(self):
24-
# Test getting the precipitation sum
2521
precipitation = self.weather.precipitation_sum()
2622
self.assertIsInstance(precipitation, float)
2723
self.assertGreaterEqual(precipitation, 0)
2824

2925
def test_weather_code(self):
30-
# Test getting the weather code
3126
weather_code = self.weather.weather_code()
3227
self.assertIsInstance(weather_code, int)
3328
self.assertGreaterEqual(weather_code, 0)

0 commit comments

Comments
 (0)