Skip to content

Instantly share code, notes, and snippets.

@canimus
Created April 29, 2017 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canimus/d593c70999fc4e53e5a139afb9aa98d9 to your computer and use it in GitHub Desktop.
Save canimus/d593c70999fc4e53e5a139afb9aa98d9 to your computer and use it in GitHub Desktop.
Solar-Weather Data Analysis
%matplotlib inline
import matplotlib
import numpy as np
import pandas as pd
import os
import matplotlib.pylab as plt
files = [f for f in os.listdir("/sw/apps/nasa") if f.endswith('csv')]
frames = []
idx = 0
for f in files:
    print(f)
    frames.append(pd.read_csv("/sw/apps/nasa/{}".format(f), header=None, names=["position","unixepoc","sdate", "stime", "metric", "val"]))
    frames[idx] = frames[idx].assign(timestamp=lambda x: x.sdate+" "+x.stime)
    frames[idx].timestamp = pd.to_datetime(frames[idx].timestamp)
    frames[idx] = frames[idx].drop(['sdate','stime','position','unixepoc','val'], axis=1)
    frames[idx] = frames[idx].set_index(['timestamp'])
    frames[idx].sort_index(inplace=True)
    idx += 1
barometric pressure.csv
humidity.csv
solar radiation.csv
sunrise.csv
sunset.csv
temperature.csv
wind direction in degrees.csv
wind speed.csv

Barometric Pressure

frames[0].metric.plot(figsize=(16,5))
<matplotlib.axes._subplots.AxesSubplot at 0x11c9a3198>

png

Humidity

frames[1].metric.plot(figsize=(16,5))
<matplotlib.axes._subplots.AxesSubplot at 0x1193dca90>

png

Solar Radiation

frames[2].metric.plot(figsize=(16,5))
<matplotlib.axes._subplots.AxesSubplot at 0x1193f6278>

png

Sunrise

frames[3].metric.plot(figsize=(16,5))
<matplotlib.axes._subplots.AxesSubplot at 0x11d7ec940>

png

Sunset

frames[4].metric.plot(figsize=(16,5))
<matplotlib.axes._subplots.AxesSubplot at 0x11d7885f8>

png

Temperature

frames[5][frames[5].index.month==12].plot(figsize=(16,5))
<matplotlib.axes._subplots.AxesSubplot at 0x12379cda0>

png

frames[5][frames[5].index.month==12].metric.describe()
count    8164.000000
mean       47.608893
std         4.994597
min        34.000000
25%        45.000000
50%        47.000000
75%        50.000000
max        62.000000
Name: metric, dtype: float64
frames[5].metric.plot(figsize=(16,5))
<matplotlib.axes._subplots.AxesSubplot at 0x11d17a550>

png

Wind Direction

frames[6].metric.plot(figsize=(16,5))
<matplotlib.axes._subplots.AxesSubplot at 0x11d0c6cf8>

png

Wind Speed

frames[7].metric.plot(figsize=(16,5))
<matplotlib.axes._subplots.AxesSubplot at 0x11d7aec88>

png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment