.py
files containing your work. (If you upload a screenshot or other file format, you won't get credit.)This homework assignment must be submitted in Gradescope by Noon central time on Tuesday 5 April 2022.
Collaboration is prohibited, and you may only access resources (books, online, etc.) listed below.
These things might be helpful while working on the problems. Remember that for worksheets, we don't strictly limit what resources you can consult, so these are only suggestions.
This homework assignment has one problem. The grading breakdown is:
Points | Item |
---|---|
2 | Autograder |
4 | Problem 2 |
6 | Total |
The part marked "autograder" reflects points assigned to your submission based on some simple automated checks for Python syntax, etc.. The result of these checks is shown immediately after you submit.
Ask your instructor or TA a question by email, in office hours, or on discord.
This problem is about the temperature in a room full of computers used for scientific calculations. The room is cooled by an air conditioning (A/C) unit. Imagine you suspect the A/C has insufficient capacity for the room, but only when the computers have sustained high utilization and the outside air temperature is very high (e.g. mid-summer). In general, computers emit more heat when the CPU utilization is high.
Use matplotlib to make a visualization of the computer room air temperature and the outside air temperature on the same set of axes. This is the sort of graph you might use to investigate your suspicions about cooling capacity.
The data you need for this is available in two files:
timestamp
(the time in seconds since midnight on 1 January 1970 GMT) and temp
which holds the room temperature in Fahrenheit. This file is large, because measurements are taken every minute.timestamp
(as above) and temp
which holds the outside air temperature. This file is small, because the air temperature is only recorded once per hour.Your script should be called hwk11.py
, and should make a plot with the following characteristics:
Here's a hand sketch showing the overall design of the intended plot. It doesn't show the actual data.
Then, once you've seen the actual plot, answer these questions in comments in your file:
plt.plot()
twice, that's what will happen.import csv
import matplotlib.pyplot as plt
# Even though both files have a "timestamp" column, there are a different number of rows in each file.
# Make two separate lists for the timestamps in each file so that the indoor temperature readings match up
# with the indoor timestamps (and vice versa for outdoors).
indoor_time = []
indoor_temp = []
outdoor_time = []
outdoor_temp = []
# Open both files (handy context manager notation here!)
with open("roomtemp.csv", "r") as file1, open("weather.csv", "r") as file2:
# Make a reader for each file
rdr1 = csv.reader(file1)
rdr2 = csv.reader(file2)
# Skip the header row (first row) for both files
next(rdr1)
next(rdr2)
for row in rdr1: # Convert to floats, otherwise we'll get strings (which will mess up our plot)
indoor_time.append(float(row[0]))
indoor_temp.append(float(row[1]))
for row in rdr2:
outdoor_time.append(float(row[0]))
outdoor_temp.append(float(row[1]))
# Make the plot wide so it's easier to read
plt.figure(figsize = (15,5))
plt.plot(indoor_time, indoor_temp, c="blue", label="room")
plt.plot(outdoor_time, outdoor_temp, c="red", label="outside")
plt.ylabel("Temp (F)")
plt.title("Computer room and outside air temps")
plt.legend()
plt.show()
Q: Do you see any sign that the room temperature sensor might be malfunctioning? If so, where?
A: There are some days where the room temperature dips down to around 70F and then oscillates back and forth to another temperature quickly. It is unlikely that the room temperature would change so quickly to exact temperatures, so there is likely some kind of fault.
Q: Do you think this plot can be used to draw a conclusion about the original question---whether the room has enough A/C capacity? If not, what more information would you want?
A: In order to draw conclusions, we might want some of the following pieces of information: