4.7. fleet_totals_dict module

fleet_totals_dict.add_keys_for_discounting(input_dict, *rates)[source]
Parameters:

input_dict: Dictionary; into which new keys will be added that provide room for discounting data.

rates: Numeric; the discount rate keys to add.

Returns:

The passed dictionary with new keys added.

class fleet_totals_dict.FleetTotals(fleet_dict)[source]

Bases: object

A FleetTotals object contains annual totals for vehicles by model year and by calendar year.

Parameters:

fleet_dict: Dictionary; contains fleet data, totals by model year and calendar year.

create_new_attributes(calc_cap_pollution, calc_ghg_pollution)[source]
Parameters:

calc_cap_pollution: True or None.

calc_ghg_pollution: True or None.

Returns:

A list of new attributes to be calculated and provided in output files.

create_fleet_totals_dict(settings, fleet_df)[source]

This method creates a dictionary of fleet total values and adds a discount rate element to the key.

Parameters:

settings: The SetInputs class.

fleet_df: DataFrame; the project fleet.

Returns:

A dictionary of the fleet having keys equal to ((vehicle), modelYearID, ageID, discount_rate) where vehicle is a tuple representing an alt_sourcetype_regclass_fueltype vehicle, and values representing totals for each key over time.

create_regclass_sales_dict(fleet_df)[source]

This method simply generates sales by regclass via Pandas which is faster than summing via dictionary.

Parameters:

fleet_df: DataFrame; the project fleet.

Returns:

A dictionary of the fleet having keys equal to ((unit), alt, modelYearID) where unit is a tuple representing a regclass_fueltype, and values representing sales (sales=VPOP at ageID=0) for each key by model year.

create_sourcetype_sales_dict(fleet_df)[source]

This method simply generates sales by sourcetype via Pandas which is faster than summing via dictionary.

Parameters:

fleet_df: DataFrame; the project fleet.

Returns:

A dictionary of the fleet having keys equal to ((unit), alt, modelYearID) where unit is a tuple representing a sourcetype_regclass_fueltype, and values representing sales (sales=VPOP at ageID=0) for each key by model year.

calc_unit_sales(unit, alt, model_year, sales_arg)[source]
Parameters:

unit: Tuple; represents a regclass-fueltype engine or sourcetype-regclass-fueltype vehicle.

alt: Numeric; represents the Alternative or optionID.

model_year: Numeric; represents the model year of the passed unit.

sales_arg: String; represents the sales attribute to use.

Returns:

A single sales value (Numeric, i.e., sales_arg value) for the given unit, model_year, alt.

Note:

DiscountRate is set to zero since sales numbers will not change with discount rate.

calc_unit_cumulative_sales(unit, alt, start_model_year, end_model_year, sales_arg)[source]
Parameters:

unit: Tuple; represents a regclass-fueltype engine or sourcetype-regclass-fueltype vehicle.

alt: Numeric; represents the Alternative or optionID.

start_model_year: Numeric; represents the initial model year of sales to include.

end_model_year: Numeric; represents the final model year of sales to include (e.g., the unit’s model year.

sales_arg: String; represents the sales attribute to use.

Returns:

A single cumulative sales value (Numeric, i.e., sales_arg value) for the given unit, model_year, alt.

Note:

DiscountRate is set to zero since sales numbers will not change with discount rate.

update_dict(key, input_dict)[source]
Parameters:

key: Tuple; the key of the dictionary instance.

input_dict: Dictionary; represents the attribute-value pairs to be updated.

Returns:

The dictionary instance with each attribute updated with the appropriate value.

get_attribute_value(key, attribute)[source]
Parameters:

key: Tuple; the key of the dictionary instance.

attribute: String; represents the attribute to be updated.

Returns:

The value of ‘attribute’ within the dictionary instance.