No project description provided
Project description
Weather_API_MASI
Weather_API_MASI is a Python library for retrieving hourly weather and AQI (Air Quality Index) data.
Output/data is given in csv files.
This is a beta version of the Python API for Scraping Weather and Air Quality Data by Location and Date. Please contact masilab@list.vanderbilt.edu for any questions.
Installation
Use the package manager pip to install Weather_API_MASI.
pip install Weather-API-MASI
Usage
from Weather_API_MASI import Weather
'''
There are two required parameters (city name and a start date in YYYY-MM-DD format).
The optional parameters are the end date, a boolean value representing if you'd like a visualization of data availability, and cache configurations.
Before creating any objects, a .env file with NOAA's API (AIRNOW_API_KEY="") and Nominatim's user agent must be created in the root directory (NOMINATIM_USER_AGENT="").
cache_config, if provided, must be in a dictionary format with keys being "cache_dir", "max_age_days", "max_cache_size_gb", and "compression".
Here is an example:
cache_config = {
"cache_dir": r"C:\Users\Jane Doe\Desktop\weatherCache",
"max_age_days": 0.01,
"max_cache_size_gb": 10,
"compression": "bz2"
}
'''
obj1 = Weather("2025-02-20", "nashville")
obj2 = Weather("2023-11-23", "los angeles", "2023-12-23")
obj3 = Weather("2023-01-02", "philadelphia", "2024-02-18", True)
obj4 = Weather("2023-01-02", "philadelphia", "2024-02-18", True, cache_config)
# These methods can be called on any obj
obj1.generate_hourly_data() # A CSV file containing hourly data for the start date will be created.
obj1.generate_yearly_hourly_data() # "A CSV file containing hourly data for the start date's year will be created.
obj1.generate_AQI_data() # A CSV file containing AQI data for the start date will be created.
obj1.get_data_availability() # A visualization of data availability will be created as a data_avail.png
# This method can be called if an end date is provided
obj2.generate_hourly_data_range() # A CSV file containing hourly data between the start and end dates will be created.
# This is a static method, so it can be run on the Weather class
Weather.clear_cache(cache_config["cache_dir"]) # All cached data in provided cache location will be cleared.
Weather.clear_cache() # All cached data in the default location (~/.weather_cache) will be cleared
CLI Command
You can use command line interface (CLI) for this package. Weather-API-MASI {city} {start date} --endDate {end date} --v {boolean} --cache-dir {file location} --max-cache-age {number of days} --max-cache-size {number of gigabytes} end date is optional.
This CLI command will provide AQI data as well as hourly data on a single day and an entire year. Depending on the third optional parameter, hourly data in a time range will also be provided. cd
Weather-API-MASI nashville 2025-02-20
Weather-API-MASI "los angeles" 2023-11-23 --endDate 2023-12-23 --v True
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file weather_api_masi-0.5.tar.gz.
File metadata
- Download URL: weather_api_masi-0.5.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e541e6b15bd0f43637a2f6cc0646307697e935349ed1c1722f1915d18a64f7fc
|
|
| MD5 |
06b77d0fbdc18341352972c5fe194a87
|
|
| BLAKE2b-256 |
cf7200adc09f8a6f9f82b34cbcd7cfbf4d3b5f6a8562acaa6f6457eb56ffd7a6
|
File details
Details for the file weather_api_masi-0.5-py3-none-any.whl.
File metadata
- Download URL: weather_api_masi-0.5-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37d36114a7152d8a66cbd97ad8b26b78ddf94350e5aa83a001c9d5245b62e12a
|
|
| MD5 |
752cdd09d639658a3df5646e5cc52393
|
|
| BLAKE2b-256 |
f4b3ec41299870c28befdf39b930c78afbae8f3747f1b0ce974e23d839a28a34
|