import matplotlib.pyplot as plt
from aux2mongodb import MagicWeather
from datetime import date


m = MagicWeather(auxdir='/fact/aux')

df = m.read_date(date(2015, 12, 31))

df.plot(x='timestamp', y='humidity', legend=False)
plt.ylabel('Humidity / %')
plt.show()

import matplotlib.pyplot as plt
from aux2mongodb import MagicWeather, PfMini
import pandas as pd
from tqdm import tqdm
import datetime

plt.style.use('ggplot')


magic_weather = MagicWeather(auxdir='/fact/aux')
pf_mini = PfMini(auxdir='/fact/aux')
dates = pd.date_range('2015-10-20', datetime.date.today())

outside = pd.DataFrame()
camera = pd.DataFrame()
for d in tqdm(dates):
    try:
        outside = outside.append(magic_weather.read_date(d), ignore_index=True)
    except FileNotFoundError:
        continue
    try:
        camera = camera.append(pf_mini.read_date(d), ignore_index=True)
    except FileNotFoundError:
        continue

outside.set_index('timestamp', inplace=True)
camera.set_index('timestamp', inplace=True)
outside = outside.resample('24h').mean()
camera = camera.resample('24h').mean()

fig, ax = plt.subplots()
ax.set_title('Camera vs. Outside Humidity (24h mean)')

outside.plot(y='humidity', legend=False, label='Outside', ax=ax)
camera.plot(y='humidity', legend=False, label='In Camera', ax=ax)

ax.legend()
ax.set_ylabel('Humidity / %')
fig.tight_layout()
plt.show()

Modify example to make camera vs. outside humidity plot
Modify example to make camera vs. outside humidity plot

  import matplotlib.pyplot as plt
- from aux2mongodb import MagicWeather
+ from aux2mongodb import MagicWeather, PfMini
- from datetime import date
+ import pandas as pd
+ from tqdm import tqdm
+ import datetime
+ 
+ plt.style.use('ggplot')
  
  
- m = MagicWeather(auxdir='/fact/aux')
+ magic_weather = MagicWeather(auxdir='/fact/aux')
+ pf_mini = PfMini(auxdir='/fact/aux')
+ dates = pd.date_range('2015-10-20', datetime.date.today())
  
- df = m.read_date(date(2015, 12, 31))
+ outside = pd.DataFrame()
+ camera = pd.DataFrame()
+ for d in tqdm(dates):
+     try:
+         outside = outside.append(magic_weather.read_date(d), ignore_index=True)
+     except FileNotFoundError:
+         continue
+     try:
+         camera = camera.append(pf_mini.read_date(d), ignore_index=True)
+     except FileNotFoundError:
+         continue
  
- df.plot(x='timestamp', y='humidity', legend=False)
+ outside.set_index('timestamp', inplace=True)
+ camera.set_index('timestamp', inplace=True)
+ outside = outside.resample('24h').mean()
+ camera = camera.resample('24h').mean()
+ 
+ fig, ax = plt.subplots()
+ ax.set_title('Camera vs. Outside Humidity (24h mean)')
+ 
+ outside.plot(y='humidity', legend=False, label='Outside', ax=ax)
+ camera.plot(y='humidity', legend=False, label='In Camera', ax=ax)
+ 
+ ax.legend()
- plt.ylabel('Humidity / %')
+ ax.set_ylabel('Humidity / %')
+ fig.tight_layout()
  plt.show()
  
Modify example to make camera vs. outside humidity plot
## Code Before:
import matplotlib.pyplot as plt
from aux2mongodb import MagicWeather
from datetime import date


m = MagicWeather(auxdir='/fact/aux')

df = m.read_date(date(2015, 12, 31))

df.plot(x='timestamp', y='humidity', legend=False)
plt.ylabel('Humidity / %')
plt.show()

## Instruction:
Modify example to make camera vs. outside humidity plot
## Code After:
import matplotlib.pyplot as plt
from aux2mongodb import MagicWeather, PfMini
import pandas as pd
from tqdm import tqdm
import datetime

plt.style.use('ggplot')


magic_weather = MagicWeather(auxdir='/fact/aux')
pf_mini = PfMini(auxdir='/fact/aux')
dates = pd.date_range('2015-10-20', datetime.date.today())

outside = pd.DataFrame()
camera = pd.DataFrame()
for d in tqdm(dates):
    try:
        outside = outside.append(magic_weather.read_date(d), ignore_index=True)
    except FileNotFoundError:
        continue
    try:
        camera = camera.append(pf_mini.read_date(d), ignore_index=True)
    except FileNotFoundError:
        continue

outside.set_index('timestamp', inplace=True)
camera.set_index('timestamp', inplace=True)
outside = outside.resample('24h').mean()
camera = camera.resample('24h').mean()

fig, ax = plt.subplots()
ax.set_title('Camera vs. Outside Humidity (24h mean)')

outside.plot(y='humidity', legend=False, label='Outside', ax=ax)
camera.plot(y='humidity', legend=False, label='In Camera', ax=ax)

ax.legend()
ax.set_ylabel('Humidity / %')
fig.tight_layout()
plt.show()
