import csv from constants import constants from models.base_model import ConstantBaseModel from models.base_model import BaseModel from utils.generators import generate_constants, generate_year_models, generate_dist_models, list_prod f_type = constants.f_type yr_models = generate_year_models(fuel_type=f_type, start_year=constants.start_year, end_year=constants.end_year, path=constants.path) rd_factor = generate_constants(fuel_type=f_type, constant_type=constants.r_factor) print(rd_factor) rd_factor.sort(reverse=True) em_dict = [] if f_type == 'diesel' or 'petrol': for year_row in rd_factor: year_row = list(map(float, year_row)) year = year_row[0] less_than_1300cc = (year_row[1] + year_row[2] + year_row[3] + year_row[4] + year_row[5]) / 5 between_1300cc_and_1900cc = (year_row[6] + year_row[7] + year_row[8] + year_row[10] + year_row[11]) / 6 more_than_1900cc = (year_row[12] + year_row[13] + year_row[14]) / 3 em_dict.append({
import csv from constants import constants from models.base_model import ConstantBaseModel from models.base_model import BaseModel from utils.generators import generate_constants, generate_year_models, generate_dist_models, list_prod f_type = constants.f_type yr_models = generate_year_models(fuel_type=f_type, start_year=constants.start_year, end_year=constants.end_year, path=constants.path) eff_band = generate_constants(fuel_type=f_type, constant_type=constants.f_band) print(eff_band) eff_band.sort(reverse=True) #vehicle stock 0 - 14 } aggregate 1-5, 5-11, 12-14 #distance 0-4 {sum of (vehicle stock (0)*eff band (0))+vehicle stock (1) *eff band (1) +.../(sum of total vehicle stock in group 0 - 4)} em_dict = [] if f_type == 'diesel' or 'petrol': for year_row in eff_band: year_row = list(map(float, year_row)) year = year_row[0] less_than_900cc = year_row[1] between_900cc_and_1200cc = (year_row[2] + year_row[3] + year_row[4]) / 3 between_1200cc_and_1500cc = (year_row[5] + year_row[6] + year_row[7]) / 3
import csv from utils.salespercentage import get_sales_percentage from models.base_model import BaseModel from constants import constants from models.base_model import ConstantBaseModel from utils.generators import generate_constants, generate_year_models, list_prod, get_model_by_year f_type = constants.f_type yr_models = generate_year_models(fuel_type=f_type, start_year=constants.start_year, end_year=constants.end_year, path=constants.path) em_band = generate_constants(fuel_type=f_type, constant_type=constants.em_band) rd_factor = generate_constants(fuel_type=f_type, constant_type=constants.r_factor) dist_travelled = ConstantBaseModel( generate_constants(fuel_type=f_type, constant_type=constants.d_travelled)) new_rd_factor = [row[1:] for row in rd_factor] new_em_band = [row[1:] for row in em_band] consumption_per_km = [[(1 + float(rf)) * float(emb) for rf, emb in zip(r_fs, embs)] for r_fs, embs, in zip(new_rd_factor, new_em_band)] new_consumption_per_km = [] #emissions bands are only recorded from 2004 onwards base_year = 1990 for row in consumption_per_km: new_consumption_per_km.append([base_year] + row)
from constants import constants from models.base_model import ConstantBaseModel from utils.generators import generate_year_models, generate_constants, list_prod, read_file f_type = constants.f_type yr_models = generate_year_models(fuel_type=f_type, start_year=constants.start_year, end_year=constants.end_year, path=constants.path) dist_travelled = ConstantBaseModel( generate_constants(fuel_type=f_type, constant_type=constants.d_travelled)) age_rate_path = f'static_constants/{f_type}/ageing_rates.csv' age_rates = read_file(age_rate_path) for sample_model in yr_models: print(sample_model._year) # Getting pkm per cat for every year dist_for_yr = list( map(int, dist_travelled.get_constant(year=sample_model._year))) cars_per_cat = sample_model.get_cat_counts() pkm_cat = list_prod(dist_for_yr, cars_per_cat) # getting the share of a car age for that cat car_share_weightings = [[ car_count / cat_count for car_count, cat_count in zip(cars_per_age, cars_per_cat) ] for cars_per_age in sample_model.get_counts()]