#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jun 25 12:08:05 2024 @author: jdaniel """ from matplotlib import pyplot as plt import numpy as np import pandas as pd from scipy.stats import norm plt.rcParams["font.family"] = "Arial" def outputAppendix(years,markets,regions,shapes,consump_bymarket,outkernel): nyears = len(years) dims = np.shape(shapes) ii = np.where(regions == 'Japan') shapeuse = shapes[:,ii[0],:] shapeuse = np.reshape(shapeuse,[dims[0],dims[2]]) # print(np.shape(shapeuse)) # print(np.shape(shapes)) nmarkets = len(shapes[0,0,:]) x = np.zeros(1000) xbin = np.zeros(51) for i in range(len(xbin)): xbin[i] = i/len(xbin) for i in range(len(x)): x[i] = i/len(x) for i in range(0,nmarkets): tmp = norm(loc = shapeuse[0,i], scale = .4 * shapeuse[0,i]) out = tmp.pdf(x)*10000/50 # print(i,np.mean(shapeuse[1::,i]),shapeuse[0,i]) m = np.max(out) plt.plot(x,out/m) plt.hist(shapeuse[:,i],bins=xbin, histtype = 'step', weights = 1/m*np.ones_like(shapeuse[:,i])) plt.ylim(0,2.1) # plt.yscale('log') # plt.xscale('log') plt.xlim(.0,1) plt.show() index = [5,0,7,4,3,11] #markets to show range of index = [0,1,2,3,4,5,6,7,8,9,10,11] #markets to show range of s = np.shape(consump_bymarket) percentile = .165 itop = int((1-percentile)*s[0]) ibot = int(percentile*s[0]) low, high = np.zeros(nyears), np.zeros(nyears) consump_avg_overregion = np.mean(consump_bymarket,axis=2) consump_total = np.sum(consump_avg_overregion[0,:,:],axis=1) for i in index: fig, ax = plt.subplots() print(i,markets[i]) for j in range(0,nyears-1): vals = np.sort(consump_avg_overregion[1::,j,i]) low[j] = vals[ibot] / consump_total[j] high[j] = vals[itop] / consump_total[j] # plt.plot(years,low,color='blue') # plt.plot(years,high,color='blue') plt.fill_between(years,low,high,color='black',alpha=.2) plt.plot(years[0:-1],consump_avg_overregion[0,0:-1,i]/consump_total[0:-1],color='black') plt.title(markets[i]+' (Global)') plt.xlim(1990,2021) plt.xlabel('Year'); plt.ylabel('Global Fraction') ax.tick_params(axis='y', which='both', direction='in', right=True) ax.tick_params(axis='x', direction='in', top=True) plt.show() s = np.shape(outkernel.activebank) for i in range(0,s[0]): plt.plot(outkernel.activebank[i,:]) plt.title(markets[i]) plt.show() # return(consump_avg_overregion, consump_total)