This script uses the weather restrictions for bat acoutsic surveys per the USFWS Florida Bonneted Bat survey protocol and sends an email notification with the metric ranges and a PASS or FAIL status. For more information on the USFWS protocol, see here. This script uses the National Weather Service API and reads it into a pandas dataframe. That information is summed up as a range of min and max values and sent to the user using the smtplib library. See example provided in this repo.
- Gmail account with 2FA enabled
- Gmail app password (or other client equivalent)
- GitHub account
From: {sender}
To: {receiver}
Subject: Bat Survey Weather Alert YYYY-MM-DD - PASS
Below are the weather metrics:
Temp (F): 65-73
Wind (mph): 2-6
Precip (mm): 0
To use locally, clone the repository on your machine.
git clone https://github.com/bofethe/WeatherTracker.gitNavigate to the .env.example file and add your credentials for your app password and sender address. Rename this file to .env. Create a python 3.11 environment using something like venv or conda and install the libraries listed in the requirements.txt file
Using conda (needs installing)
conda create --name WeatherTracker --file requirements.txt
conda activate WeatherTrackerUsing venv (built-in) to install
- MacOS/Linux
python3.11 -m venv WeatherTracker
source WeatherTracker/bin/activate
pip install -r requirements.txt- Windows Command Prompt
python3.11 -m venv WeatherTracker
WeatherTracker\Scripts\activate
pip install -r requirements.txtNow open the WeatherTracker.py file and update the variable receiveraddr with a comma seperated string containing the email addresses that should recieve the notification.
To use this tool, fork the repository so you can host it in your own GitHub Account or organization. In the repository's main menu, near the top right of the toolbar, drop down fork and select Create A New Fork. Add whatever details you want.
Next, open the WeatherTracker.py file and update the variable receiveraddr with a comma seperated string containing the email addresses that should recieve the notification.
The script is preconfigured for scheduling using a CI pipeline that GitHub provides called GitHub Actions. Navigate to weather.yml file and adjust the cron variable to the time you want to run. Note that the timezone defaults to UTC, so adjust accordingly.
To handle authentication, you must add a secret to avoid hard-coding credentials. Open the repository's Settings page. Under Security, open Actions. Create a repository secrets called APPPW for your email app password, and another called SENDERADDR for your email address.
Once you're done, commit your changes. Then navigate to the Actions tab. Near the top right, select Enable Workflow.
Once you're done collecting data, navigate back to the Actions tab, select Run WeatherTracker, and in the top right next to where it says Filter workflow runs, click the ... and select Disable Workflow.