Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

GEP475GROUPINEEDANAP

Views: 1461
Kernel: Python 3 (Anaconda)
import pandas as pd import numpy as np
column_names = ['Time', 'ppm/min'] In= pd.read_csv('../../DataFiles/Netatmo2016_2017CO2ppm.csv', parse_dates=True, index_col=0, names = column_names) In.head()
ppm/min
Time
2016-02-19 13:26:00 NaN
2016-02-19 13:27:00 718.0
2016-02-19 13:27:00 NaN
2016-02-19 13:31:00 337.0
2016-02-19 13:36:00 332.0
%matplotlib inline In.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f064b91e940>
Image in a Jupyter notebook
df1 = In
df1['Outsidepmm'] = 400
df1.describe()
ppm/min Outsidepmm
count 100985.000000 100991.0
mean 547.646878 400.0
std 304.511307 0.0
min 201.000000 400.0
25% 362.000000 400.0
50% 438.000000 400.0
75% 615.000000 400.0
max 2777.000000 400.0
df1['Infiltration'] = (df1['ppm/min']*41000)/df1['Outsidepmm']
df1.head()
ppm/min Outsidepmm Infiltration
Time
2016-02-19 13:26:00 NaN 400 NaN
2016-02-19 13:27:00 718.0 400 73595.0
2016-02-19 13:27:00 NaN 400 NaN
2016-02-19 13:31:00 337.0 400 34542.5
2016-02-19 13:36:00 332.0 400 34030.0
PPM = pd.read_csv('Netatmo2016_2017CO2ppm.csv', parse_dates=True, index_col=1)
%matplotlib inline PPM['ppm'].plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7fcc39a1ada0>
Image in a Jupyter notebook
df3 = PPM df3.head(5)
Unnamed: 0 ppm
Time
2016-02-19 13:26:00 0 NaN
2016-02-19 13:27:00 1 718.0
2016-02-19 13:27:00 2 NaN
2016-02-19 13:31:00 3 337.0
2016-02-19 13:36:00 4 332.0
delta_CO2 = df3['ppm'].diff(1) df3['Time'] = df3.index delta_time = df3['Time'].diff(1) / np.timedelta64(1,'m')
df3['Slope'] = delta_CO2 / delta_time
df3.head(5)
Unnamed: 0 ppm Time Slope
Time
2016-02-19 13:26:00 0 NaN 2016-02-19 13:26:00 NaN
2016-02-19 13:27:00 1 718.0 2016-02-19 13:27:00 NaN
2016-02-19 13:27:00 2 NaN 2016-02-19 13:27:00 NaN
2016-02-19 13:31:00 3 337.0 2016-02-19 13:31:00 NaN
2016-02-19 13:36:00 4 332.0 2016-02-19 13:36:00 -1.0
slope = delta_CO2 / delta_time
%matplotlib df3['Slope'].plot()
Using matplotlib backend: Qt5Agg
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) <ipython-input-16-173c82f79985> in <module>() 1 get_ipython().run_line_magic('matplotlib', '') ----> 2 df3['Slope'].plot() /ext/anaconda3/lib/python3.5/site-packages/pandas/plotting/_core.py in __call__(self, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds) 2451 colormap=colormap, table=table, yerr=yerr, 2452 xerr=xerr, label=label, secondary_y=secondary_y, -> 2453 **kwds) 2454 __call__.__doc__ = plot_series.__doc__ 2455 /ext/anaconda3/lib/python3.5/site-packages/pandas/plotting/_core.py in plot_series(data, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds) 1892 yerr=yerr, xerr=xerr, 1893 label=label, secondary_y=secondary_y, -> 1894 **kwds) 1895 1896 /ext/anaconda3/lib/python3.5/site-packages/pandas/plotting/_core.py in _plot(data, x, y, subplots, ax, kind, **kwds) 1692 plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds) 1693 -> 1694 plot_obj.generate() 1695 plot_obj.draw() 1696 return plot_obj.result /ext/anaconda3/lib/python3.5/site-packages/pandas/plotting/_core.py in generate(self) 242 self._args_adjust() 243 self._compute_plot_data() --> 244 self._setup_subplots() 245 self._make_plot() 246 self._add_table() /ext/anaconda3/lib/python3.5/site-packages/pandas/plotting/_core.py in _setup_subplots(self) 293 else: 294 if self.ax is None: --> 295 fig = self.plt.figure(figsize=self.figsize) 296 axes = fig.add_subplot(111) 297 else: /ext/anaconda3/lib/python3.5/site-packages/matplotlib/pyplot.py in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, **kwargs) 533 frameon=frameon, 534 FigureClass=FigureClass, --> 535 **kwargs) 536 537 if figLabel: /ext/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5agg.py in new_figure_manager(num, *args, **kwargs) 42 FigureClass = kwargs.pop('FigureClass', Figure) 43 thisFig = FigureClass(*args, **kwargs) ---> 44 return new_figure_manager_given_figure(num, thisFig) 45 46 /ext/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5agg.py in new_figure_manager_given_figure(num, figure) 49 Create a new figure manager instance for the given figure. 50 """ ---> 51 canvas = FigureCanvasQTAgg(figure) 52 return FigureManagerQT(canvas, num) 53 /ext/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5agg.py in __init__(self, figure) 240 if DEBUG: 241 print('FigureCanvasQtAgg: ', figure) --> 242 super(FigureCanvasQTAgg, self).__init__(figure=figure) 243 self._drawRect = None 244 self.blitbox = [] /ext/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5agg.py in __init__(self, figure) 64 65 def __init__(self, figure): ---> 66 super(FigureCanvasQTAggBase, self).__init__(figure=figure) 67 self._agg_draw_pending = False 68 /ext/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5.py in __init__(self, figure) 234 if DEBUG: 235 print('FigureCanvasQt qt5: ', figure) --> 236 _create_qApp() 237 238 # NB: Using super for this call to avoid a TypeError: /ext/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5.py in _create_qApp() 142 display = os.environ.get('DISPLAY') 143 if display is None or not re.search(r':\d', display): --> 144 raise RuntimeError('Invalid DISPLAY variable') 145 146 qApp = QtWidgets.QApplication([str(" ")]) RuntimeError: Invalid DISPLAY variable
df = PPM
df['CO2volume'] = df['ppm']*((1/1E6)*41000)

Above, I created a new column called CO2volume, in which i converted the ppm into cubic feet

df.describe()
del df['Volume']
df.head()
df['Volume_other_gases'] = 41000 - df['CO2volume']
df.head()
df.describe()
delta_CO2 = df['CO2volume'].diff(1) delta_Gases = df['Volume_other_gases'].diff(1)
df['Time'] = df.index delta_time = df['Time'].diff(1) / np.timedelta64(1,'m') slopes = (delta_CO2+delta_Gases) / delta_time
%matplotlib inline slopes.plot()
slopes.describe()