Skip to content

Commit 8a0e2f4

Browse files
WIP - generate hip-ra-x-result.json - WIP to generate correct output categories
1 parent aacd314 commit 8a0e2f4

3 files changed

Lines changed: 224 additions & 1 deletion

File tree

src/geophires_x_schema_generator/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ all_messages_conf.log
33
!geophires-request.json
44
!geophires-result.json
55
!hip-ra-x-request.json
6+
!hip-ra-x-reult.json

src/geophires_x_schema_generator/__init__.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ def _fix_floating_point_error(val: Any) -> Any:
377377

378378

379379
class HipRaXSchemaGenerator(GeophiresXSchemaGenerator):
380+
# Single implicit category used to keep the result schema shape consistent
381+
# with the GEOPHIRES result schema (top-level properties -> category -> properties -> fields).
382+
# FIXME WIP refactor to reflect SUMMARY OF RESULTS and SUMMARY OF INPUTS categories
383+
_RESULT_CATEGORY: str = 'HIP-RA-X OUTPUTS'
384+
380385
def get_parameter_sources(self) -> list:
381386
"""
382387
:rtype: list[Tuple[Any, str]]
@@ -388,7 +393,35 @@ def get_schema_title(self) -> str:
388393
return 'HIP-RA-X'
389394

390395
def get_result_json_schema(self, output_params_json) -> dict:
391-
return None # FIXME TODO
396+
output_params = json.loads(output_params_json)
397+
398+
cat_properties = {}
399+
for param_name, output_param in output_params.items():
400+
description = _get_key(output_param, 'ToolTipText', default_val=None) or None
401+
units_val = output_param['CurrentUnits'] if isinstance(output_param.get('CurrentUnits'), str) else None
402+
cat_properties[param_name] = {
403+
'type': _get_key(output_param, 'json_parameter_type', default_val=None) or None,
404+
'description': description,
405+
'units': units_val,
406+
}
407+
408+
properties = {
409+
self._RESULT_CATEGORY: {
410+
'type': 'object',
411+
'properties': cat_properties,
412+
}
413+
}
414+
415+
result_schema = {
416+
'definitions': {},
417+
'$schema': 'http://json-schema.org/draft-04/schema#',
418+
'type': 'object',
419+
'title': f'{self.get_schema_title()} Result Schema',
420+
'required': [],
421+
'properties': properties,
422+
}
423+
424+
return result_schema
392425

393426
def get_output_params_table_rst(self, output_params_json) -> str:
394427
"""
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
{
2+
"definitions": {},
3+
"$schema": "http://json-schema.org/draft-04/schema#",
4+
"type": "object",
5+
"title": "HIP-RA-X Result Schema",
6+
"required": [],
7+
"properties": {
8+
"HIP-RA-X OUTPUTS": {
9+
"type": "object",
10+
"properties": {
11+
"Reservoir Volume (reservoir)": {
12+
"type": "number",
13+
"description": null,
14+
"units": "km**3"
15+
},
16+
"Reservoir Volume (rock)": {
17+
"type": "number",
18+
"description": null,
19+
"units": "km**3"
20+
},
21+
"Recoverable Volume (recoverable fluid)": {
22+
"type": "number",
23+
"description": null,
24+
"units": "km**3"
25+
},
26+
"Stored Heat (reservoir)": {
27+
"type": "number",
28+
"description": null,
29+
"units": "kJ"
30+
},
31+
"Stored Heat (rock)": {
32+
"type": "number",
33+
"description": null,
34+
"units": "kJ"
35+
},
36+
"Stored Heat (fluid)": {
37+
"type": "number",
38+
"description": null,
39+
"units": "kJ"
40+
},
41+
"Mass of Reservoir (total)": {
42+
"type": "number",
43+
"description": null,
44+
"units": "kilogram"
45+
},
46+
"Mass of Reservoir (rock)": {
47+
"type": "number",
48+
"description": null,
49+
"units": "kilogram"
50+
},
51+
"Mass of Reservoir (fluid)": {
52+
"type": "number",
53+
"description": null,
54+
"units": "kilogram"
55+
},
56+
"Specific Enthalpy (reservoir)": {
57+
"type": "number",
58+
"description": null,
59+
"units": "kJ/kg"
60+
},
61+
"Specific Enthalpy (rock)": {
62+
"type": "number",
63+
"description": null,
64+
"units": "kJ/kg"
65+
},
66+
"Specific Enthalpy (fluid)": {
67+
"type": "number",
68+
"description": null,
69+
"units": "kJ/kg"
70+
},
71+
"Wellhead Heat (reservoir)": {
72+
"type": "number",
73+
"description": null,
74+
"units": "kJ"
75+
},
76+
"Wellhead Heat (rock)": {
77+
"type": "number",
78+
"description": null,
79+
"units": "kJ"
80+
},
81+
"Wellhead Heat (fluid)": {
82+
"type": "number",
83+
"description": null,
84+
"units": "kJ"
85+
},
86+
"Recovery Factor (reservoir)": {
87+
"type": "number",
88+
"description": null,
89+
"units": "%"
90+
},
91+
"Recovery Factor (rock)": {
92+
"type": "number",
93+
"description": null,
94+
"units": "%"
95+
},
96+
"Recovery Factor (fluid)": {
97+
"type": "number",
98+
"description": null,
99+
"units": "%"
100+
},
101+
"Available Heat (reservoir)": {
102+
"type": "number",
103+
"description": null,
104+
"units": "kJ"
105+
},
106+
"Available Heat (rock)": {
107+
"type": "number",
108+
"description": null,
109+
"units": "kJ"
110+
},
111+
"Available Heat (fluid)": {
112+
"type": "number",
113+
"description": null,
114+
"units": "kJ"
115+
},
116+
"Producible Heat (reservoir)": {
117+
"type": "number",
118+
"description": null,
119+
"units": "kJ"
120+
},
121+
"Producible Heat (rock)": {
122+
"type": "number",
123+
"description": null,
124+
"units": "kJ"
125+
},
126+
"Producible Heat (fluid)": {
127+
"type": "number",
128+
"description": null,
129+
"units": "kJ"
130+
},
131+
"Producible Electricity (reservoir)": {
132+
"type": "number",
133+
"description": null,
134+
"units": "MW"
135+
},
136+
"Producible Electricity (rock)": {
137+
"type": "number",
138+
"description": null,
139+
"units": "MW"
140+
},
141+
"Producible Electricity (fluid)": {
142+
"type": "number",
143+
"description": null,
144+
"units": "MW"
145+
},
146+
"Producible Heat/Unit Area (reservoir)": {
147+
"type": "number",
148+
"description": null,
149+
"units": "kJ/km**2"
150+
},
151+
"Producible Heat/Unit Area (rock)": {
152+
"type": "number",
153+
"description": null,
154+
"units": "kJ/km**2"
155+
},
156+
"Producible Heat/Unit Area (fluid)": {
157+
"type": "number",
158+
"description": null,
159+
"units": "kJ/km**2"
160+
},
161+
"Producible Heat/Unit Volume (reservoir)": {
162+
"type": "number",
163+
"description": null,
164+
"units": "kJ/km**3"
165+
},
166+
"Producible Electricity/Unit Area (reservoir)": {
167+
"type": "number",
168+
"description": null,
169+
"units": "MW/km**2"
170+
},
171+
"Producible Electricity/Unit Area (rock)": {
172+
"type": "number",
173+
"description": null,
174+
"units": "MW/km**2"
175+
},
176+
"Producible Electricity/Unit Area (fluid)": {
177+
"type": "number",
178+
"description": null,
179+
"units": "MW/km**2"
180+
},
181+
"Producible Electricity/Unit Volume (reservoir)": {
182+
"type": "number",
183+
"description": null,
184+
"units": "MW/km**3"
185+
}
186+
}
187+
}
188+
}
189+
}

0 commit comments

Comments
 (0)