Single station analysis

Import the familiar modules and the ACIS data loader


In [1]:
import ACISLoader as A
import pandas as pd
import matplotlib.pyplot as plt

Define your request parameters:

  • COOP station ID 304174 is Ithaca, NY
  • por indicates the period of record
  • get minimum temperature, maximum temperature and daily precipitation

The loader returns a panel with a dataframe keyed on the station id.


In [2]:
p = A.ACISLoader(sid='304174',sdate='2012-01-01',edate='por',elems='mint,maxt,pcpn')
df = p['304174']

The dataframe has a column per requested element, indexed by the date


In [3]:
df[-10:]


Out[3]:
maxt mint pcpn
2013-06-18 80 54 0.14
2013-06-19 67 41 0
2013-06-20 67 42 0
2013-06-21 79 51 0
2013-06-22 83 61 0
2013-06-23 86 66 0
2013-06-24 90 66 0.81
2013-06-25 85 63 0.06
2013-06-26 83 65 0.03
2013-06-27 82 60 0

Use pandas and matplotlib to visualize the min/max temperatures


In [4]:
a1 = df.mint.plot(figsize=(16,6)).set_title('Ithaca, NY min and max temperature')
a2 = df.maxt.plot(style='r')


Use pandas to smooth the data


In [5]:
b1 = pd.rolling_mean(df.mint,10).plot(figsize=(16,6)).set_title('10 day moving average')
b2 = pd.rolling_mean(df.maxt,10).plot(style='r')


Use ACIS to calculate the moving average

10 days ending on reported date


In [6]:
p1 = A.ACISLoader(sid='304174',sdate='2012-01-01',edate='por',
                 elems=[dict(name='mint',interval='dly',duration=10,reduce='mean'),
                        dict(name='maxt',interval='dly',duration=10,reduce='mean')])
df1 = p1['304174']
a1 = df1.mint.plot(figsize=(16,6)).set_title('Ithaca, NY min and max temperature (10-day mean)')
a2 = df1.maxt.plot(style='r')


Don't use pandas to sum the precipitation

The ACIS sum reduction will handle subsequent/accumulated values properly

Get the 120 years of precipitation over 30, 60, 90 and 120 days ending on September 1.


In [7]:
p = A.ACISLoader(sid='304174',sdate='1893-09-01',edate='por',elems=[
    dict(label='p_30',name='pcpn',interval=(1,0,0),duration=30,reduce='sum'),
    dict(label='p_60',name='pcpn',interval=(1,0,0),duration=60,reduce='sum'),
    dict(label='p_90',name='pcpn',interval=(1,0,0),duration=90,reduce='sum'),
    dict(label='p_120',name='pcpn',interval=(1,0,0),duration=120,reduce='sum'),
    ])
prcp = p['304174']

In [8]:
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(16, 6),sharex=True,sharey=True)
prcp.p_30.hist(ax=axes[0,0],color='k', alpha=0.5, bins=50); axes[0,0].set_title('30-day')
prcp.p_60.hist(ax=axes[0,1],color='k', alpha=0.5, bins=50); axes[0,1].set_title('60-day')
prcp.p_90.hist(ax=axes[1,0],color='k', alpha=0.5, bins=50); axes[1,0].set_title('90-day')
prcp.p_120.hist(ax=axes[1,1],color='k', alpha=0.5, bins=50); axes[1,1].set_title('120-day')


Out[8]:
<matplotlib.text.Text at 0x106261e10>

In [8]: