Homework2 / salvage_table_data.py
rylieweber's picture
Upload 4 files
0c8aa0f verified
# salvage_table_data.py β€” exact values transcribed from Iowa State PM 710 (Tables 1a & 1b)
# Format:
# For tractors & combines: nested by annual-hours band β†’ { age(years): fraction_of_new_price }
# For implements (Table 1b): single band 0 β†’ { age: fraction } (age-only, no hours dependence)
SALVAGE_TABLE = {
# ---------- Table 1a: TRACTORS ----------
"30-79 hp tractor": {
200: {1:0.65, 2:0.59, 3:0.54, 4:0.51, 5:0.48, 6:0.45, 7:0.42, 8:0.40, 9:0.38,10:0.36,
11:0.35,12:0.33,13:0.32,14:0.30,15:0.29,16:0.28,17:0.26,18:0.25,19:0.24,20:0.23},
400: {1:0.60, 2:0.54, 3:0.49, 4:0.46, 5:0.43, 6:0.40, 7:0.38, 8:0.36, 9:0.34,10:0.32,
11:0.31,12:0.29,13:0.28,14:0.27,15:0.25,16:0.24,17:0.23,18:0.22,19:0.21,20:0.20},
600: {1:0.56, 2:0.50, 3:0.46, 4:0.43, 5:0.40, 6:0.37, 7:0.35, 8:0.33, 9:0.31,10:0.30,
11:0.28,12:0.27,13:0.25,14:0.24,15:0.23,16:0.22,17:0.21,18:0.20,19:0.19,20:0.18},
},
"80-149 hp tractor": {
200: {1:0.69, 2:0.62, 3:0.57, 4:0.53, 5:0.50, 6:0.47, 7:0.44, 8:0.42, 9:0.40,10:0.38,
11:0.36,12:0.34,13:0.33,14:0.31,15:0.30,16:0.28,17:0.27,18:0.26,19:0.25,20:0.24},
400: {1:0.68, 2:0.62, 3:0.57, 4:0.53, 5:0.49, 6:0.46, 7:0.44, 8:0.41, 9:0.39,10:0.37,
11:0.35,12:0.34,13:0.32,14:0.31,15:0.29,16:0.28,17:0.27,18:0.25,19:0.24,20:0.23},
600: {1:0.68, 2:0.61, 3:0.56, 4:0.52, 5:0.49, 6:0.46, 7:0.43, 8:0.41, 9:0.39,10:0.37,
11:0.35,12:0.33,13:0.32,14:0.30,15:0.29,16:0.27,17:0.26,18:0.25,19:0.24,20:0.23},
},
"150+ hp tractor": {
200: {1:0.69, 2:0.61, 3:0.55, 4:0.51, 5:0.47, 6:0.43, 7:0.40, 8:0.38, 9:0.35,10:0.33,
11:0.31,12:0.29,13:0.27,14:0.25,15:0.24,16:0.22,17:0.21,18:0.20,19:0.19,20:0.17},
400: {1:0.67, 2:0.59, 3:0.54, 4:0.49, 5:0.45, 6:0.42, 7:0.39, 8:0.36, 9:0.34,10:0.32,
11:0.30,12:0.28,13:0.26,14:0.24,15:0.23,16:0.21,17:0.20,18:0.19,19:0.18,20:0.17},
600: {1:0.66, 2:0.58, 3:0.52, 4:0.48, 5:0.44, 6:0.41, 7:0.38, 8:0.35, 9:0.33,10:0.31,
11:0.29,12:0.27,13:0.25,14:0.24,15:0.22,16:0.21,17:0.19,18:0.18,19:0.17,20:0.16},
},
# ---------- Table 1a: COMBINE / FORAGE HARVESTER ----------
"combine/forage harvester": {
100: {1:0.79, 2:0.67, 3:0.59, 4:0.52, 5:0.47, 6:0.42, 7:0.38, 8:0.35, 9:0.31,10:0.28,
11:0.26,12:0.23,13:0.21,14:0.19,15:0.17,16:0.16,17:0.14,18:0.13,19:0.11,20:0.10},
300: {1:0.69, 2:0.58, 3:0.50, 4:0.44, 5:0.39, 6:0.35, 7:0.31, 8:0.28, 9:0.25,10:0.23,
11:0.20,12:0.18,13:0.16,14:0.14,15:0.13,16:0.11,17:0.10,18:0.09,19:0.08,20:0.07},
500: {1:0.63, 2:0.52, 3:0.45, 4:0.39, 5:0.34, 6:0.30, 7:0.27, 8:0.24, 9:0.21,10:0.19,
11:0.17,12:0.15,13:0.13,14:0.12,15:0.10,16:0.09,17:0.08,18:0.07,19:0.06,20:0.05},
},
# ---------- Table 1b: IMPLEMENTS (age-only) ----------
"plows": { 0: {1:0.47, 2:0.44, 3:0.42, 4:0.40, 5:0.39, 6:0.38, 7:0.36, 8:0.35, 9:0.34,10:0.33,
11:0.32,12:0.32,13:0.31,14:0.30,15:0.29,16:0.29,17:0.28,18:0.27,19:0.27,20:0.26}},
"other tillage": { 0: {1:0.61, 2:0.54, 3:0.49, 4:0.45, 5:0.42, 6:0.39, 7:0.36, 8:0.34, 9:0.31,10:0.30,
11:0.28,12:0.26,13:0.24,14:0.23,15:0.22,16:0.20,17:0.19,18:0.18,19:0.17,20:0.16}},
"planter, drill, sprayer": { 0: {1:0.65, 2:0.60, 3:0.56, 4:0.53, 5:0.50, 6:0.48, 7:0.46, 8:0.44, 9:0.42,10:0.40,
11:0.39,12:0.38,13:0.36,14:0.35,15:0.34,16:0.33,17:0.32,18:0.30,19:0.29,20:0.29}},
"mower, chopper": { 0: {1:0.47, 2:0.44, 3:0.41, 4:0.39, 5:0.37, 6:0.35, 7:0.33, 8:0.32, 9:0.31,10:0.30,
11:0.28,12:0.27,13:0.26,14:0.26,15:0.25,16:0.24,17:0.23,18:0.22,19:0.22,20:0.21}},
"baler": { 0: {1:0.56, 2:0.50, 3:0.46, 4:0.42, 5:0.39, 6:0.37, 7:0.34, 8:0.32, 9:0.30,10:0.28,
11:0.27,12:0.25,13:0.24,14:0.22,15:0.21,16:0.20,17:0.19,18:0.18,19:0.17,20:0.16}},
"swather, rake": { 0: {1:0.49, 2:0.44, 3:0.40, 4:0.37, 5:0.35, 6:0.32, 7:0.30, 8:0.28, 9:0.27,10:0.25,
11:0.24,12:0.23,13:0.21,14:0.20,15:0.19,16:0.18,17:0.17,18:0.16,19:0.16,20:0.15}},
"vehicle": { 0: {1:0.42, 2:0.39, 3:0.36, 4:0.34, 5:0.33, 6:0.31, 7:0.30, 8:0.29, 9:0.27,10:0.26,
11:0.25,12:0.24,13:0.24,14:0.23,15:0.22,16:0.21,17:0.20,18:0.20,19:0.19,20:0.19}},
"others": { 0: {1:0.69, 2:0.62, 3:0.56, 4:0.52, 5:0.48, 6:0.45, 7:0.42, 8:0.40, 9:0.37,10:0.35,
11:0.33,12:0.31,13:0.29,14:0.28,15:0.26,16:0.25,17:0.24,18:0.22,19:0.21,20:0.20}},
}
# salvage_table_data.py (at the end)
# Make a case-insensitive view
# --- Normalize keys so lookups are case-insensitive and space-insensitive ---
def _norm_key(s: str) -> str:
return "".join(s.lower().split()) # lowercase + remove all whitespace
# Build a normalized alias map (in addition to the original keys)
_SALV_NORM = {}
for k, v in list(SALVAGE_TABLE.items()):
if isinstance(k, str):
_SALV_NORM[_norm_key(k)] = v
# Public accessor dict: original keys + normalized clones
SALVAGE_TABLE_NORM = dict(_SALV_NORM)