Reputation: 176
I wrote a python script that determines what arrow spine to use according to a users insert weight, draw length, and poundage weight (in that order) according to the attached chart (Top row is draw length, side column is bow poundages, and where those two inputs intersect is the spine to be used. So essentially the "sorting" process of this chart is by insert weight (only 2 options) ==> draw length ==> bow poundage ==> spine to be used. I hard coded everything as a first time project but I just feel there is a better way to go about this and cut the amount of code down. Below is an example of the code. Repo can be found here: https://github.com/wayoh22/Easton-Arrow-Spine-Calculator/blob/main/Arrow_Spine_Calculator.py
Arrow Spine chart . Any help is appreciated.
raw_draw_length = input("Enter Draw Length (Round to Nearest Quarter Inch): ")
raw_bow_poundage = input("Enter Bow Poundage: ")
grain_insert_list = int(50) or int(75)
draw_length_list = [23.0, 23.25, 23.5, 23.75, 24.0, 24.25, 24.25, 24.5, 24.75, 25.0, 25.25, 25.5, 25.75, 26.0, 26.25, 26.5, 26.75, 27.0, 27.25, 27.5, 27.75, 28.0, 28.25, 28.5, 28.75, 29.0, 29.25, 29.5, 29.75, 30.0, 30.25, 30.5, 30.75, 31.0, 31.25, 31.5, 31.75, 32.0]
bow_poundage_list = range(23,86)
arrow_choice = "raw_arrow_input"
grain_insert = int(raw_grain_input)
draw_length = float(raw_draw_length)
bow_poundage = int(raw_bow_poundage)
if grain_insert != int(50) and grain_insert != int(75):
print ("Grainage not Supported")
if grain_insert == int(50):
if draw_length < float(23):
print("Draw Length Not Supported")
elif draw_length >= float(23.0) and draw_length <= float(23.4):
if bow_poundage < 69:
print("Bow Poundage not Supported")
if bow_poundage in range(69,86):
print("400 Spine")
if bow_poundage > 85:
print("Bow Poundage not Supported")
Upvotes: 0
Views: 62
Reputation: 117661
I'm going off the image you included:
Note that every column in your table always follow the same pattern:
col = [[400], [400], [400], [340], [340,300], [300], [300,260], [260]]
Then,
poundage_breakpoints = [23, 28, 33, 38, 43, 48, 53, 58, 63, 69, 75, 81, 86]
row_idx = min((i for i, bp in enumerate(poundage_breakpoints)
if bow_poundage >= bp),
default=None)
if row_idx == len(poundage_breakpoints) - 1 or row_idx is None:
print("Bow poundage not supported.")
return
Now we have the row index into our table. We can also easily compute the column index:
if not (23 <= draw_length <= 32):
print("Draw length not supported.")
return
col_idx = int(draw_length - 23)
Now for the final trick (to shift the column as we see in the table):
num_cols = 32 - 23 + 1
effective_row_idx = row_idx - (num_cols - 1 - col_idx)
if not (0 <= effective_row_idx < len(col)):
print("Bow poundage not supported.")
return
spines = col[effective_row_idx]
print(" or ".join(str(s) for s in spines) + " spine.")
Upvotes: 2