Exemple #1
0
def test_cycle_retrieval_default():
    dc = get_standard_driving_cycle()
    assert isinstance(dc, np.ndarray)
    assert dc.sum() == 83744.6
Exemple #2
0
def test_missing_cycle():
    with pytest.raises(SystemExit) as wrapped_error:
        get_standard_driving_cycle("Foo")
    assert wrapped_error.type == SystemExit
    assert wrapped_error.value.code == 1
Exemple #3
0
def test_cycle_retrieval_cadc():
    dc = get_standard_driving_cycle("CADC")
    assert isinstance(dc, np.ndarray)
    assert dc.sum() == 186074.2
Exemple #4
0
def test_cycle_retrieval_nedc():
    dc = get_standard_driving_cycle("NEDC")
    assert isinstance(dc, np.ndarray)
    assert dc.sum() == 39353.0
Exemple #5
0
def test_cycle_retrieval_wltc():
    dc = get_standard_driving_cycle("WLTC")
    assert isinstance(dc, np.ndarray)
    assert dc.sum() == 83744.6
from carculator.driving_cycles import get_standard_driving_cycle
from carculator.hot_emissions import HotEmissionsModel
import numpy as np
import pytest

dc = get_standard_driving_cycle()
dc_name = "WLTC"


def test_wrong_powertrain():
    hem = HotEmissionsModel(dc, dc_name)
    with pytest.raises(TypeError) as wrapped_error:
        hem.get_emissions_per_powertrain("electric")
    assert wrapped_error.type == TypeError


def test_output_emissions():
    hem = HotEmissionsModel(dc, dc_name)
    em = hem.get_emissions_per_powertrain("diesel", euro_class=6)

    # Carbon monoxide emission, diesel
    assert em[:, 3:6, :, :].sum() > 0.000013
    assert em[:, 3:6, :, :].sum() < 0.000016

    # Particulate matter emission, diesel
    assert em[:, 9:12, :, :].sum() > 3.7e-7
    assert em[:, 9:12, :, :].sum() < 3.8e-7

    # Euro-6d NOx emission limit, diesel
    assert em[:, 6:9, :, :].sum() < 8e-5