Belladonna is a project designed to collect weather data (...more in the future). This README will guide you through the steps needed to run the visualise.py
script, which plots temperature, humidity, and pressure data from a CSV file.
I am specifically using a CSV file because I do not yet understand how to interact with a database, though I am trying. In my opinion, learning to write-to, and read-from a CSV might be a good 'stepping-stone' on my way to learning databases. When I say 'database', I am referring to something like MongoDB, which I frequently-note being used, discussed, referenced, etc.
Before running the script, ensure you have the following prerequisites installed:
- Python 3.6 or later
pandas
librarymatplotlib
library
If you do not have Python installed, you can download it from python.org.
- Open your terminal or command prompt.
- Clone the repository from GitHub:
git clone https://github.com/jbx6/belladonna.git
- Navigate to the cloned repository directory:
cd belladonna
To install the necessary Python libraries, run the following command:
pip install pandas matplotlib
Once you have the prerequisites installed, follow these steps to run the visualise.py
script:
- Ensure your data file (
data.csv
) is in the same directory asvisualise.py
. - Open your terminal or command prompt.
- Navigate to the directory containing
visualise.py
anddata.csv
. - Run the script by executing the following command:
python3 visualise.py
This will generate a plot displaying temperature, humidity, and pressure data over time.
The visualise.py
script performs the following steps:
- Load the Data: Reads the weather data from
data.csv
usingpandas
. - Preprocess the Data: Combines the
date
andtime
columns into a singledatetime
column and sets it as the index. - Plot the Data: Creates a plot with three y-axes to display temperature, humidity, and pressure. Important events can be marked on the plot for reference.
- Display the Plot: Shows the plot with proper labels, legends, and formatting.
Ensure your data.csv
file follows this format:
date | time | temperature | humidity | pressure |
---|---|---|---|---|
2024-05-25 | 06:00:00 | 22.5 | 60 | 1012 |
2024-05-25 | 06:10:00 | 22.8 | 59 | 1012 |
... | ... | ... | ... | ... |
The date
and time
columns should be in YYYY-MM-DD
and HH:MM:SS
format, respectively.
You can customize the script to highlight specific events by adjusting the event_datetime
variables. Uncomment and modify the axvline
and text
lines in the script to add vertical lines and labels at the specified event times.
event_datetime = pd.to_datetime('2024-05-27 16:22:12')
# ax1.axvline(event_datetime, color='k', linestyle='--', label='Event 1')
# ax1.text(event_datetime, ax1.get_ylim()[1], 'Event 1', rotation=90, verticalalignment='center', color='k')
This README was written by ChatGPT (with some specific prompting)...