Numpy (pronounced "num-pee") is a popular Python library for numerical computations. It stands for "Numerical Python." Numpy is a powerful tool for working with arrays, matrices, and mathematical functions, making it easier to perform complex mathematical and data manipulation tasks in Python.
Documentation for Numpy
Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.
If you haven't installed Matplotlib, do that first. From the terminal:
sudo apt install python3-matplotlib
Choose one the sensors from the previous exercises (Temp and Humidity or Laser Distance). Get the sensor hooked up and working.
2. Use the code example numpy_temp_array.py to capture some sensor data in a Numpy array
OR
this code for the laser_distance_sensor numpy_laser_distance.py
3. Try analyzing aspects of the data using. Can you figure out how to:
Display the min and max sensor values (these don't actually require numpy)
Display the median value using print(np.median(your_data))
Display the mean (average) value using print(np.mean(your_data))
4. Try graphing the output, live, using MatPlotlib
See how MatPlotLib works, start with matplotlib_random_graph.py which graphs random data on a line graph (use cntl + W to quit)
Then use the matplotlib_sensor.py example to graph a temperature sensor over time OR the matplotlib_distance.py example if you are using the laser distance sensor.
Finally, can you add humidity to the graph?
Challenges:
Look at the MatPlotlib documentation: Documentation for Matplotlib Can you do any of the following?
Create a different-looking graph.
Create two or more graphs in one window.