Simple quick update latest weather
In [1]:
# Tell matplotlib to plot in line
%matplotlib inline
# import pandas
import pandas
# seaborn magically adds a layer of goodness on top of Matplotlib
# mostly this is just changing matplotlib defaults, but it does also
# provide some higher level plotting methods.
import seaborn
# Tell seaborn to set things up
seaborn.set()
def smooth(data, thresh=None):
means = data.mean()
if thresh is None:
sds = data.std()
else:
sds = thresh
delta = data - data.shift()
good = delta[abs(delta) < sds]
#print(good.describe())
return delta.where(good, 0.0)
In [2]:
infile = "../files/pijessie_weather.csv"
!scp 192.168.0.127:Adafruit_Python_BMP/weather.csv $infile
In [3]:
""" assume it is csv and let pandas do magic
index_col tells it to use the 'date' column in the data
as the row index, plotting picks up on this and uses the
date on the x-axis
The *parse_dates* bit just tells it to try and figure out
the date/time in the columne labeled 'date'.
"""
data = pandas.read_csv(infile, index_col='date', parse_dates=['date'])
#data = smooth(data)
# smooth the data to filter out bad temps and pressures
#data.altitude = (smooth(data.altitude, 5.0).cumsum() + data.altitude[0])
#data.temp = (smooth(data.temp, 5.0).cumsum() + data.temp[0])
In [4]:
data.altitude.plot()
Out[4]:
In [5]:
# reading is once a minute, so take last 24 * 60 readings
def plotem(data, n=-60):
if n < 0:
start = n
end = len(data)
else:
start = 0
end = n
data[['temp', 'altitude', 'humidity']][n:].plot(subplots=True)
plotem(data, -24*60)
In [6]:
data.altitude[-8*60:].plot()
Out[6]:
In [7]:
# reading is once a minute, so take last 7 * 24 * 60 readings
plotem(data, -7*24*60)
In [8]:
plotem(data)
In [9]:
data.describe()
Out[9]:
In [10]:
data.tail()
Out[10]:
I currently have two temperature sensors:
The plot below shows the two temperature plots.
Both these sensors are currently in my study. For temperature and humidity I would like to have some readings from outside. If I can solder them to a phone jack then I can just run phone cable to where they need to be.
Below plots the current values from these sensors. This is handy for calibration.
In [11]:
data[['temp', 'temp_dht']].plot()
Out[11]:
The warmer air is, the more moisture it can hold. The dew point is the temperature at which air would be totally saturated if it had as much moisture as it currently does.
Given the temperature and humidity the dew point can be calculated, the actual formula is pretty complex.
It is explained in more detail here: http://iridl.ldeo.columbia.edu/dochelp/QA/Basic/dewpoint.html
$$Td = T - ((100 - RH)/5.)$$If you are interested in a simpler calculation that gives an approximation of dew point temperature if you know >the observed temperature and relative humidity, the following formula was proposed in a 2005 article by Mark G. >Lawrence in the Bulletin of the American Meteorological Society:
In [12]:
data['dewpoint'] = data.temp - ((100. - data.humidity)/5.)
In [13]:
data[['temp', 'dewpoint', 'humidity']].plot()
Out[13]:
In [14]:
data[['temp', 'dewpoint', 'humidity']].plot(subplots=True)
Out[14]:
In [15]:
data[['temp', 'dewpoint']].plot()
Out[15]:
In [16]:
data.altitude.plot()
Out[16]: