In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

import pandas as pd

In [76]:
filename = 'data_meteoblue/'+'history_export_2017-07-10T14_30_52.csv'

In [77]:
data = pd.read_csv(filename, sep=';' , header=10)#, delimiter=None, header='infer'

In [78]:
data


Out[78]:
Year Month Day Hour Minute Temperature [2 m above gnd] Relative humidity [2 m above gnd] Total Precipitation [sfc] Total cloud cover [sfc] High cloud cover [high cld lay] Medium cloud cover [mid cld lay] Low cloud cover [low cld lay] Shortwave Radiation - backwards [sfc] Wind speed [10 m above gnd] Wind direction [10 m above gnd] Wind speed [900 mb] Wind direction [900 mb] Wind Gust [sfc]
0 2017 6 26 0 0 18.59 66.0 0.0 0.0 0.0 0.0 0.0 0.00 0.70 180.00 3.94 66.04 0.9
1 2017 6 26 1 0 18.34 66.0 0.0 0.0 0.0 0.0 0.0 0.00 1.48 208.30 3.95 81.25 1.3
2 2017 6 26 2 0 17.16 72.0 0.0 0.0 0.0 0.0 0.0 0.00 0.30 180.00 3.21 95.36 0.8
3 2017 6 26 3 0 16.18 77.0 0.0 5.7 19.0 0.0 0.0 0.00 0.30 180.00 2.94 107.82 2.0
4 2017 6 26 4 0 15.55 79.0 0.0 8.1 27.0 0.0 0.0 0.00 0.45 206.57 2.55 138.18 2.1
5 2017 6 26 5 0 16.37 77.0 0.0 2.1 7.0 0.0 0.0 76.54 0.32 18.43 2.32 172.57 1.0
6 2017 6 26 6 0 18.02 76.0 0.0 7.8 26.0 0.0 0.0 232.29 0.28 135.00 2.19 204.23 1.2
7 2017 6 26 7 0 20.30 72.0 0.0 2.7 9.0 0.0 0.0 390.71 0.57 45.00 1.53 168.69 0.8
8 2017 6 26 8 0 22.60 65.0 0.0 100.0 0.0 100.0 0.0 531.33 0.32 161.57 1.70 183.37 1.7
9 2017 6 26 9 0 24.53 58.0 0.0 67.0 0.0 67.0 0.0 631.90 0.50 36.87 2.82 173.88 1.5
10 2017 6 26 10 0 26.51 49.0 0.0 14.0 0.0 14.0 0.0 771.63 0.51 11.31 2.82 173.88 0.6
11 2017 6 26 11 0 28.29 42.0 0.0 0.0 0.0 0.0 0.0 765.40 0.51 11.31 2.57 193.50 0.8
12 2017 6 26 12 0 28.93 46.0 0.0 10.0 0.0 10.0 0.0 595.41 0.70 360.00 3.75 189.21 1.0
13 2017 6 26 13 0 28.94 50.0 0.5 100.0 1.0 100.0 75.0 789.43 1.75 336.37 2.14 232.59 4.7
14 2017 6 26 14 0 27.96 74.0 0.8 100.0 100.0 100.0 79.0 180.67 0.92 347.47 3.56 231.84 2.7
15 2017 6 26 15 0 26.34 84.0 1.3 100.0 100.0 100.0 0.0 185.12 1.75 59.04 2.55 168.69 2.3
16 2017 6 26 16 0 27.48 60.0 0.4 100.0 100.0 100.0 81.0 492.17 0.57 135.00 2.53 189.09 0.3
17 2017 6 26 17 0 25.93 73.0 0.7 100.0 100.0 100.0 81.0 95.23 0.10 90.00 6.73 191.14 2.7
18 2017 6 26 18 0 25.46 72.0 0.0 100.0 100.0 100.0 83.0 51.62 1.24 194.04 9.62 196.93 4.5
19 2017 6 26 19 0 24.34 72.0 0.0 100.0 100.0 100.0 86.0 30.26 1.84 192.53 8.23 204.39 5.9
20 2017 6 26 20 0 24.63 66.0 0.0 100.0 100.0 100.0 80.0 1.78 0.50 216.87 3.81 203.20 3.7
21 2017 6 26 21 0 24.61 64.0 0.0 100.0 100.0 100.0 83.0 0.00 0.73 344.05 2.33 189.87 0.4
22 2017 6 26 22 0 24.26 60.0 0.0 100.0 100.0 100.0 3.0 0.00 0.82 345.96 0.82 194.04 6.0
23 2017 6 26 23 0 22.87 62.0 0.0 100.0 100.0 100.0 100.0 0.00 2.69 311.99 0.86 305.54 2.5
24 2017 6 27 0 0 19.59 81.0 0.0 100.0 30.0 100.0 4.0 0.00 2.55 348.69 2.91 63.43 3.6
25 2017 6 27 1 0 21.48 67.0 0.0 100.0 0.0 100.0 0.0 0.00 0.41 194.04 1.81 96.34 0.6
26 2017 6 27 2 0 20.04 74.0 0.0 62.0 0.0 62.0 0.0 0.00 1.20 180.00 0.90 180.00 1.9
27 2017 6 27 3 0 19.85 78.0 0.0 28.0 0.0 28.0 3.0 0.00 0.64 51.34 2.77 154.36 0.3
28 2017 6 27 4 0 19.29 77.0 0.0 11.0 0.0 11.0 0.0 0.00 0.22 63.43 2.40 180.00 0.5
29 2017 6 27 5 0 20.16 76.0 0.0 5.0 0.0 5.0 0.0 71.20 0.10 360.00 2.38 202.25 0.9
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
306 2017 7 8 18 0 32.13 38.0 0.9 100.0 100.0 100.0 0.0 206.48 0.22 153.43 0.50 126.87 0.8
307 2017 7 8 19 0 30.18 50.0 0.7 100.0 100.0 100.0 74.0 78.32 0.10 360.00 1.12 280.30 0.1
308 2017 7 8 20 0 29.58 56.0 0.0 74.0 100.0 74.0 74.0 2.67 0.63 341.57 2.70 360.00 1.0
309 2017 7 8 21 0 28.59 59.0 0.0 78.0 100.0 78.0 0.0 0.00 1.10 354.81 4.47 10.30 2.2
310 2017 7 8 22 0 28.06 59.0 0.1 100.0 100.0 100.0 15.0 0.00 0.36 326.31 3.09 29.05 2.1
311 2017 7 8 23 0 27.65 57.0 0.0 44.0 100.0 44.0 0.0 0.00 0.28 225.00 3.10 104.93 1.2
312 2017 7 9 0 0 26.53 58.0 0.0 87.0 100.0 87.0 0.0 0.00 1.30 184.40 2.56 159.44 1.8
313 2017 7 9 1 0 24.87 59.0 0.0 10.8 36.0 7.0 0.0 0.00 0.10 90.00 1.99 197.53 1.1
314 2017 7 9 2 0 24.14 61.0 0.0 54.0 20.0 54.0 1.0 0.00 0.00 180.00 2.53 161.57 1.1
315 2017 7 9 3 0 24.13 64.0 0.0 100.0 37.0 100.0 0.0 0.00 1.36 17.10 2.35 102.26 1.6
316 2017 7 9 4 0 24.55 60.0 0.0 100.0 100.0 100.0 0.0 0.00 1.46 254.05 0.91 186.34 0.6
317 2017 7 9 5 0 22.78 65.0 0.2 100.0 100.0 100.0 100.0 6.23 1.70 220.24 10.22 183.37 6.7
318 2017 7 9 6 0 24.47 68.0 0.3 100.0 100.0 100.0 4.0 103.24 1.71 339.44 4.00 90.00 1.3
319 2017 7 9 7 0 25.11 65.0 0.0 100.0 64.0 100.0 2.0 243.86 0.45 116.57 5.80 147.68 1.7
320 2017 7 9 8 0 25.98 60.0 0.0 100.0 100.0 100.0 0.0 331.97 1.50 3.81 2.58 125.54 1.8
321 2017 7 9 9 0 28.08 53.0 0.0 37.0 68.0 37.0 2.0 351.55 1.06 41.19 0.91 173.66 1.2
322 2017 7 9 10 0 28.41 50.0 0.1 100.0 100.0 100.0 7.0 561.59 1.20 94.76 8.20 178.60 8.7
323 2017 7 9 11 0 30.05 36.0 1.1 100.0 100.0 100.0 5.0 467.25 4.00 177.14 9.37 168.93 10.3
324 2017 7 9 12 0 24.17 61.0 0.9 100.0 100.0 100.0 100.0 131.72 3.36 329.62 1.94 258.11 3.4
325 2017 7 9 13 0 25.86 56.0 0.2 100.0 100.0 100.0 9.0 202.92 0.94 327.99 2.40 163.07 1.6
326 2017 7 9 14 0 25.65 60.0 0.5 100.0 100.0 100.0 65.0 218.94 0.50 233.13 6.51 197.88 6.5
327 2017 7 9 15 0 25.66 67.0 0.1 100.0 0.0 100.0 0.0 165.54 1.50 360.00 2.92 210.96 5.9
328 2017 7 9 16 0 26.09 62.0 0.0 100.0 0.0 100.0 61.0 226.06 1.36 306.03 4.07 204.68 3.7
329 2017 7 9 17 0 25.81 64.0 0.0 100.0 0.0 100.0 69.0 191.35 0.36 303.69 6.86 198.70 5.2
330 2017 7 9 18 0 25.03 63.0 0.3 100.0 0.0 100.0 69.0 103.24 0.32 198.43 7.40 196.48 5.1
331 2017 7 9 19 0 24.62 63.0 0.0 100.0 0.0 100.0 4.0 45.39 0.20 90.00 6.99 199.21 4.4
332 2017 7 9 20 0 23.82 68.0 0.2 72.0 0.0 72.0 72.0 6.23 0.20 180.00 8.10 197.99 3.9
333 2017 7 9 21 0 22.61 71.0 0.9 100.0 0.0 0.0 100.0 0.00 1.00 216.87 8.19 199.98 3.4
334 2017 7 9 22 0 21.81 74.0 0.2 100.0 0.0 83.0 100.0 0.00 1.40 270.00 6.40 208.97 3.2
335 2017 7 9 23 0 20.37 77.0 0.2 100.0 0.0 10.0 100.0 0.00 1.84 292.38 4.18 222.09 3.2

336 rows × 18 columns


In [80]:
data.index = pd.to_datetime( data[['Year', 'Month', 'Day', 'Hour', 'Minute']] )

data = data.drop( ['Year', 'Month', 'Day', 'Hour', 'Minute'], axis=1 )

In [81]:
data.columns


Out[81]:
Index(['Temperature  [2 m above gnd]', 'Relative humidity  [2 m above gnd]',
       'Total Precipitation  [sfc]', 'Total cloud cover  [sfc]',
       'High cloud cover  [high cld lay]', 'Medium cloud cover  [mid cld lay]',
       'Low cloud cover  [low cld lay]',
       'Shortwave Radiation - backwards  [sfc]',
       'Wind speed  [10 m above gnd]', 'Wind direction  [10 m above gnd]',
       'Wind speed  [900 mb]', 'Wind direction  [900 mb]', 'Wind Gust  [sfc]'],
      dtype='object')

In [82]:
data['Total cloud cover  [sfc]'].plot()


Out[82]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f647cdc9198>

In [92]:
import weatherfeed as wf
import sunradiation as sun

In [38]:
coords_grenoble = (45.1973288, 5.7139923)

startday = pd.to_datetime('26/06/2017', format='%d/%m/%Y').tz_localize('Europe/Paris')
lastday =  pd.to_datetime('10/07/2017', format='%d/%m/%Y').tz_localize('Europe/Paris')

In [39]:
weatherdata = wf.buildmultidayDF(startday, lastday, coords_grenoble )


26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, done

In [83]:
weatherdata['temperature'].plot( figsize=(14, 6))
data['Temperature  [2 m above gnd]'].plot(style='r')


Out[83]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f647ce56a58>

In [84]:
data.index.dayofyear


Out[84]:
Int64Index([177, 177, 177, 177, 177, 177, 177, 177, 177, 177,
            ...
            190, 190, 190, 190, 190, 190, 190, 190, 190, 190],
           dtype='int64', length=336)

In [87]:
zoom_mask = data.index.map(lambda x: x.dayofyear) == 185

In [88]:
weatherdata['temperature'].loc[ zoom_mask].plot( figsize=(14, 6))
data['Temperature  [2 m above gnd]'].loc[ zoom_mask].plot(style='r')


Out[88]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f647cc93a20>

In [89]:
weatherdata['cloudCover'].plot( figsize=(14, 6))
cc = data['Total cloud cover  [sfc]']/100
cc.plot(style='r')


Out[89]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f647cbe1d68>

In [106]:
zoom_mask = data.index.map(lambda x: x.dayofyear) == 181
data['Shortwave Radiation - backwards  [sfc]'].loc[zoom_mask].plot(figsize=(14, 6))


Out[106]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f647c528b70>

In [93]:
sundata = sun.buildmultidayDF( coords_grenoble, weatherdata.index, cloudCover = weatherdata['cloudCover']  )


/home/etienne/Projets/thermique_appart/py3/lib/python3.5/site-packages/pysolar/time.py:105: UserWarning: I don't know about leap seconds after 2015
  (leap_seconds_base_year + len(leap_seconds_adjustments) - 1)

In [94]:
sundata['I0'].plot()


Out[94]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f647caf37b8>

In [107]:
zoom_mask = data.index.map(lambda x: x.dayofyear) == 181
data['Shortwave Radiation - backwards  [sfc]'].loc[zoom_mask].plot(figsize=(14, 6))
sundata['I0'].loc[zoom_mask].plot()

# surface horizontal  vs   dans direction du soleil


Out[107]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f647c6a1358>

In [ ]: