In [1]:
import sqlite3
import pandas as pd
import seaborn as sns
import glob
In [2]:
df = pd.read_csv('../datasets/weather_station/weather.csv.zip')
In [3]:
df
Out[3]:
In [4]:
files = [f for f in glob.glob("../datasets/sky_quality_meter/SQM_DL/*.dat", recursive=True)]
shards=[]
for f in files:
df = pd.read_csv(f, comment='#', delimiter=';', names=['UTCDateTime', 'LocalDateTime', 'Temperature', 'Voltage', 'MSAS', 'Recordtype'], parse_dates=['UTCDateTime', 'LocalDateTime'])
shards.append(df)
sqm_data = pd.concat(shards)
In [5]:
sqm_data
Out[5]:
In [6]:
sns.lineplot(x="UTCDateTime", y="MSAS",
data=sqm_data)
Out[6]:
In [7]:
from astropy.utils import iers
iers.IERS_A_URL = 'ftp://cddis.gsfc.nasa.gov/pub/products/iers/finals2000A.all'
from astroplan import download_IERS_A
download_IERS_A()
In [8]:
import multiprocessing as mp
from astropy.coordinates import EarthLocation
from astroplan import Observer
import astropy.units as u
def sunalt(datetime):
lat=52.2533
lon=-8.3605
elev=80
location = EarthLocation.from_geodetic(lon*u.deg, lat*u.deg, elev*u.m)
observer = Observer(location=location)
return observer.sun_altaz(datetime).alt.deg
def moonalt(datetime):
lat=52.2533
lon=-8.3605
elev=80
location = EarthLocation.from_geodetic(lon*u.deg, lat*u.deg, elev*u.m)
observer = Observer(location=location)
return observer.moon_altaz(datetime).alt.deg
def moonill(datetime):
lat=52.2533
lon=-8.3605
elev=80
location = EarthLocation.from_geodetic(lon*u.deg, lat*u.deg, elev*u.m)
observer = Observer(location=location)
return observer.moon_illumination(datetime)
pool = mp.Pool(mp.cpu_count())
sqm_data['sun_alt'] = pool.map(sunalt, [dt for dt in sqm_data['UTCDateTime'].values])
sqm_data['moon_alt'] = pool.map(moonalt, [dt for dt in sqm_data['UTCDateTime'].values])
sqm_data['moon_illumination'] = pool.map(moonill, [dt for dt in sqm_data['UTCDateTime'].values])
pool.close()
# sqm_data['sun_alt'] = sunalt(sqm_data['UTCDateTime'])
In [14]:
derek_dark = sqm_data[(sqm_data['sun_alt']<-18) & (sqm_data['moon_alt']<-12)]
In [16]:
sns.set(style="white")
sns.distplot(derek_dark['MSAS'], hist=False, rug=True, color="b")
Out[16]:
In [ ]: