The functions in ELA can be used independently of the user interface widgets to explore the energy generation and storage data and the K nearest neighbors model. Selected functions in the ela
and mapping
modules are described and demonstrated here.
In [1]:
import ela
import folium
%matplotlib inline
In [2]:
ela.get_latlon_from_zip(98105)
Out[2]:
In [3]:
ela.get_state_from_zip(98105)
Out[3]:
In [4]:
ela.get_closest_facility((47.66377, -122.30118),'gen')
Out[4]:
Alternatively the get_latlon_from__zip
function can be called and that will provide the tuple of lat-lon.
In [5]:
ela.get_closest_facility(ela.get_latlon_from_zip(98105),'stor')
Out[5]:
Printing formatted output from the returned dataframe row:
In [6]:
my_fac = ela.get_closest_facility((47.66377, -122.30118),'gen')
print("The nearest energy generation facility is {}, which is a {} \
facility with a capacity of {} MW.".
format(my_fac['name'], my_fac['type'], my_fac.capacity_MW))
In [7]:
ela.get_state_breakdown('WA', ela.gen_data)
Out[7]:
In [8]:
ela.get_state_breakdown('WA', ela.stor_data)
Out[8]:
In [9]:
ela.get_energy_breakdown(ela.gen_data)
Out[9]:
In [10]:
ela.get_energy_breakdown(ela.stor_data)
Out[10]:
get_state_breakdown()
, but as a pandas dataframe containing the energy type percentages for all U.S. states, rather than just for one state.
In [11]:
ela.state_type(ela.gen_data).head()
Out[11]:
In [12]:
ela.get_predicted_type((47.66377, -122.30118),'gen')
Out[12]:
In [13]:
ela.get_predicted_type((47.66377, -122.30118),'stor')
Out[13]:
In [14]:
ela.graph_state_breakdown('WA', 'gen')
In [15]:
ela.graph_state_breakdown('WA', 'stor')
Most of the functions in mapping
are for processing GeoJSON files and making predictions using ela.get_predicted_type
. The mapping functions of primary interest to a general user are described below.
The GeoJSON objects needed for visualizing state- or county-level predictions are included with ELA and can be accessed as ela.states
and ela.counties
.
In [16]:
m = folium.Map(location=[35,-97], zoom_start=4)
f = ela.prediction_map(ela.states, 'gen')
m.add_child(f)
Out[16]:
In [17]:
m = folium.Map(location=[35,-97], zoom_start=4)
f = ela.prediction_map(ela.counties, 'stor')
m.add_child(f)
Out[17]:
In [18]:
m = folium.Map(location=ela.get_latlon_from_zip(98105), zoom_start=6)
f = ela.facility_map('WA', 'stor')
m.add_child(f)
Out[18]:
In [19]:
m = folium.Map(location=ela.get_latlon_from_zip(98105), zoom_start=6)
f = ela.facility_map('WA', 'gen')
m.add_child(f)
Out[19]:
In [20]:
ela.state_map('NY')
Out[20]:
In [21]:
m = ela.state_map('WA')
prediction = ela.prediction_map(ela.counties, 'gen')
facilities = ela.facility_map('WA', 'gen')
m.add_child(prediction)
m.add_child(facilities)
Out[21]:
In [ ]: