Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
476 views
Kernel: Python 3 (Anaconda)

ETC.CO2.Data ETC.CO_2.Data

from pint import UnitRegistry u = UnitRegistry()
%matplotlib inline import matplotlib.pyplot as plt import numpy as np import pandas as pd data = pd.read_csv('Indoor_3-3-2016.csv', skiprows=3, # ignore the first 3 rows of data sep=';', # semicolon is used to separate data values index_col=1, # use column 1 as the dates to index the data parse_dates=True) # convert the date string into a date object data.head()
data['CO2'].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f55b17dc400>
Image in a Jupyter notebook
import bokeh.plotting as bkp bkp.output_notebook() p = bkp.figure(x_axis_type='datetime') p.line(y=data['CO2'], x=data.index) bkp.show(p)
MIME type unknown not supported
time2 = '2016-02-22 09:15:00' time1 = '2016-02-22 08:45:00' rise = data['CO2'][time2] - data['CO2'][time1] run = (data['Timestamp'][time2] - data['Timestamp'][time1]) rise/run
time2 = '2016-02-23 09:15:00' time1 = '2016-02-23 08:45:00' rise = data['CO2'][time2] - data['CO2'][time1] run = (data['Timestamp'][time2] - data['Timestamp'][time1]) rise/run
def process_data(begin, end, data, plot=False): x = data['Timestamp'][begin:end] x = x - x[0] y = data['CO2'][begin:end] fit = np.polyfit(x,y,1) room_ppm_per_second = fit[0] room_ppm_per_minute = room_ppm_per_second * 60 ppm_per_student_per_minute = 0.176 num_students = room_ppm_per_minute / ppm_per_student_per_minute if plot: yfit = np.polyval(fit, x) plt.plot(x, y) plt.plot(x, yfit) print('Start time = {}'.format(begin)) print('End time = {}'.format(end)) print('Carbon dioxide rate of increase {:.2f} ppm per minute'.format(room_ppm_per_minute)) print('Estimated number of students: {:.0f}'.format(num_students)) print()

Class times for Spring 2016 for ENSP 430 and 437

class_starts = ( ('2016-02-23 10:00', '2016-02-23 12:00'), ('2016-02-24 14:00', '2016-02-24 17:50'), ('2016-02-25 10:00', '2016-02-25 12:00') ) for begin, end in class_starts: process_data(begin, end, data, plot=True) plt.show()
data.head()
data.head()
data.plot()