ras-commander 0.73.0__py3-none-any.whl → 0.74.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ras_commander/Decorators.py +68 -17
- ras_commander/HdfPlan.py +8 -4
- ras_commander/RasPlan.py +46 -12
- ras_commander/__init__.py +1 -1
- {ras_commander-0.73.0.dist-info → ras_commander-0.74.0.dist-info}/METADATA +1 -1
- {ras_commander-0.73.0.dist-info → ras_commander-0.74.0.dist-info}/RECORD +9 -9
- {ras_commander-0.73.0.dist-info → ras_commander-0.74.0.dist-info}/WHEEL +0 -0
- {ras_commander-0.73.0.dist-info → ras_commander-0.74.0.dist-info}/licenses/LICENSE +0 -0
- {ras_commander-0.73.0.dist-info → ras_commander-0.74.0.dist-info}/top_level.txt +0 -0
ras_commander/Decorators.py
CHANGED
@@ -110,13 +110,17 @@ def standardize_input(file_type: str = 'plan_hdf'):
|
|
110
110
|
except Exception as e:
|
111
111
|
raise ValueError(f"RAS object is not initialized: {str(e)}")
|
112
112
|
|
113
|
+
# Extract the number part and strip leading zeros
|
113
114
|
number_str = hdf_input if hdf_input.isdigit() else hdf_input[1:]
|
114
|
-
|
115
|
+
stripped_number = number_str.lstrip('0')
|
116
|
+
if stripped_number == '': # Handle case where input was '0' or '00'
|
117
|
+
stripped_number = '0'
|
118
|
+
number_int = int(stripped_number)
|
115
119
|
|
116
120
|
if file_type == 'plan_hdf':
|
117
121
|
try:
|
118
|
-
# Convert plan_number column to integers for comparison
|
119
|
-
plan_info = ras_obj.plan_df[ras_obj.plan_df['plan_number'].astype(int) == number_int]
|
122
|
+
# Convert plan_number column to integers for comparison after stripping zeros
|
123
|
+
plan_info = ras_obj.plan_df[ras_obj.plan_df['plan_number'].str.lstrip('0').astype(int) == number_int]
|
120
124
|
if not plan_info.empty:
|
121
125
|
# Make sure HDF_Results_Path is a string and not None
|
122
126
|
hdf_path_str = plan_info.iloc[0]['HDF_Results_Path']
|
@@ -128,12 +132,35 @@ def standardize_input(file_type: str = 'plan_hdf'):
|
|
128
132
|
|
129
133
|
elif file_type == 'geom_hdf':
|
130
134
|
try:
|
131
|
-
#
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
# First try to get the geometry number from the plan
|
136
|
+
from ras_commander import RasPlan
|
137
|
+
plan_info = ras_obj.plan_df[ras_obj.plan_df['plan_number'].astype(int) == number_int]
|
138
|
+
if not plan_info.empty:
|
139
|
+
# Extract the geometry number from the plan
|
140
|
+
geom_number = plan_info.iloc[0]['geometry_number']
|
141
|
+
if pd.notna(geom_number) and geom_number is not None:
|
142
|
+
# Handle different types of geom_number (string or int)
|
143
|
+
try:
|
144
|
+
# Get the geometry path using RasPlan
|
145
|
+
geom_path = RasPlan.get_geom_path(str(geom_number), ras_obj)
|
146
|
+
|
147
|
+
if geom_path is not None:
|
148
|
+
# Create the HDF path by adding .hdf to the geometry path
|
149
|
+
hdf_path = Path(str(geom_path) + ".hdf")
|
150
|
+
if hdf_path.exists():
|
151
|
+
logger.info(f"Found geometry HDF file for plan {number_int}: {hdf_path}")
|
152
|
+
else:
|
153
|
+
# Try to find it in the geom_df if direct path doesn't exist
|
154
|
+
geom_info = ras_obj.geom_df[ras_obj.geom_df['full_path'] == str(geom_path)]
|
155
|
+
if not geom_info.empty and 'hdf_path' in geom_info.columns:
|
156
|
+
hdf_path_str = geom_info.iloc[0]['hdf_path']
|
157
|
+
if pd.notna(hdf_path_str):
|
158
|
+
hdf_path = Path(str(hdf_path_str))
|
159
|
+
logger.info(f"Found geometry HDF file from geom_df for plan {number_int}: {hdf_path}")
|
160
|
+
except (TypeError, ValueError) as e:
|
161
|
+
logger.warning(f"Error processing geometry number {geom_number}: {str(e)}")
|
162
|
+
else:
|
163
|
+
logger.warning(f"No valid geometry number found for plan {number_int}")
|
137
164
|
except Exception as e:
|
138
165
|
logger.warning(f"Error retrieving geometry HDF path: {str(e)}")
|
139
166
|
else:
|
@@ -153,8 +180,8 @@ def standardize_input(file_type: str = 'plan_hdf'):
|
|
153
180
|
|
154
181
|
if file_type == 'plan_hdf':
|
155
182
|
try:
|
156
|
-
# Convert plan_number column to integers for comparison
|
157
|
-
plan_info = ras_obj.plan_df[ras_obj.plan_df['plan_number'].astype(int) == number_int]
|
183
|
+
# Convert plan_number column to integers for comparison after stripping zeros
|
184
|
+
plan_info = ras_obj.plan_df[ras_obj.plan_df['plan_number'].str.lstrip('0').astype(int) == number_int]
|
158
185
|
if not plan_info.empty:
|
159
186
|
# Make sure HDF_Results_Path is a string and not None
|
160
187
|
hdf_path_str = plan_info.iloc[0]['HDF_Results_Path']
|
@@ -162,14 +189,38 @@ def standardize_input(file_type: str = 'plan_hdf'):
|
|
162
189
|
hdf_path = Path(str(hdf_path_str))
|
163
190
|
except Exception as e:
|
164
191
|
logger.warning(f"Error retrieving plan HDF path: {str(e)}")
|
192
|
+
|
165
193
|
elif file_type == 'geom_hdf':
|
166
194
|
try:
|
167
|
-
#
|
168
|
-
|
169
|
-
if not
|
170
|
-
|
171
|
-
|
172
|
-
|
195
|
+
# First try finding plan info to get geometry number
|
196
|
+
plan_info = ras_obj.plan_df[ras_obj.plan_df['plan_number'].astype(int) == number_int]
|
197
|
+
if not plan_info.empty:
|
198
|
+
# Extract the geometry number from the plan
|
199
|
+
geom_number = plan_info.iloc[0]['geometry_number']
|
200
|
+
if pd.notna(geom_number) and geom_number is not None:
|
201
|
+
# Handle different types of geom_number (string or int)
|
202
|
+
try:
|
203
|
+
# Get the geometry path using RasPlan
|
204
|
+
from ras_commander import RasPlan
|
205
|
+
geom_path = RasPlan.get_geom_path(str(geom_number), ras_obj)
|
206
|
+
|
207
|
+
if geom_path is not None:
|
208
|
+
# Create the HDF path by adding .hdf to the geometry path
|
209
|
+
hdf_path = Path(str(geom_path) + ".hdf")
|
210
|
+
if hdf_path.exists():
|
211
|
+
logger.info(f"Found geometry HDF file for plan {number_int}: {hdf_path}")
|
212
|
+
else:
|
213
|
+
# Try to find it in the geom_df if direct path doesn't exist
|
214
|
+
geom_info = ras_obj.geom_df[ras_obj.geom_df['full_path'] == str(geom_path)]
|
215
|
+
if not geom_info.empty and 'hdf_path' in geom_info.columns:
|
216
|
+
hdf_path_str = geom_info.iloc[0]['hdf_path']
|
217
|
+
if pd.notna(hdf_path_str):
|
218
|
+
hdf_path = Path(str(hdf_path_str))
|
219
|
+
logger.info(f"Found geometry HDF file from geom_df for plan {number_int}: {hdf_path}")
|
220
|
+
except (TypeError, ValueError) as e:
|
221
|
+
logger.warning(f"Error processing geometry number {geom_number}: {str(e)}")
|
222
|
+
else:
|
223
|
+
logger.warning(f"No valid geometry number found for plan {number_int}")
|
173
224
|
except Exception as e:
|
174
225
|
logger.warning(f"Error retrieving geometry HDF path: {str(e)}")
|
175
226
|
else:
|
ras_commander/HdfPlan.py
CHANGED
@@ -280,17 +280,18 @@ class HdfPlan:
|
|
280
280
|
Raises:
|
281
281
|
ValueError: If Geometry group is missing or there's an error reading attributes.
|
282
282
|
"""
|
283
|
-
|
283
|
+
logger.info(f"Getting geometry attributes from {hdf_path}")
|
284
284
|
try:
|
285
285
|
with h5py.File(hdf_path, 'r') as hdf_file:
|
286
286
|
geom_attrs_path = "Geometry"
|
287
|
-
|
287
|
+
logger.info(f"Checking for Geometry group in {hdf_path}")
|
288
288
|
if geom_attrs_path not in hdf_file:
|
289
|
+
logger.error(f"Geometry group not found in {hdf_path}")
|
289
290
|
raise ValueError(f"Geometry group not found in {hdf_path}")
|
290
291
|
|
291
292
|
attrs = {}
|
292
293
|
geom_group = hdf_file[geom_attrs_path]
|
293
|
-
|
294
|
+
logger.info("Getting root level geometry attributes")
|
294
295
|
# Get root level geometry attributes only
|
295
296
|
for key, value in geom_group.attrs.items():
|
296
297
|
if isinstance(value, bytes):
|
@@ -300,13 +301,16 @@ class HdfPlan:
|
|
300
301
|
logger.warning(f"Failed to decode byte string for root attribute {key}")
|
301
302
|
continue
|
302
303
|
attrs[key] = value
|
304
|
+
logger.debug(f"Geometry attribute: {key} = {value}")
|
303
305
|
|
304
|
-
|
306
|
+
logger.info(f"Successfully extracted {len(attrs)} root level geometry attributes")
|
305
307
|
return pd.DataFrame.from_dict(attrs, orient='index', columns=['Value'])
|
306
308
|
|
307
309
|
except (OSError, RuntimeError) as e:
|
310
|
+
logger.error(f"Failed to read HDF file {hdf_path}: {str(e)}")
|
308
311
|
raise ValueError(f"Failed to read HDF file {hdf_path}: {str(e)}")
|
309
312
|
except Exception as e:
|
313
|
+
logger.error(f"Failed to get geometry attributes: {str(e)}")
|
310
314
|
raise ValueError(f"Failed to get geometry attributes: {str(e)}")
|
311
315
|
|
312
316
|
|
ras_commander/RasPlan.py
CHANGED
@@ -579,12 +579,12 @@ class RasPlan:
|
|
579
579
|
|
580
580
|
@staticmethod
|
581
581
|
@log_call
|
582
|
-
def get_geom_path(geom_number: str, ras_object=None) -> Optional[str]:
|
582
|
+
def get_geom_path(geom_number: Union[str, int], ras_object=None) -> Optional[str]:
|
583
583
|
"""
|
584
584
|
Return the full path for a given geometry number.
|
585
585
|
|
586
586
|
Args:
|
587
|
-
geom_number (str): The geometry number to search for.
|
587
|
+
geom_number (Union[str, int]): The geometry number to search for.
|
588
588
|
ras_object (RasPrj, optional): Specific RAS object to use. If None, uses the global ras instance.
|
589
589
|
|
590
590
|
Returns:
|
@@ -601,17 +601,51 @@ class RasPlan:
|
|
601
601
|
... else:
|
602
602
|
... print("Geometry file not found.")
|
603
603
|
"""
|
604
|
-
|
605
|
-
ras_obj.check_initialized()
|
606
|
-
|
607
|
-
# Use updated geom dataframe
|
608
|
-
ras_obj.geom_df = ras_obj.get_prj_entries('Geom')
|
604
|
+
logger = get_logger(__name__)
|
609
605
|
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
606
|
+
if geom_number is None:
|
607
|
+
logger.warning("Provided geometry number is None")
|
608
|
+
return None
|
609
|
+
|
610
|
+
try:
|
611
|
+
ras_obj = ras_object or ras
|
612
|
+
ras_obj.check_initialized()
|
613
|
+
|
614
|
+
# Ensure geom_number is a string with proper formatting
|
615
|
+
if isinstance(geom_number, int):
|
616
|
+
geom_number = f"{geom_number:02d}"
|
617
|
+
elif isinstance(geom_number, str):
|
618
|
+
# Strip any leading zeros and reformat
|
619
|
+
stripped = geom_number.lstrip('0')
|
620
|
+
if not stripped: # Handle case where input was '0' or '00'
|
621
|
+
geom_number = '00'
|
622
|
+
else:
|
623
|
+
geom_number = f"{int(stripped):02d}"
|
624
|
+
else:
|
625
|
+
# Handle unexpected types
|
626
|
+
logger.warning(f"Unexpected type for geom_number: {type(geom_number)}")
|
627
|
+
return None
|
628
|
+
|
629
|
+
# Use updated geom dataframe
|
630
|
+
ras_obj.geom_df = ras_obj.get_prj_entries('Geom')
|
631
|
+
|
632
|
+
# Find the geometry file path
|
633
|
+
geom_path = ras_obj.geom_df[ras_obj.geom_df['geom_number'] == geom_number]
|
634
|
+
if not geom_path.empty:
|
635
|
+
if 'full_path' in geom_path.columns and pd.notna(geom_path['full_path'].iloc[0]):
|
636
|
+
full_path = geom_path['full_path'].iloc[0]
|
637
|
+
logger.info(f"Found geometry path: {full_path}")
|
638
|
+
return full_path
|
639
|
+
else:
|
640
|
+
# Fallback to constructing path
|
641
|
+
constructed_path = str(ras_obj.project_folder / f"{ras_obj.project_name}.g{geom_number}")
|
642
|
+
logger.info(f"Constructed geometry path: {constructed_path}")
|
643
|
+
return constructed_path
|
644
|
+
else:
|
645
|
+
logger.warning(f"No geometry file found with number: {geom_number}")
|
646
|
+
return None
|
647
|
+
except Exception as e:
|
648
|
+
logger.error(f"Error in get_geom_path: {str(e)}")
|
615
649
|
return None
|
616
650
|
|
617
651
|
# Clone Functions to copy unsteady, flow, and geometry files from templates
|
ras_commander/__init__.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
ras_commander/Decorators.py,sha256=
|
1
|
+
ras_commander/Decorators.py,sha256=mhfM6A8jJTZ9b0srybB3u4DIaDnwweVQqYHERLR62Ck,14527
|
2
2
|
ras_commander/HdfBase.py,sha256=Jws6Y8JFkharuiM6Br5ivp6MS64X2fL6y87FOpe3FQw,14219
|
3
3
|
ras_commander/HdfBndry.py,sha256=FBNFoTz4sXVB-MOsbHJBP8P0dMqJUfBROloKTaxmzCo,16377
|
4
4
|
ras_commander/HdfFluvialPluvial.py,sha256=dlqoFX5i7uSA2BvuRNrV-Fg-z2JaeUxY86_fbZAdGqI,25933
|
5
5
|
ras_commander/HdfInfiltration.py,sha256=HiifhbzgUs4kdtJkKfhxo1IsE-FBp5XspKkrJnnCDuc,66171
|
6
6
|
ras_commander/HdfMesh.py,sha256=zI_4AqxDxb2_31G9RUmWibyld6KDMGhDpI3F8qwzVAw,19139
|
7
7
|
ras_commander/HdfPipe.py,sha256=m-yvPL2GIP23NKt2tcwzOlS7khvgcDPGAshlTPMUAeI,32154
|
8
|
-
ras_commander/HdfPlan.py,sha256=
|
8
|
+
ras_commander/HdfPlan.py,sha256=WINI3lp865cE99QXztgvKKIhVUTOqu4X41ZPBfhYJGU,12145
|
9
9
|
ras_commander/HdfPlot.py,sha256=7MNI5T9qIz-Ava1RdlnB6O9oJElE5BEB29QVF5Y2Xuc,3401
|
10
10
|
ras_commander/HdfPump.py,sha256=Vc2ff16kRISR7jwtnaAqxI0p-gfBSuZKzR3rQbBLQoE,12951
|
11
11
|
ras_commander/HdfResultsMesh.py,sha256=MKnSJxcWVDccHaRRGgAK0szm7B-VtrKBtgL1Uz0kAiw,44662
|
@@ -20,13 +20,13 @@ ras_commander/RasCmdr.py,sha256=37GnchoQ0fIAkPnssnCr1mRUXY8gm-hIMTmuHZlnYP8,3459
|
|
20
20
|
ras_commander/RasExamples.py,sha256=6IZ96LcAsk5LYFehdD0zDW5wyZWxQa6OQu2N9upxWXA,17536
|
21
21
|
ras_commander/RasGeo.py,sha256=CQ1VjJ4uWWyXC9KsoVStbhlRf_5AiDm8yWvtDM3l4ac,21675
|
22
22
|
ras_commander/RasMap.py,sha256=4cVzaaQure-CXdXB1BY29iE20S00eldUqoL96PvJPbw,10635
|
23
|
-
ras_commander/RasPlan.py,sha256=
|
23
|
+
ras_commander/RasPlan.py,sha256=GhAeUSvWRuBcYcOtBCo-qZGUefEWOlhw4ASJQHTGWzU,63872
|
24
24
|
ras_commander/RasPrj.py,sha256=ivAHB3vexH6GQi-Aa4kqAabRwdthllMkTp8xphh5Ldc,57655
|
25
25
|
ras_commander/RasUnsteady.py,sha256=TO08CT2GC4G5rcXO_Wbia2t4PhiWRu9-nC9F0IW7Gyo,37187
|
26
26
|
ras_commander/RasUtils.py,sha256=0fm4IIs0LH1dgDj3pGd66mR82DhWLEkRKUvIo2M_5X0,35886
|
27
|
-
ras_commander/__init__.py,sha256=
|
28
|
-
ras_commander-0.
|
29
|
-
ras_commander-0.
|
30
|
-
ras_commander-0.
|
31
|
-
ras_commander-0.
|
32
|
-
ras_commander-0.
|
27
|
+
ras_commander/__init__.py,sha256=K6g6-GMFHnDKhLYvht8voqlGfY3N86UNS6ZQKvne3Mc,2039
|
28
|
+
ras_commander-0.74.0.dist-info/licenses/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
|
29
|
+
ras_commander-0.74.0.dist-info/METADATA,sha256=qoAaqX8Z5ZCA88r1KAhcvatAh1WyAX75H0FK8HmC-8Y,27365
|
30
|
+
ras_commander-0.74.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
31
|
+
ras_commander-0.74.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
|
32
|
+
ras_commander-0.74.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|