Skip to content

Commit

Permalink
Merge pull request #1 from VITObelgium/fd5965-meteo-error
Browse files Browse the repository at this point in the history
fix(FD-5965): empty meteo property check is added to get meteo function
  • Loading branch information
omerjava authored May 13, 2024
2 parents db9d73e + c077333 commit 9f650bf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pywig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ def get_meteo(self, field_id: str, key: str, start_date: datetime.date = None, e
"""Retrieve the meteo statistics for the selected field
:param field_id: ID of the field for which to retrieve the meteo statistics
:param key: Key that represents what type of meteo information should be fetched. For fields inside of Belgium, the supported keys are (AVERAGE_TEMPERATURE, MAXIMUM_TEMPERATURE, MINIMUM_TEMPERATURE, RAINFALL). For fields outside of Belgium, the supported keys are (TEMPERATURE, RAINFALL).
:param key: Key that represents what type of meteo information should be fetched.
For fields inside of Belgium, the supported keys are (AVERAGE_TEMPERATURE, MAXIMUM_TEMPERATURE, MINIMUM_TEMPERATURE, RAINFALL).
For fields outside of Belgium, the supported keys are (TEMPERATURE, RAINFALL).
:param start_date: The date from where to retrieve the meteo data
:param end_date: The end date for the meteo data retrieval
:return: A list of MeteoStat entries
:rtype: List
"""
field = self.get_field_details(field_id)
print(field)
if field.meteo and key.lower() in field.meteo:
if field.meteo and key.lower() in field.meteo and len(field.meteo[key.lower()]) > 0:
meteo = list(map(lambda x: MeteoStat(date=x['date'], value=x['value']), field.meteo[key.lower()]))
if start_date:
meteo = [x for x in meteo if start_date <= datetime.datetime.strptime(x.date, "%Y-%m-%d").date()]
Expand Down

0 comments on commit 9f650bf

Please sign in to comment.