2
2
from IPython .display import display # type: ignore
3
3
import json # type: ignore
4
4
import os # type: ignore
5
- from .. import EquationExtractionResponse , VariableRequirement
5
+ from .. import EquationProcessingResponse , VariableRequirement
6
+ from typing import Dict , Any
6
7
7
8
8
9
def _find_symbol (name , variable_dict ):
@@ -33,15 +34,15 @@ def _requirements_from_table(results, variable_dict):
33
34
return requirements
34
35
35
36
36
- def interactive_table (loaded_equations , file_path = "./custom_presets.json" ):
37
+ def interactive_table (loaded_equations : EquationProcessingResponse , file_path : str = "./custom_presets.json" ):
37
38
"""
38
39
Creates an interactive table for IMAGING_TELESCOPE,
39
40
PAYLOAD, and user-defined custom templates.
40
41
Adds or deletes rows, and can save custom templates persistently in JSON.
41
42
42
43
Parameters
43
44
----------
44
- loaded_equations : EquationExtractionResponse
45
+ loaded_equations : EquationProcessingResponse
45
46
The extracted equations containing variable information
46
47
file_path : str, optional
47
48
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"):
55
56
# ---------------------------------------------------------------
56
57
# 1) Define built-in templates and units directly inside the function
57
58
# ---------------------------------------------------------------
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
- }
72
59
73
60
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 ,
78
65
"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 ,
82
69
"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 ,
86
73
}
87
74
88
75
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" ,
93
80
"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" ,
97
84
"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" ,
101
88
}
102
89
103
90
PAYLOAD_1 = {
@@ -120,7 +107,6 @@ def interactive_table(loaded_equations, file_path="./custom_presets.json"):
120
107
preset_options_dict = {
121
108
"Select a template" : [],
122
109
"IMAGING TELESCOPE" : list (IMAGING_TELESCOPE .keys ()),
123
- "IMAGING TELESCOPE template" : list (IMAGING_TELESCOPE_template .keys ()),
124
110
"PAYLOAD" : list (PAYLOAD_1 .keys ()),
125
111
}
126
112
@@ -170,7 +156,7 @@ def save_custom_presets(custom_data, file_path):
170
156
name_label_width = ["150px" ]
171
157
172
158
# Dictionary to keep track of row widget references
173
- value_widgets = {}
159
+ value_widgets : Dict [ str , Any ] = {}
174
160
175
161
# ---------------------------------------------------------------
176
162
# 6) display_table(change): Re-populate rows when user selects a template
@@ -272,11 +258,6 @@ def submit_values(_):
272
258
result ["values" ] = updated_values
273
259
requirements_result [0 ] = _requirements_from_table (result , variable_dict )
274
260
275
- # Display a confirmation message
276
- with message_output :
277
- message_output .clear_output ()
278
- print ("Requirements submitted successfully!" )
279
-
280
261
return requirements_result [0 ]
281
262
282
263
# ---------------------------------------------------------------
@@ -382,14 +363,14 @@ def save_requirements(_):
382
363
return requirements_result
383
364
384
365
385
- def _create_variable_dict (equation_response : EquationExtractionResponse ) -> dict :
366
+ def _create_variable_dict (equation_response : EquationProcessingResponse ) -> dict :
386
367
"""
387
- Creates a variable dictionary from an EquationExtractionResponse object
368
+ Creates a variable dictionary from an EquationProcessingResponse object
388
369
for use with the interactive_table function.
389
370
390
371
Parameters
391
372
----------
392
- equation_response : EquationExtractionResponse
373
+ equation_response : EquationProcessingResponse
393
374
The equation extraction response containing equations and their symbols
394
375
395
376
Returns
@@ -406,9 +387,14 @@ def _create_variable_dict(equation_response: EquationExtractionResponse) -> dict
406
387
407
388
# Iterate through all equations and their symbols
408
389
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 ):
410
396
# 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 }
413
399
414
400
return variable_dict
0 commit comments