Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_weather_station_for_location(latitude, longitude, as_object=True):
ranked_stations = eeweather.rank_stations(latitude, longitude)
for i in range(len(ranked_stations)):
try:
ranked_station = ranked_stations.iloc[i]
if as_object:
return WeatherStation.objects.get(weather_station_code=ranked_station.name)
else:
return ranked_station.name
except Exception as e:
logging.error(e)