Skip to content

Commit

Permalink
Fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
csparpa committed Feb 24, 2021
2 parents 27b5e74 + 5ee75b3 commit 0474b61
Show file tree
Hide file tree
Showing 77 changed files with 1,840 additions and 525 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ tests/proxy/.tox/*
.cache
.eggs/
htmlcov/*
venv

9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: python
python:
- "3.7"
- "3.8"
- "3.9-dev"
script: tox
after_success:
- coveralls
Expand Down Expand Up @@ -34,13 +35,17 @@ jobs:
script: bash tests/local_installation_test.sh
- <<: *local_installation_test
python: "3.8"
- <<: *local_installation_test
python: "3.9-dev"

- &coverage
stage: "Coverage"
python: "3.7"
script: coverage run --rcfile=.coveragerc setup.py test -s tests.unit
- <<: *coverage
python: "3.8"
- <<: *coverage
python: "3.9-dev"

- stage: "Build docs"
script: cd sphinx && make clean && make html
Expand All @@ -51,6 +56,8 @@ jobs:
script: bash deploy/deploy_to_pypi.sh
- <<: *deploy_to_pypi
python: "3.8"
- <<: *deploy_to_pypi
python: "3.9-dev"

- &pypi_installation_test
stage: "PyPI Installation Test"
Expand All @@ -59,3 +66,5 @@ jobs:
script: bash tests/pypi_installation_test.sh
- <<: *pypi_installation_test
python: "3.8"
- <<: *pypi_installation_test
python: "3.9-dev"
7 changes: 7 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ Contributors will be shown in alphabetical order

Code
----
* [ahertz](https://github.com/ahertz)
* [alechewitt](https://github.com/alechewitt)
* [camponez](https://github.com/camponez)
* [Darumin](https://github.com/Darumin)
* [dev-iks](https://github.com/dev-iks)
* [dphildebrandt](https://github.com/dphildebrandt)
* [dstmar](https://github.com/dstmar)
* [edenhaus](https://github.com/edenhaus)
* [eumiro](https://github.com/eumiro)
* [ggstuart](https://github.com/ggstuart)
* [irahorecka](https://github.com/irahorecka)
* [jwmelvin](https://github.com/jwmelvin)
* [lardconcepts](https://github.com/lardconcepts)
* [liato](https://github.com/liato)
* [LukasBoersma](https://github.com/LukasBoersma)
* [MatthiasLohr](https://github.com/MatthiasLohr)
* [Misiu](https://github.com/Misiu)
* [Noid](https://github.com/n0id)
* [titilambert](https://github.com/titilambert)
Expand All @@ -26,9 +30,11 @@ Code

Docs
----
* [Crozzers](https://github.com/Crozzers)
* [EJEP](https://github.com/EJEP)
* [Franzqat](https://github.com/franzqat)
* [Harmon758](https://github.com/Harmon758)
* [joe-meyer](https://github.com/joe-meyer)

Testing
-------
Expand All @@ -40,6 +46,7 @@ Testing
Packaging and Distribution
--------------------------
* [Diapente](https://github.com/Diapente)
* [onkelbeh](https://github.com/onkelbeh)
* [Simone-Zabberoni](https://github.com/Simone-Zabberoni)

Wiki
Expand Down
322 changes: 177 additions & 145 deletions Pipfile.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ With PyOWM you can integrate into your code any of the following OpenWeatherMap
- **Stations API v3.0**, allowing to create and manage meteostation and publish local weather measurements
- **Weather Alerts API v3.0**, allowing to set triggers on weather conditions and areas and poll for spawned alerts
- **Image tiles** for several map layers provided by OWM
- **Geocoding API v1.0** allowing to perform direct/reverse geocoding


## In case of trouble...
Please **read the [FAQ](https://pyowm.readthedocs.io/en/latest/v3/faq.html)** before filing a new issue on GitHub! There are many common issues, therefore a fix for your issue might come easier than you think

## Get started

Expand Down Expand Up @@ -107,11 +112,6 @@ The library software API documentation is available on [Read the Docs](https://p
The [Code recipes](https://pyowm.readthedocs.io/en/latest/v3/code-recipes.html) section comes in handy!


## Help - PyOWM is giving me errors!
Please read the [FAQ](https://pyowm.readthedocs.io/en/latest/v3/faq.html) section of the documentation before filing a new issue on GitHub!

There are many common issues, therefore a fix for your issue might come easier than you think

## Community & Contributing

Here are [some cool projects](https://github.com/csparpa/pyowm/wiki/Community-Projects-using-PyOWM) that use PyOWM
Expand Down
30 changes: 17 additions & 13 deletions pyowm/agroapi10/agro_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ def create_polygon(self, geopolygon, name=None):
"""
assert geopolygon is not None
assert isinstance(geopolygon, GeoPolygon)
data = dict()
data['geo_json'] = {
"type": "Feature",
"properties": {},
"geometry": geopolygon.to_dict()
data = {
'geo_json': {
"type": "Feature",
"properties": {},
"geometry": geopolygon.to_dict(),
}
}

if name is not None:
data['name'] = name
status, payload = self.http_client.post(
Expand Down Expand Up @@ -144,12 +146,14 @@ def soil_data(self, polygon):
params={'appid': self.API_key,
'polyid': polyd},
headers={'Content-Type': 'application/json'})
the_dict = dict()
the_dict['reference_time'] = data['dt']
the_dict['surface_temp'] = data['t0']
the_dict['ten_cm_temp'] = data['t10']
the_dict['moisture'] = data['moisture']
the_dict['polygon_id'] = polyd
the_dict = {
'reference_time': data['dt'],
'surface_temp': data['t0'],
'ten_cm_temp': data['t10'],
'moisture': data['moisture'],
'polygon_id': polyd,
}

return Soil.from_dict(the_dict)

# Satellite Imagery subset methods
Expand Down Expand Up @@ -271,7 +275,7 @@ def download_satellite_image(self, metaimage, x=None, y=None, zoom=None, palette
params = dict(paletteid=palette)
else:
palette = PaletteEnum.GREEN
params = dict()
params = {}
# polygon PNG
if isinstance(metaimage, MetaPNGImage):
prepared_url = metaimage.url
Expand Down Expand Up @@ -309,7 +313,7 @@ def stats_for_satellite_image(self, metaimage):
:type metaimage: a `pyowm.agroapi10.imagery.MetaImage` subtype
:return: dict
"""
if metaimage.preset != PresetEnum.EVI and metaimage.preset != PresetEnum.NDVI:
if metaimage.preset not in [PresetEnum.EVI, PresetEnum.NDVI]:
raise ValueError("Unsupported image preset: should be EVI or NDVI")
if metaimage.stats_url is None:
raise ValueError("URL for image statistics is not defined")
Expand Down
10 changes: 5 additions & 5 deletions pyowm/agroapi10/imagery.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ def __init__(self, url, preset, satellite_name, acquisition_time,
assert isinstance(acquisition_time, int)
assert acquisition_time >= 0, 'acquisition_time cannot be negative'
self._acquisition_time = acquisition_time
assert isinstance(valid_data_percentage, float) or isinstance(valid_data_percentage, int)
assert isinstance(valid_data_percentage, (float, int))
assert valid_data_percentage >= 0., 'valid_data_percentage cannot be negative'
self.valid_data_percentage = valid_data_percentage
assert isinstance(cloud_coverage_percentage, float) or isinstance(cloud_coverage_percentage, int)
assert isinstance(cloud_coverage_percentage, (float, int))
assert cloud_coverage_percentage >= 0., 'cloud_coverage_percentage cannot be negative'
self.cloud_coverage_percentage = cloud_coverage_percentage
assert isinstance(sun_azimuth, float) or isinstance(sun_azimuth, int)
assert isinstance(sun_azimuth, (float, int))
assert sun_azimuth >= 0. and sun_azimuth <= 360., 'sun_azimuth must be between 0 and 360 degrees'
self.sun_azimuth = sun_azimuth
assert isinstance(sun_elevation, float) or isinstance(sun_elevation, int)
assert isinstance(sun_elevation, (float, int))
assert sun_elevation >= 0. and sun_elevation <= 90., 'sun_elevation must be between 0 and 90 degrees'
self.sun_elevation = sun_elevation
self.polygon_id = polygon_id
Expand Down Expand Up @@ -122,7 +122,7 @@ class SatelliteImage:
def __init__(self, metadata, data, downloaded_on=None, palette=None):
assert isinstance(metadata, MetaImage)
self.metadata = metadata
assert isinstance(data, Image) or isinstance(data, Tile)
assert isinstance(data, (Image, Tile))
self.data = data
if downloaded_on is not None:
assert isinstance(downloaded_on, int)
Expand Down
2 changes: 1 addition & 1 deletion pyowm/agroapi10/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, id, name=None, geopolygon=None, center=None, area=None, user_
if center is not None:
assert isinstance(center, GeoPoint), 'Polygon center must be a valid geopoint type'
if area is not None:
assert isinstance(area, float) or isinstance(area, int), 'Area must be a numeric type'
assert isinstance(area, (float, int)), 'Area must be a numeric type'
assert area >= 0, 'Area must not be negative'
self.id = id
self.name = name
Expand Down
4 changes: 2 additions & 2 deletions pyowm/agroapi10/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, polygon_id, list_of_dict, query_timestamp):
self.query_timestamp = query_timestamp

# parse raw data
result = list()
result = []
for the_dict in list_of_dict:
# common metadata
acquisition_time = the_dict.get('dt', None)
Expand Down Expand Up @@ -180,7 +180,7 @@ def with_img_type(self, image_type):

def with_preset(self, preset):
"""
Returns the seach results having the specified preset
Returns the search results having the specified preset
:param preset: the desired image preset (valid values are provided by the
`pyowm.agroapi10.enums.PresetEnum` enum)
Expand Down
6 changes: 3 additions & 3 deletions pyowm/agroapi10/soil.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def __init__(self, reference_time, surface_temp, ten_cm_temp, moisture, polygon_
raise ValueError("reference_time must be greater than 0")
self._reference_time = reference_time
assert surface_temp is not None
assert isinstance(surface_temp, float) or isinstance(surface_temp, int), 'surface_temp must be a number'
assert isinstance(surface_temp, (float, int)), 'surface_temp must be a number'
self._surface_temp = surface_temp
assert ten_cm_temp is not None
assert isinstance(ten_cm_temp, float) or isinstance(ten_cm_temp, int), 'ten_cm_temp must be a number'
assert isinstance(ten_cm_temp, (float, int)), 'ten_cm_temp must be a number'
self._ten_cm_temp = ten_cm_temp
assert moisture is not None
assert isinstance(moisture, float) or isinstance(moisture, int), 'moisture must be a number'
assert isinstance(moisture, (float, int)), 'moisture must be a number'
if moisture < 0.:
raise ValueError("moisture must be greater than 0")
self.moisture = moisture
Expand Down
41 changes: 39 additions & 2 deletions pyowm/airpollutionapi30/airpollution_client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyowm.airpollutionapi30.uris import CO_INDEX_URL, OZONE_URL, NO2_INDEX_URL, SO2_INDEX_URL
from pyowm.airpollutionapi30.uris import CO_INDEX_URL, OZONE_URL, NO2_INDEX_URL, SO2_INDEX_URL, AIR_POLLUTION_URL, \
AIR_POLLUTION_FORECAST_URL, AIR_POLLUTION_HISTORY_URL
from pyowm.utils import formatting


Expand Down Expand Up @@ -152,6 +153,42 @@ def get_so2(self, params_dict):
_, json_data = self._client.get_json(uri)
return json_data

def get_air_pollution(self, params_dict):
"""
Invokes the new AirPollution API endpoint
:param params_dict: dict of parameters
:returns: a string containing raw JSON data
:raises: *ValueError*, *APIRequestError*
"""
_, json_data = self._client.get_json(AIR_POLLUTION_URL, params=params_dict)
return json_data

def get_forecast_air_pollution(self, params_dict):
"""
Invokes the new AirPollution API forecast endpoint
:param params_dict: dict of parameters
:returns: a string containing raw JSON data
:raises: *ValueError*, *APIRequestError*
"""
_, json_data = self._client.get_json(AIR_POLLUTION_FORECAST_URL, params=params_dict)
return json_data

def get_historical_air_pollution(self, params_dict):
"""
Invokes the new AirPollution API history endpoint
:param params_dict: dict of parameters
:returns: a string containing raw JSON data
:raises: *ValueError*, *APIRequestError*
"""
_, json_data = self._client.get_json(AIR_POLLUTION_HISTORY_URL, params=params_dict)
return json_data

def __repr__(self):
return "<%s.%s - httpclient=%s>" % \
(__name__, self.__class__.__name__, str(self._client))
(__name__, self.__class__.__name__, str(self._client))
Loading

0 comments on commit 0474b61

Please sign in to comment.