22from IPython .display import display # type: ignore
33import json # type: ignore
44import os # type: ignore
5- from .. import EquationExtractionResponse , VariableRequirement
5+ from .. import EquationProcessingResponse , VariableRequirement
6+ from typing import Dict , Any
67
78
89def _find_symbol (name , variable_dict ):
@@ -33,15 +34,15 @@ def _requirements_from_table(results, variable_dict):
3334 return requirements
3435
3536
36- def interactive_table (loaded_equations , file_path = "./custom_presets.json" ):
37+ def interactive_table (loaded_equations : EquationProcessingResponse , file_path : str = "./custom_presets.json" ):
3738 """
3839 Creates an interactive table for IMAGING_TELESCOPE,
3940 PAYLOAD, and user-defined custom templates.
4041 Adds or deletes rows, and can save custom templates persistently in JSON.
4142
4243 Parameters
4344 ----------
44- loaded_equations : EquationExtractionResponse
45+ loaded_equations : EquationProcessingResponse
4546 The extracted equations containing variable information
4647 file_path : str, optional
4748 JSON file path where we load and save user-created custom templates.
@@ -55,49 +56,35 @@ def interactive_table(loaded_equations, file_path="./custom_presets.json"):
5556 # ---------------------------------------------------------------
5657 # 1) Define built-in templates and units directly inside the function
5758 # ---------------------------------------------------------------
58- IMAGING_TELESCOPE_template = {
59- "Resolution (panchromatic)" : 0 ,
60- "Ground sampling distance (panchromatic)" : 0 ,
61- "Resolution (multispectral)" : 0 ,
62- "Ground sampling distance (multispectral)" : 0 ,
63- "Altitude" : 0 ,
64- "Half field of view" : 0 ,
65- "Mirror aperture" : 0 ,
66- "F-number" : 0 ,
67- "Focal length" : 0 ,
68- "Pixel size (panchromatic)" : 0 ,
69- "Pixel size (multispectral)" : 0 ,
70- "Swath width" : 0 ,
71- }
7259
7360 IMAGING_TELESCOPE = {
74- "Resolution (panchromatic) " : 1.23529 ,
75- "Ground sampling distance (panchromatic) " : 0.61765 ,
76- "Resolution (multispectral) " : 1.81176 ,
77- "Ground sampling distance (multispectral) " : 0.90588 ,
61+ "Resolved Ground Detail, Panchromatic " : 1.23529 ,
62+ "Ground Sample Distance, Panchromatic " : 0.61765 ,
63+ "Resolved Ground Detail, Multispectral " : 1.81176 ,
64+ "Ground Sample Distance, Multispectral " : 0.90588 ,
7865 "Altitude" : 420000 ,
79- "Half field of view " : 0.017104227 ,
80- "Mirror aperture " : 0.85 ,
81- "F -number" : 6.0 ,
66+ "Horizontal Field of View " : 0.017104227 ,
67+ "Aperture diameter " : 0.85 ,
68+ "f -number" : 6.0 ,
8269 "Focal length" : 5.1 ,
83- "Pixel size (panchromatic) " : 7.5e-6 ,
84- "Pixel size ( multispectral) " : 11e-6 ,
85- "Swath width " : 14368.95 ,
70+ "Pixel pitch " : 7.5e-6 ,
71+ "Pixel pitch of the multispectral sensor " : 11e-6 ,
72+ "Swath Width " : 14368.95 ,
8673 }
8774
8875 IMAGING_TELESCOPE_UNITS = {
89- "Resolution (panchromatic) " : "m" ,
90- "Ground sampling distance (panchromatic) " : "m" ,
91- "Resolution (multispectral) " : "m" ,
92- "Ground sampling distance (multispectral) " : "m" ,
76+ "Resolved Ground Detail, Panchromatic " : "m" ,
77+ "Ground Sample Distance, Panchromatic " : "m" ,
78+ "Resolved Ground Detail, Multispectral " : "m" ,
79+ "Ground Sample Distance, Multispectral " : "m" ,
9380 "Altitude" : "m" ,
94- "Half field of view " : "rad" ,
95- "Mirror aperture " : "m" ,
96- "F -number" : "dimensionless" ,
81+ "Horizontal Field of View " : "rad" ,
82+ "Aperture diameter " : "m" ,
83+ "f -number" : "dimensionless" ,
9784 "Focal length" : "m" ,
98- "Pixel size (panchromatic) " : "m" ,
99- "Pixel size ( multispectral) " : "m" ,
100- "Swath width " : "m" ,
85+ "Pixel pitch " : "m" ,
86+ "Pixel pitch of the multispectral sensor " : "m" ,
87+ "Swath Width " : "m" ,
10188 }
10289
10390 PAYLOAD_1 = {
@@ -120,7 +107,6 @@ def interactive_table(loaded_equations, file_path="./custom_presets.json"):
120107 preset_options_dict = {
121108 "Select a template" : [],
122109 "IMAGING TELESCOPE" : list (IMAGING_TELESCOPE .keys ()),
123- "IMAGING TELESCOPE template" : list (IMAGING_TELESCOPE_template .keys ()),
124110 "PAYLOAD" : list (PAYLOAD_1 .keys ()),
125111 }
126112
@@ -170,7 +156,7 @@ def save_custom_presets(custom_data, file_path):
170156 name_label_width = ["150px" ]
171157
172158 # Dictionary to keep track of row widget references
173- value_widgets = {}
159+ value_widgets : Dict [ str , Any ] = {}
174160
175161 # ---------------------------------------------------------------
176162 # 6) display_table(change): Re-populate rows when user selects a template
@@ -272,11 +258,6 @@ def submit_values(_):
272258 result ["values" ] = updated_values
273259 requirements_result [0 ] = _requirements_from_table (result , variable_dict )
274260
275- # Display a confirmation message
276- with message_output :
277- message_output .clear_output ()
278- print ("Requirements submitted successfully!" )
279-
280261 return requirements_result [0 ]
281262
282263 # ---------------------------------------------------------------
@@ -382,14 +363,14 @@ def save_requirements(_):
382363 return requirements_result
383364
384365
385- def _create_variable_dict (equation_response : EquationExtractionResponse ) -> dict :
366+ def _create_variable_dict (equation_response : EquationProcessingResponse ) -> dict :
386367 """
387- Creates a variable dictionary from an EquationExtractionResponse object
368+ Creates a variable dictionary from an EquationProcessingResponse object
388369 for use with the interactive_table function.
389370
390371 Parameters
391372 ----------
392- equation_response : EquationExtractionResponse
373+ equation_response : EquationProcessingResponse
393374 The equation extraction response containing equations and their symbols
394375
395376 Returns
@@ -406,9 +387,14 @@ def _create_variable_dict(equation_response: EquationExtractionResponse) -> dict
406387
407388 # Iterate through all equations and their symbols
408389 for equation in equation_response .equations :
409- for symbol in equation .latex_symbols :
390+
391+ wolfram_symbols = equation .wolfram_symbols
392+ latex_symbols = [equation .latex_symbols [i ].key for i in range (len (equation .latex_symbols ))]
393+ names = [equation .latex_symbols [i ].value for i in range (len (equation .latex_symbols ))]
394+
395+ for symbol , name in zip (wolfram_symbols , names ):
410396 # Only add if not already present (avoid duplicates)
411- if symbol . key not in variable_dict :
412- variable_dict [symbol . key ] = {"name" : symbol . value }
397+ if symbol not in variable_dict :
398+ variable_dict [symbol ] = {"name" : name }
413399
414400 return variable_dict
0 commit comments