@sh.add_function(dsp, outputs=['tyre_code'], weight=5)
def default_tyre_code(r_dynamic):
"""
Return one of the most popular tyre code according to the r dynamic.
:param r_dynamic:
Dynamic radius of the wheels [m].
:type r_dynamic: float
:return:
Tyre code (e.g.,P225/70R14).
:rtype: str
"""
pop = (
'165/65R13', '155/70R13', '165/70R13', '165/60R14', '185/60R14',
'155/65R14', '165/65R14', '175/65R14', '185/65R14', '165/70R14',
'175/70R14', '195/50R15', '185/55R15', '195/55R15', '185/60R15',
'195/60R15', '205/60R15', '175/65R15', '185/65R15', '195/65R15',
'195/70R15', '195/45R16', '205/45R16', '205/50R16', '195/55R16',
'205/55R16', '215/55R16', '205/60R16', '215/60R16', '215/65R16',
'205/40R17', '245/40R17', '205/45R17', '215/45R17', '225/45R17',
'235/45R17', '205/50R17', '215/50R17', '225/50R17', '215/55R17',
'225/55R17', '215/60R17', '225/65R17', '235/65R17', '225/40R18',
'235/40R18', '245/40R18', '225/45R18', '235/60R18', '255/35R19'
)
def _key_func(c):
r = calculate_r_wheels(calculate_tyre_dimensions(c))
return r <= r_dynamic, (r - r_dynamic) ** 2
return min(pop, key=_key_func)