In [ ]:
import mesowest
import importlib
from datetime import datetime
import json
import locale
import numpy as np
import folium


from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets

In [ ]:
importlib.reload(mesowest)

In [ ]:
# Date range for data we are interested
start = datetime(2016, 12, 1)
end = datetime(2017, 3, 1)

In [ ]:
# MesoWest station ID.
stn = 'MTMET'

data, url = mesowest.query(stn, start, end)

In [ ]:
url

In [ ]:
fo = mesowest.urlopen("""https://api.synopticlabs.org/v2/stations/metadata?&token=demotoken&state=UT&vars=PM_25_concentration&status=active""")

stations = json.loads(fo.read())
fo.close()

In [ ]:
type(stations)

In [ ]:
stations.keys()

In [ ]:
station_data = [("; ".join((s['STID'],s['NAME'])),locale.atof(s['LATITUDE']),locale.atof(s['LONGITUDE'])) for s in stations['STATION']]

In [ ]:
for s in stations['STATION']:
    if s['STID'] == stn:
        print(s["MNET_ID"])
        print(s["STID"])
        print(s["LONGITUDE"], s["LATITUDE"])
        print("*"*42)

In [ ]:
stations['STATION'][0]

In [ ]:
map = folium.Map(location=[40.766563, -111.928211], tiles="Stamen Terrain", zoom_start=6.5)
for s in station_data:
    folium.Marker([s[1], s[2]],
                  popup=s[0],
                  icon=folium.Icon(icon='cloud')).add_to(map)
map

Valid States

CA, AZ, ID, CO, UT

Why doesn't this work for UT?


In [ ]:
state = 'CO'
fo = mesowest.urlopen("""https://api.synopticlabs.org/v2/stations/metadata?&token=demotoken&state=%s&vars=PM_25_concentration&status=active"""%state)
stations_ca = json.loads(fo.read())
fo.close()

ca_station_data = [(";".join((s["STID"],s['NAME'])),locale.atof(s['LATITUDE']),locale.atof(s['LONGITUDE'])) for s in stations_ca['STATION']]
lat = np.mean([s[1] for s in ca_station_data])
lon = np.mean([s[2] for s in ca_station_data])
ca_map = folium.Map(location=[lat,lon], tiles="Stamen Terrain", zoom_start=6.5)
for s in ca_station_data:
    folium.Marker([s[1], s[2]],
                  popup=s[0],
                  icon=folium.Icon(icon='cloud')).add_to(ca_map)
ca_map

In [ ]:
lat, lon

In [ ]:
ca_station_data

In [ ]:
states = ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DC", "DE", "FL", "GA", 
          "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", 
          "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", 
          "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", 
          "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY"]

In [ ]:
import pandas as pd

In [ ]:
!which python

In [ ]:
erik_data = pd.read_html("https://link.springer.com/article/10.1007/s11869-016-0415-2")
len(erik_data)

In [ ]:
erik_data[1]

In [1]:
import geopandas as gpd

In [ ]: