Skip to content

Global module

t3co.run.Global

Global constants Stores paths to directories used for input files, as well as constants referenced throughout the code base

ANN_TRAVEL_TSV = 'annual-travel.tsv' module-attribute

BEV = vehicle.BEV module-attribute

CONV = vehicle.CONV module-attribute

DieselGalPerGasGal = 0.887 module-attribute

EMISSION_RATE_TSV = 'emission-rate.tsv' module-attribute

FASTSIM_INPUTS = OPTIMIZATION_RESOURCES_AUX / FASTSIM_INPUTS_FILE module-attribute

FASTSIM_INPUTS_FILE = 'FASTSimInputsHeader.csv' module-attribute

FC_EFF_TYPES = {1: 'SI', 2: 'Diesel - ISB280', 3: 'Diesel', 4: 'Fuel Cell', 5: 'Hybrid Diesel', 6: 'Diesel - HD', 7: 'Diesel - HDISM Scaled', 8: 'Diesel - HDISM Scaled', 9: 'CNG'} module-attribute

FUEL_EFF_TSV = 'fuel-efficiency.tsv' module-attribute

FUEL_EXPENSE_TSV = 'fuel-expense.tsv' module-attribute

FUEL_SPLIT_TSV = 'fuel-split.tsv' module-attribute

HEV = vehicle.HEV module-attribute

KG_2_LB = 2.20462 module-attribute

MARKET_SHARE_TSV = 'market-share.tsv' module-attribute

MOO_KNOB_SWEEP_PLOTS_DIR = Path(os.path.abspath(__file__)).parents[1] / 'tco_results' / 'knob_sweep_results' module-attribute

OPTIMIZATION_AND_TCO_RCRS = Path(os.path.abspath(__file__)).parents[1] / 'resources' module-attribute

OPTIMIZATION_DRIVE_CYCLES = OPTIMIZATION_AND_TCO_RCRS / 'cycles' module-attribute

OPTIMIZATION_RESOURCES_AUX = OPTIMIZATION_AND_TCO_RCRS / 'auxiliary' module-attribute

OTHER_INPUTS = OPTIMIZATION_RESOURCES_AUX / OTHER_INPUTS_FILE module-attribute

OTHER_INPUTS_FILE = 'OtherInputs.csv' module-attribute

PHEV = vehicle.PHEV module-attribute

PT_TYPES_NUM_TO_STR = {CONV: 'Conv', HEV: 'HEV', PHEV: 'PHEV', BEV: 'BEV'} module-attribute

REGIONAL_FUEL_PRICES_BY_TYPE_BY_YEAR = OPTIMIZATION_RESOURCES_AUX / 'FuelPrices.csv' module-attribute

REGIONAL_SALES_TSV = 'regional-sales.tsv' module-attribute

RESIDUAL_VALUE_PER_YEAR = OPTIMIZATION_RESOURCES_AUX / 'ResidualValues.csv' module-attribute

SURVIVAL_TSV = 'survival.tsv' module-attribute

SWEEP_PATH = Path(os.path.abspath(__file__)).parents[1] / 'sweep.py' module-attribute

T2COBENCHMARKDATADIR = OPTIMIZATION_AND_TCO_RCRS / 'benchmarkdata' module-attribute

T3CO_INPUTS_DIR = OPTIMIZATION_AND_TCO_RCRS / 'inputs' module-attribute

TCO = 'tests' module-attribute

TCO_INTERMEDIATES = None module-attribute

TCO_RESULTS = None module-attribute

TCO_RES_FIGS = None module-attribute

TESTCYCLES = TESTSDIR / 'test_cycles' module-attribute

TESTSCENARIOINPUTS = TESTSDIR / 'TCO_SCENARIO_TEST_INPUTS.csv' module-attribute

TESTSDIR = Path(os.path.abspath(__file__)).parents[1] / f'{TCO}/tco_tests' module-attribute

TESTVEHICLEINPUTS = TESTSDIR / 'TCO_VEHICLE_TEST_INPUTS.csv' module-attribute

TESTVEHICLES = TESTSDIR / 'test_vehicles' module-attribute

TRAVEL_EXP_TSV = 'travel-expense.tsv' module-attribute

VEH_EXP_TSV = 'vehicle-expense.tsv' module-attribute

evGVWRAllowanceLbs = 0 module-attribute

global_opt_range_cycle = None module-attribute

kgH2_per_gge = 1.019 module-attribute

kwh_per_gge = 33.7 module-attribute

m_to_mi = 0.000621371 module-attribute

maxGvwrKg = 0 module-attribute

mps_to_mph = 2.23694 module-attribute

vocation_scenario = None module-attribute

wkdir = Path(__file__).parent.parent module-attribute

write_files = False module-attribute

get_kwh_per_gge()

This is a getter for kwh_per_gge, sim and scenario dependant var that can change important to get from one location each time so we can track when and how it's used

Returns:

Name Type Description
kwh_per_gge float

kWh per Gasoline Gallon Equivalent

Source code in t3co/run/Global.py
Python
def get_kwh_per_gge():
    """
    This is a getter for kwh_per_gge, sim and scenario dependant var that can change
    important to get from one location each time so we can track when and how it's used

    Returns:
        kwh_per_gge (float): kWh per Gasoline Gallon Equivalent
    """
    return kwh_per_gge

kg_to_lbs(kgs: float) -> float

This function converts kg to lb

Parameters:

Name Type Description Default
kgs float

mass in kg

required

Returns:

Type Description
float

mass in pounds

Source code in t3co/run/Global.py
Python
def kg_to_lbs(kgs: float) -> float:
    """
    This function converts kg to lb

    Args:
        kgs (float): mass in kg

    Returns:
        (float): mass in pounds
    """
    return kgs * KG_2_LB

lbs_to_kgs(lbs: float) -> float

This function converts lb to kg

Parameters:

Name Type Description Default
lbs float

mass in pounds

required

Returns:

Type Description
float

mass in kg

Source code in t3co/run/Global.py
Python
def lbs_to_kgs(lbs: float) -> float:
    """
    This function converts lb to kg

    Args:
        lbs (float): mass in pounds

    Returns:
        (float): mass in kg
    """
    return lbs / KG_2_LB

not_falsy(var: float) -> bool

This function returns True to verify that var is NOT falsy: not in [None, np.nan, 0, False]

Parameters:

Name Type Description Default
var float

variable to check

required

Returns:

Type Description
bool

True if not in [None, 0, False]

Source code in t3co/run/Global.py
Python
def not_falsy(var: float) -> bool:
    """
    This function returns True to verify that var is NOT falsy: not in [None, np.nan, 0, False]


    Args:
        var (float): variable to check

    Returns:
        (bool): True if not in [None, 0, False]
    """
    return var not in [None, 0, False]

set_tco_intermediates()

This function sets path for TCO_INTERMEDIATES to save tsv files

Source code in t3co/run/Global.py
Python
def set_tco_intermediates():
    """
    This function sets path for TCO_INTERMEDIATES to save tsv files
    """
    global TCO_INTERMEDIATES

    # ./t3co/resources/f'vehicles/{vocation_scenario}/tco/tco_intermediates'
    TCO_INTERMEDIATES = (
        OPTIMIZATION_AND_TCO_RCRS
        / f"vehicles/{vocation_scenario}/tco/tco_intermediates"
    )
    if not TCO_INTERMEDIATES.exists():
        TCO_INTERMEDIATES.mkdir(parents=True)

set_tco_results()

This function sets path for TCO_RESULTS

Source code in t3co/run/Global.py
Python
def set_tco_results():
    """
    This function sets path for TCO_RESULTS
    """
    global TCO_RESULTS
    # ./t3co/resources/f'vehicles/{vocation_scenario}/tco/tco_results'
    TCO_RESULTS = (
        OPTIMIZATION_AND_TCO_RCRS / f"vehicles/{vocation_scenario}/tco/tco_results"
    )
    if not TCO_RESULTS.exists():
        TCO_RESULTS.mkdir(parents=True)

    global TCO_RES_FIGS
    # ./t3co/resources/f'vehicles/{vocation_scenario}/result_figures/'
    TCO_RES_FIGS = (
        OPTIMIZATION_AND_TCO_RCRS / f"vehicles/{vocation_scenario}/result_figures/"
    )
    if not TCO_RES_FIGS.exists():
        TCO_RES_FIGS.mkdir(parents=True)