Open willu47 opened 5 years ago
Read scenario data (workaround for smif#370):
import pandas as pd
from smif.data_layer import Results
results = Results({'interface': 'local_csv', 'dir': '.'})
store = results._store
model_run_name = 'energy_sd_optimised'
model_run = store.read_model_run(model_run_name)
scenario = 'gva'
variant = dict(model_run['scenarios'])[scenario]
output = 'gva_per_head'
dimensions = [x['dims'] for x in store.read_scenario(scenario, skip_coords=True)['provides'] if x['name']==output][0]
df = None
for step in model_run['timesteps']:
if df is not None:
data = store.read_scenario_variant_data(scenario, variant, output, step).as_df()
df[step] = data
else:
df = store.read_scenario_variant_data(scenario, variant, output, step).as_df()
df = df.rename(columns={output: step})
df = df.reset_index().melt(id_vars=dimensions)
df = df.rename(columns={'variable': 'timestep', 'value': output})
Example of plotting spatial data using dimensions access via the store:
import geopandas as gpd
lads = store.read_dimension('lad_uk_2016')['elements']
lad_features = [x['feature'] for x in lads]
lad_df = gpd.GeoDataFrame.from_features(lad_features)
b = lad_df.merge(df, left_on='lad16cd', right_on='lad_uk_2016')
b.plot(column='population')
Question: for plots like: Total heating demand by LAD, timestep, what do you actually want out?
heating demand on Y against timestep on X, and an individual graph per LAD? Or lots of lines, one for each LAD, on a single set of axes?
Hi @fcooper8472 - Suggest heating demand on Y against timestep on X, with an individual graph per LAD, or mean, min, max graphs over all LADs in three charts.
Put together a Python script or Jupyter notebook which creates a set of plots which enables comparison of results from across the model runs.
List of plots required
Scenarios
Energy Supply
Energy Demand
Transport - Road
Transport - Rail
Digital Comms
Water