Jfink09 commited on
Commit
e63fc58
·
verified ·
1 Parent(s): 415ec57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -56,11 +56,11 @@ def calculate_magnitude_and_axis(j0, j45):
56
  if j0 != 0:
57
  Z = math.degrees(0.5 * math.atan(j45 / j0))
58
  else:
59
- Z = 90 # This matches Excel's behavior when A2 (j0) is zero
60
 
61
  # Apply the conditional logic
62
  if j0 > 0:
63
- if j45 >= 0: # Changed to >= to match Excel's behavior
64
  final_axis = Z
65
  else:
66
  final_axis = Z + 180
@@ -70,7 +70,7 @@ def calculate_magnitude_and_axis(j0, j45):
70
  # Ensure the final axis is between 0 and 180
71
  final_axis = final_axis % 180
72
 
73
- return magnitude, final_axis
74
 
75
  def main():
76
  st.set_page_config(page_title='Astigmatism Prediction', page_icon=':eyeglasses:', layout='wide')
@@ -91,7 +91,7 @@ def main():
91
  new_j0, new_j45 = predict_new_j0_j45(age, aca_magnitude, aca_axis)
92
 
93
  # Calculate predicted magnitude and axis
94
- predicted_magnitude, predicted_axis = calculate_magnitude_and_axis(new_j0, new_j45)
95
 
96
  st.success(f'Predicted Total Corneal Astigmatism Magnitude: {predicted_magnitude:.2f} D')
97
  st.success(f'Predicted Total Corneal Astigmatism Axis: {predicted_axis:.1f}°')
@@ -99,6 +99,7 @@ def main():
99
  # Display intermediate values for verification
100
  st.info(f'Initial J0: {initial_j0:.2f}, Initial J45: {initial_j45:.2f}')
101
  st.info(f'Predicted J0: {new_j0:.2f}, Predicted J45: {new_j45:.2f}')
 
102
  st.info(f'ACA Axis (Degrees): {aca_axis:.2f}°, ACA Axis (Radians): {math.radians(aca_axis):.4f}')
103
  else:
104
  st.error('Please ensure all inputs are within the specified ranges.')
 
56
  if j0 != 0:
57
  Z = math.degrees(0.5 * math.atan(j45 / j0))
58
  else:
59
+ Z = 90 # This matches Excel's behavior when j0 is zero
60
 
61
  # Apply the conditional logic
62
  if j0 > 0:
63
+ if j45 >= 0:
64
  final_axis = Z
65
  else:
66
  final_axis = Z + 180
 
70
  # Ensure the final axis is between 0 and 180
71
  final_axis = final_axis % 180
72
 
73
+ return magnitude, final_axis, Z
74
 
75
  def main():
76
  st.set_page_config(page_title='Astigmatism Prediction', page_icon=':eyeglasses:', layout='wide')
 
91
  new_j0, new_j45 = predict_new_j0_j45(age, aca_magnitude, aca_axis)
92
 
93
  # Calculate predicted magnitude and axis
94
+ predicted_magnitude, predicted_axis, Z = calculate_magnitude_and_axis(new_j0, new_j45)
95
 
96
  st.success(f'Predicted Total Corneal Astigmatism Magnitude: {predicted_magnitude:.2f} D')
97
  st.success(f'Predicted Total Corneal Astigmatism Axis: {predicted_axis:.1f}°')
 
99
  # Display intermediate values for verification
100
  st.info(f'Initial J0: {initial_j0:.2f}, Initial J45: {initial_j45:.2f}')
101
  st.info(f'Predicted J0: {new_j0:.2f}, Predicted J45: {new_j45:.2f}')
102
+ st.info(f'Intermediate Z: {Z:.2f}°')
103
  st.info(f'ACA Axis (Degrees): {aca_axis:.2f}°, ACA Axis (Radians): {math.radians(aca_axis):.4f}')
104
  else:
105
  st.error('Please ensure all inputs are within the specified ranges.')