Introduction

This module is in charge of reading the POPS housekeeping file and converting it to a TimeSeries instance.

Imports


In [1]:
from atmPy.aerosols.instruments.POPS import housekeeping
%matplotlib inline

Reading a housekeeping file


In [4]:
filename = './data/POPS_housekeeping.csv'
hk = housekeeping.read_csv(filename)


reading ./data/POPS_housekeeping.csv

In [5]:
hk.data.columns


Out[5]:
Index(['Time_s', 'Status', 'Flow_Rate_ccps', 'Particle_rate_nops', '12V_Mon',
       'A1', 'A2', 'A3', 'Therm_1', 'Therm_2', 'TiltRef', 'POPS_Flow',
       'POPS_P', 'ULR_AZ_Home', 'ULR_PD_T', 'ULR_Incl_x', 'ULR_Incl_y',
       'ULR_Incl_T', 'POPS_LD_T', 'POPS_T_LED', 'POPS_LP_Set', 'MeanBL',
       'stdDevBL'],
      dtype='object')

In [6]:
hk.data.stdDevBL.plot()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-b19cf65e30ae> in <module>()
----> 1 hk.data.stdDevBL.plot()

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/tools/plotting.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)
   3564                            colormap=colormap, table=table, yerr=yerr,
   3565                            xerr=xerr, label=label, secondary_y=secondary_y,
-> 3566                            **kwds)
   3567     __call__.__doc__ = plot_series.__doc__
   3568 

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/tools/plotting.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)
   2643                  yerr=yerr, xerr=xerr,
   2644                  label=label, secondary_y=secondary_y,
-> 2645                  **kwds)
   2646 
   2647 

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/tools/plotting.py in _plot(data, x, y, subplots, ax, kind, **kwds)
   2439         plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
   2440 
-> 2441     plot_obj.generate()
   2442     plot_obj.draw()
   2443     return plot_obj.result

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/tools/plotting.py in generate(self)
   1026         self._compute_plot_data()
   1027         self._setup_subplots()
-> 1028         self._make_plot()
   1029         self._add_table()
   1030         self._make_legend()

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/tools/plotting.py in _make_plot(self)
   1705                              stacking_id=stacking_id,
   1706                              is_errorbar=is_errorbar,
-> 1707                              **kwds)
   1708             self._add_legend_handle(newlines[0], label, index=i)
   1709 

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/tools/plotting.py in _ts_plot(cls, ax, x, data, style, **kwds)
   1745         lines = cls._plot(ax, data.index, data.values, style=style, **kwds)
   1746         # set date formatter, locators and rescale limits
-> 1747         format_dateaxis(ax, ax.freq)
   1748         return lines
   1749 

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/tseries/plotting.py in format_dateaxis(subplot, freq)
    292         "t = {0}  y = {1:8f}".format(Period(ordinal=int(t), freq=freq), y))
    293 
--> 294     pylab.draw_if_interactive()

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/utils/decorators.py in wrapper(*args, **kw)
     41     def wrapper(*args,**kw):
     42         wrapper.called = False
---> 43         out = func(*args,**kw)
     44         wrapper.called = True
     45         return out

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/backends/backend_macosx.py in draw_if_interactive()
    248         figManager =  Gcf.get_active()
    249         if figManager is not None:
--> 250             figManager.canvas.invalidate()
    251 
    252 

AttributeError: 'FigureCanvasAgg' object has no attribute 'invalidate'

Done! hk is an instance of TimeSeries and you can do with it what ever the instance is capable of (see here). E.g. plot stuff.


In [3]:
out = hk.plot_all()



In [2]:
from atmPy.aerosols.instruments import POPS

In [33]:
reload(POPS)
reload(POPS.housekeeping)


Out[33]:
<module 'atmPy.aerosols.instruments.POPS.housekeeping' from '/Users/htelg/prog/atm-py/atmPy/aerosols/instruments/POPS/housekeeping.py'>

In [34]:
fname = '/Users/htelg/data/2017_ICARUS/POPS_SN14_ambient_more_raw/F20170523/HK_20170523x001.csv'
hk = POPS.read_housekeeping(fname)

In [36]:
for col in hk.data.columns:
    print(col)


Status
PartCt
PartCon
BL
BLTH
STD
P
TofP
POPS_Flow
PumpFB
LDTemp
LaserFB
LD_Mon
Temp
BatV
Laser_Current
Flow_Set
BL_Start
TH_Mult
nbins
logmin
logmax
Skip_Save
MinPeakPts
MaxPeakPts
RawPts
Barometric_pressure

In [39]:
sel = hk._del_all_columns_but(['Temp','TofP','LDTemp'])

In [40]:
sel.data.plot()


Out[40]:
<matplotlib.axes._subplots.AxesSubplot at 0x11902a1d0>

In [41]:
hk.get_timespan()


Out[41]:
(Timestamp('2017-05-23 16:45:59.288000'),
 Timestamp('2017-05-23 22:34:47.301000'))

In [ ]:


In [12]:
col_names = pd.read_csv(fname, sep=',', nrows=1, header=None,
                         #             index_col=1,
                         #             usecols=np.arange()
                         ).values[0][:-1].astype(str)
col_names = np.char.strip(col_names)
col_names


Out[12]:
array(['DateTime', 'Status', 'PartCt', 'PartCon', 'BL', 'BLTH', 'STD', 'P',
       'TofP', 'POPS_Flow', 'PumpFB', 'LDTemp', 'LaserFB', 'LD_Mon',
       'Temp', 'BatV', 'Laser_Current', 'Flow_Set', 'BL_Start', 'TH_Mult',
       'nbins', 'logmin', 'logmax', 'Skip_Save', 'MinPeakPts',
       'MaxPeakPts', 'RawPts'],
      dtype='<U14')

In [18]:
col_names = pd.read_csv(fname, sep=',', nrows=1, header=None,
                         #             index_col=1,
                         #             usecols=np.arange()
                         ).values[0][:-1].astype(str)
col_names = np.char.strip(col_names)

data = pd.read_csv(fname, sep=',', skiprows=1, header=None,
                    #             index_col=1,
                    #             usecols=np.arange()
                    )

data_hk = data.iloc[:, :27]
data_hk.columns = col_names
data_hk.index = pd.to_datetime(data_hk['DateTime'], unit='s')
data_hk.drop('DateTime', axis=1, inplace=True)
#     hk = atmPy.general.timeseries.TimeSeries(data_hk, sampling_period = 1)

hk = _housekeeping.POPSHouseKeeping(data_hk, sampling_period=1)
hk.data['Barometric_pressure'] = hk.data['P']

In [13]:
col_names = pd.read_csv(fname, sep=',', nrows=1, header=None).values[0][:-1].astype(str)
col_names = np.char.strip(col_names)
pd.read_csv(fname, usecols=range(5), skiprows=1, )


Out[13]:
1495557959.288 1 0 0.00 2261
0 1.495558e+09 1 3 6.02 2258
1 1.495558e+09 1 6 12.05 2258
2 1.495558e+09 1 4 8.03 2259
3 1.495558e+09 1 3 6.09 2260
4 1.495558e+09 1 4 7.94 2259
5 1.495558e+09 1 1 1.99 2260
6 1.495558e+09 1 1 1.99 2261
7 1.495558e+09 1 4 8.03 2260
8 1.495558e+09 1 3 5.96 2260
9 1.495558e+09 1 7 14.06 2260
10 1.495558e+09 1 4 8.03 2257
11 1.495558e+09 1 2 2.19 2258
12 1.495558e+09 1 36 13.91 2257
13 1.495558e+09 1 99 33.97 2256
14 1.495558e+09 1 11 3.74 2257
15 1.495558e+09 1 7 2.37 2257
16 1.495558e+09 1 15 5.09 2258
17 1.495558e+09 1 21 7.05 2260
18 1.495558e+09 1 18 6.07 2261
19 1.495558e+09 1 7 2.35 2260
20 1.495558e+09 1 7 2.38 2262
21 1.495558e+09 1 9 3.04 2260
22 1.495558e+09 1 8 2.70 2263
23 1.495558e+09 1 8 2.72 2262
24 1.495558e+09 1 12 4.06 2261
25 1.495558e+09 1 6 2.03 2261
26 1.495558e+09 1 7 2.38 2261
27 1.495558e+09 1 10 3.36 2261
28 1.495558e+09 1 7 2.35 2261
29 1.495558e+09 1 8 2.70 2260
... ... ... ... ... ...
20898 1.495579e+09 1 636 213.05 2241
20899 1.495579e+09 1 466 156.96 2241
20900 1.495579e+09 1 354 119.68 2242
20901 1.495579e+09 1 208 71.10 2241
20902 1.495579e+09 1 141 45.98 2243
20903 1.495579e+09 1 166 56.33 2242
20904 1.495579e+09 1 224 76.72 2242
20905 1.495579e+09 1 298 100.93 2245
20906 1.495579e+09 1 1220 408.69 2244
20907 1.495579e+09 1 1342 442.30 2243
20908 1.495579e+09 1 774 260.23 2242
20909 1.495579e+09 1 639 218.44 2245
20910 1.495579e+09 1 674 228.28 2242
20911 1.495579e+09 1 1130 380.62 2243
20912 1.495579e+09 1 564 191.73 2242
20913 1.495579e+09 1 588 200.26 2244
20914 1.495579e+09 1 812 274.52 2243
20915 1.495579e+09 1 856 292.08 2244
20916 1.495579e+09 1 1518 521.84 2241
20917 1.495579e+09 1 917 313.47 2245
20918 1.495579e+09 1 691 233.18 2243
20919 1.495579e+09 1 639 206.53 2240
20920 1.495579e+09 1 287 97.75 2243
20921 1.495579e+09 1 330 112.39 2242
20922 1.495579e+09 1 270 90.78 2242
20923 1.495579e+09 1 160 54.59 2240
20924 1.495579e+09 1 211 72.53 2241
20925 1.495579e+09 1 154 51.12 2241
20926 1.495579e+09 1 147 50.44 2241
20927 1.495579e+09 1 86 28.97 2243

20928 rows × 5 columns


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: