How to use the eeweather.stations.get_isd_station_metadata 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 / scripts / import_weather_stations.py View on Github external
station_name = row[2]
                country = row[3]
                state = row[4]
                icao = row[5]
                latitude = parse_float(row[6])
                longitude = parse_float(row[7])
                elevation = parse_float(row[8])
                elevation_uom_id = 'length_m'

                weather_station_id = 'USAF_' + usaf_id
                weather_station_code = usaf_id

                # note ensure eemeter has metadata for it
                # else fetching data would fail anyway ..
                try:
                    get_isd_station_metadata(usaf_id)
                except Exception:
                    print('-- IGNORE station without eemeter metadata: ', usaf_id)
                    try:
                        c.execute("""DELETE FROM core_weather_station where weather_station_code = %s""",
                                  [weather_station_code]
                                  )
                    except Exception:
                        pass
                    continue

                try:
                    c.execute("""INSERT INTO core_weather_station (weather_station_id, weather_station_code,
                        station_name, country, state, call, latitude, longitude, elevation, elevation_uom_id)
                        VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
                              [weather_station_id, weather_station_code,
                               station_name, country, state, icao, latitude, longitude, elevation, elevation_uom_id]