Skip to main content

API Wrapper for the Ambient Weather Station API with meteorological units and pandas functionality as well

Project description

Ambient Weather Station API Wrapper

There are a couple of great packages that do a great job but this package introduces units. It also serves as a side-project for me. ☺️

This is currently a work in progress to get it in a package and with the proper tests and CI.

Units

Units are set for these fields using the pint python library:

  • windspeedmph - mph
  • windgustmph - mph
  • maxdailygust - mph
  • tempf - degF
  • baromrelin - Hg
  • baromabsin - Hg
  • tempinf - degF
  • hourlyrainin - inches
  • dailyrainin - inches
  • monthlyrainin - inches
  • yearlyrainin - inches
  • feelsLike - degF
  • dewPoint - degF
  • winddir - degrees
  • winddir_avg10m - degrees
  • humidity - percent
  • humidityin - percent

Setup the API object

from ambient_wx import AmbientApi
api_key = "123"
app_key = "456"
api = AmbientApi(api_key, app_key)

Get Devices

from ambient_wx import WxDeviceCollection
devices = WxDeviceCollection(api)
devices.get_devices()
device = devices.devices[0] # first device
print(device.mac_addr)

Get Device Obervations

from ambient_wx import WxObservationCollection
# with a device object
obs = WxObservationCollection(api, device=device)

# or with a known device mac addr to skip an api call for a device
obs = WxObservationCollection(api, mac_addr="some_mac_addr")

# get the last 5 observations this populates obs.data as a 
# list of WxObservation objects
obs.get_observations(limit=5)

# iterate through observations
for o in obs.data:
    print(o.tempf, o.winddir, o.humidity)

Get data for an end date

obs = WxObservationCollection(api, device)
obs.get_observations(end_date=datetime(2024, 4, 25))

for o in obs.data:
    print(o.tempf, o.winddir, o.humidity)

Perform Unit Conversions

# convert deg F to deg C
degc = obs.data[0].tempf.to('degC') 
print(degc)

Create pandas Dataframe from Observations

df = obs.to_dataframe()
print(df)

Write csv from Observations

obs.write_csv("/some_path/my_observations.csv")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ambient_wx-0.1.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

ambient_wx-0.1.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file ambient_wx-0.1.1.tar.gz.

File metadata

  • Download URL: ambient_wx-0.1.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.4.0

File hashes

Hashes for ambient_wx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 222bcf72611ba0a4f3a7e4df2d533f1aa6edd77d946c7ca485bc7ee500201701
MD5 e6269970a4cf86f6a3fa451bce9c6f1d
BLAKE2b-256 87f89c4076d32c5c771387f2dad8fb224e8c7009bc663dba28218deba53dc0fb

See more details on using hashes here.

File details

Details for the file ambient_wx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ambient_wx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.4.0

File hashes

Hashes for ambient_wx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 290d755ccd7314621c2980349a3e1a9601b39dbe8e576077dadd71a1d423fbb4
MD5 764f52536b24aa95e42063c15f9ea9a6
BLAKE2b-256 5792638f5f5487b256e5a5a2495271ff6684b8d454a97d87b7e8a43b7641568c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page