How to use the eeweather.rank_stations function in eeweather

To help you get started, we’ve selected a few eeweather examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opentaps / opentaps_seas / opentaps_seas / core / utils.py View on Github external
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)