In [1]:
import pandas as pd
In [2]:
#text file looks like this
'''
Docklight Log File (ASCII) - Started 6/14/2013 11:34:17.033
RH0000 P1040X<CR><LF>
2013/06/04 19:42:23 - G 498.00 T26.78 HT0000 RH0000 P1040X<CR><LF>
2013/06/04 19:42:25 - G 498.00 T26.78 HT0000 RH0000 P1040X<CR><LF>
2013/06/04 19:42:27 - G 498.00 T26.78 HT0000 RH0000 P1040X<CR><LF>
2013/06/04 19:42:29 - G 498.00 T26.79 HT0000 RH0000 P1040X<CR><LF>
2013/06/04 19:42:31 - G 498.00 T26.80 HT0000 RH0000 P1042X<CR><LF>
''';
In [3]:
col_specs=[(0,10), (11,19), (23,30), (32,37), (43,47), (50,54), (58,62)]
'''
df = pd.read_fwf(StringIO(x),colspecs=col_specs, skiprows=2,parse_dates =[[0,1]], index_col=0,
names=['date','time','CO2','Temperature','Humidity','Relative Humidity','Pressure'],header=None)
'''
df = pd.read_fwf('/usgs/data2/notebook/data/ICO2sensordata_v1.txt',colspecs=col_specs, skiprows=2,parse_dates =[[0,1]], index_col=0,
names=['date','time','CO2','Temperature','Humidity','Relative Humidity','Pressure'],header=None,nrows=500000)
In [4]:
df['CO2'].max()
Out[4]:
In [5]:
df['CO2'].plot(figsize=(12,6))
Out[5]:
In [6]:
df_5min=df.resample('5min',how='mean')
In [7]:
df_5min['Temperature'][0:20]
Out[7]:
In [8]:
df_5min['Temperature']['2013-06-11 12:00:00':'2013-06-11 18:00:00']
Out[8]:
In [9]:
# clip to time when instrument was in water
df_5min=df_5min['2013-06-04 20:35:00':'2013-06-11 17:15:00']
In [10]:
df_5min[['CO2','Temperature']].plot(figsize=(12,4),secondary_y='Temperature');
In [11]:
df_5min[['Humidity','Relative Humidity']].plot(figsize=(12,4));
In [12]:
df_5min['Pressure'].plot(figsize=(12,4));
In [13]:
# look at correlation between Temp and CO2
corrcoef(df_5min['Temperature'],df_5min['CO2'])
Out[13]:
In [14]:
plot(df_5min['Temperature'],df_5min['CO2'],'go');
grid();
In [14]: