Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

GEP475GROUPINEEDANAP

Views: 1463
Kernel: Python 3 (Anaconda)
#%matplotlib notebook %matplotlib inline import matplotlib.pyplot as plt import numpy as np import pandas as pd data = pd.read_csv('Indoor_21-4-2016 30MIN.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[-5:]
Timestamp Temperature Humidity CO2 Noise Pressure
Timezone : America/Los_Angeles
2016-04-20 22:01:00 1461214860 22.8 57 399 35 1009.2
2016-04-20 22:31:00 1461216660 22.8 57 393 35 1009.2
2016-04-20 23:01:00 1461218460 22.8 57 392 35 1009.2
2016-04-20 23:31:00 1461220260 22.7 57 391 35 1009.1
2016-04-21 00:01:00 1461222060 22.7 57 384 35 1009.0
inside_concentration = data['CO2'] concentration_slope = data['CO2'].diff()/data['Timestamp'].diff() concentration_slope.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f6b97c3bc18>
Image in a Jupyter notebook
concentration_slope = concentration_slope.where(concentration_slope<0, 0) concentration_slope = concentration_slope.where(data['CO2']>450, 0) concentration_slope.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f6ba0050860>
Image in a Jupyter notebook
infiltration_rate = concentration_slope/((inside_concentration - 400.).abs())*3600 infiltration_rate.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f6b97d115c0>
Image in a Jupyter notebook
ax = infiltration_rate.plot() ax.set_ylim((-1,1)) ax.grid() plt.savefig('test.pdf')
Image in a Jupyter notebook
infiltration_rate.describe()
count 2888.000000 mean -0.055188 std 0.308958 min -12.083333 25% -0.036691 50% 0.000000 75% 0.000000 max 0.000000 dtype: float64
infiltration_rate.hist(bins=50)
<matplotlib.axes._subplots.AxesSubplot at 0x7f6b97d11128>
Image in a Jupyter notebook
data['CO2'].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f6b91a7e780>
Image in a Jupyter notebook
time2 = '2016-04-19 12:18:29' time1 = '2016-04-19 12:43:36' data[time2:time1]
Timestamp Temperature Humidity CO2 Noise Pressure
Timezone : America/Los_Angeles
2016-04-19 12:31:00 1461094260 23.1 57 1665 36 1009.5
time2 = '2016-04-19 12:18:29' time1 = '2016-04-19 12:43:36' rise = data['CO2'][time2] - data['CO2'][time1] run = (data['Timestamp'][time2] - data['Timestamp'][time1]) print(data['CO2'][time2]) print(rise) print('run =',run) print('slope =', rise/run) rise / run * 3600 / (data['CO2'][time2]-400)
TypeErrorTraceback (most recent call last) /projects/anaconda3/lib/python3.5/site-packages/pandas/indexes/base.py in get_value(self, series, key) 1916 try: -> 1917 return tslib.get_value_box(s, key) 1918 except IndexError: pandas/tslib.pyx in pandas.tslib.get_value_box (pandas/tslib.c:17748)() pandas/tslib.pyx in pandas.tslib.get_value_box (pandas/tslib.c:17416)() TypeError: 'str' object cannot be interpreted as an integer During handling of the above exception, another exception occurred: KeyErrorTraceback (most recent call last) /projects/anaconda3/lib/python3.5/site-packages/pandas/tseries/index.py in get_value(self, series, key) 1375 try: -> 1376 return _maybe_box(self, Index.get_value(self, series, key), 1377 series, key) /projects/anaconda3/lib/python3.5/site-packages/pandas/indexes/base.py in get_value(self, series, key) 1924 else: -> 1925 raise e1 1926 except Exception: # pragma: no cover /projects/anaconda3/lib/python3.5/site-packages/pandas/indexes/base.py in get_value(self, series, key) 1910 return self._engine.get_value(s, k, -> 1911 tz=getattr(series.dtype, 'tz', None)) 1912 except KeyError as e1: pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3234)() pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:2931)() pandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:11025)() pandas/index.pyx in pandas.index.DatetimeEngine._date_check_type (pandas/index.c:11193)() KeyError: '2016-04-19 12:18:29' During handling of the above exception, another exception occurred: KeyErrorTraceback (most recent call last) pandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:10814)() pandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6527)() pandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6465)() KeyError: 1461068309000000000 During handling of the above exception, another exception occurred: KeyErrorTraceback (most recent call last) /projects/anaconda3/lib/python3.5/site-packages/pandas/tseries/index.py in get_value(self, series, key) 1385 try: -> 1386 return self.get_value_maybe_box(series, key) 1387 except (TypeError, ValueError, KeyError): /projects/anaconda3/lib/python3.5/site-packages/pandas/tseries/index.py in get_value_maybe_box(self, series, key) 1396 values = self._engine.get_value(_values_from_object(series), -> 1397 key, tz=self.tz) 1398 return _maybe_box(self, values, series, key) pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3234)() pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:2931)() pandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:10880)() KeyError: Timestamp('2016-04-19 12:18:29') During handling of the above exception, another exception occurred: KeyErrorTraceback (most recent call last) <ipython-input-10-9bcbc0c0688d> in <module>() 1 time2 = '2016-04-19 12:18:29' 2 time1 = '2016-04-19 12:43:36' ----> 3 rise = data['CO2'][time2] - data['CO2'][time1] 4 run = (data['Timestamp'][time2] - data['Timestamp'][time1]) 5 /projects/anaconda3/lib/python3.5/site-packages/pandas/core/series.py in __getitem__(self, key) 558 def __getitem__(self, key): 559 try: --> 560 result = self.index.get_value(self, key) 561 562 if not lib.isscalar(result): /projects/anaconda3/lib/python3.5/site-packages/pandas/tseries/index.py in get_value(self, series, key) 1386 return self.get_value_maybe_box(series, key) 1387 except (TypeError, ValueError, KeyError): -> 1388 raise KeyError(key) 1389 1390 def get_value_maybe_box(self, series, key): KeyError: '2016-04-19 12:18:29'