ras-commander 0.73.0__py3-none-any.whl → 0.75.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/RasPrj.py +115 -45
- ras_commander/__init__.py +1 -1
- {ras_commander-0.73.0.dist-info → ras_commander-0.75.0.dist-info}/METADATA +1 -1
- {ras_commander-0.73.0.dist-info → ras_commander-0.75.0.dist-info}/RECORD +10 -10
- {ras_commander-0.73.0.dist-info → ras_commander-0.75.0.dist-info}/WHEEL +0 -0
- {ras_commander-0.73.0.dist-info → ras_commander-0.75.0.dist-info}/licenses/LICENSE +0 -0
- {ras_commander-0.73.0.dist-info → ras_commander-0.75.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/RasPrj.py
CHANGED
@@ -1274,7 +1274,7 @@ def init_ras_project(ras_project_folder, ras_version=None, ras_object=None):
|
|
1274
1274
|
ras_project_folder (str or Path): The path to the RAS project folder.
|
1275
1275
|
ras_version (str, optional): The version of RAS to use (e.g., "6.6").
|
1276
1276
|
Can also be a full path to the Ras.exe file.
|
1277
|
-
If None, will attempt to
|
1277
|
+
If None, will attempt to detect from plan files.
|
1278
1278
|
ras_object (RasPrj, optional): If None, updates the global 'ras' object.
|
1279
1279
|
If a RasPrj instance, updates that instance.
|
1280
1280
|
If any other value, creates and returns a new RasPrj instance.
|
@@ -1295,31 +1295,86 @@ def init_ras_project(ras_project_folder, ras_version=None, ras_object=None):
|
|
1295
1295
|
>>> my_project = init_ras_project("/path/to/project", "6.6", "new")
|
1296
1296
|
>>> print(f"Created project instance: {my_project.project_name}")
|
1297
1297
|
"""
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
ras_exe_path = get_ras_exe(ras_version)
|
1298
|
+
project_folder = Path(ras_project_folder)
|
1299
|
+
if not project_folder.exists():
|
1300
|
+
logger.error(f"The specified RAS project folder does not exist: {project_folder}")
|
1301
|
+
raise FileNotFoundError(f"The specified RAS project folder does not exist: {project_folder}. Please check the path and try again.")
|
1303
1302
|
|
1304
1303
|
# Determine which RasPrj instance to use
|
1305
1304
|
if ras_object is None:
|
1306
1305
|
# Use the global 'ras' object
|
1307
|
-
logger.
|
1306
|
+
logger.debug("Initializing global 'ras' object via init_ras_project function.")
|
1308
1307
|
ras_object = ras
|
1309
1308
|
elif not isinstance(ras_object, RasPrj):
|
1310
1309
|
# Create a new RasPrj instance
|
1311
|
-
logger.
|
1310
|
+
logger.debug("Creating a new RasPrj instance.")
|
1312
1311
|
ras_object = RasPrj()
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1312
|
+
|
1313
|
+
ras_exe_path = None
|
1314
|
+
|
1315
|
+
# Use version specified by user if provided
|
1316
|
+
if ras_version is not None:
|
1317
|
+
ras_exe_path = get_ras_exe(ras_version)
|
1318
|
+
if ras_exe_path == "Ras.exe" and ras_version != "Ras.exe":
|
1319
|
+
logger.warning(f"HEC-RAS Version {ras_version} was not found. Running HEC-RAS will fail.")
|
1320
|
+
else:
|
1321
|
+
# No version specified, try to detect from plan files
|
1322
|
+
detected_version = None
|
1323
|
+
logger.info("No HEC-RAS Version Specified.Attempting to detect HEC-RAS version from plan files.")
|
1324
|
+
|
1325
|
+
# Look for .pXX files in project folder
|
1326
|
+
logger.info(f"Searching for plan files in {project_folder}")
|
1327
|
+
plan_files = list(project_folder.glob(f"{project_folder.stem}.p[0-9][0-9]"))
|
1328
|
+
|
1329
|
+
if not plan_files:
|
1330
|
+
logger.info(f"No plan files found in {project_folder}")
|
1331
|
+
|
1332
|
+
for plan_file in plan_files:
|
1333
|
+
logger.info(f"Found plan file: {plan_file.name}")
|
1334
|
+
content, encoding = read_file_with_fallback_encoding(plan_file)
|
1335
|
+
|
1336
|
+
if not content:
|
1337
|
+
logger.info(f"Could not read content from {plan_file.name}")
|
1338
|
+
continue
|
1339
|
+
|
1340
|
+
logger.info(f"Successfully read plan file with {encoding} encoding")
|
1341
|
+
|
1342
|
+
# Look for Program Version in plan file
|
1343
|
+
for line in content.splitlines():
|
1344
|
+
if line.startswith("Program Version="):
|
1345
|
+
version = line.split("=")[1].strip()
|
1346
|
+
logger.info(f"Found Program Version={version} in {plan_file.name}")
|
1347
|
+
|
1348
|
+
# Try to get RAS executable for this version
|
1349
|
+
test_exe_path = get_ras_exe(version)
|
1350
|
+
logger.info(f"Checking RAS executable path: {test_exe_path}")
|
1351
|
+
|
1352
|
+
if test_exe_path != "Ras.exe":
|
1353
|
+
detected_version = version
|
1354
|
+
ras_exe_path = test_exe_path
|
1355
|
+
logger.debug(f"Found valid HEC-RAS version {version} in plan file {plan_file.name}")
|
1356
|
+
break
|
1357
|
+
else:
|
1358
|
+
logger.info(f"Version {version} not found in default installation path")
|
1359
|
+
|
1360
|
+
if detected_version:
|
1361
|
+
break
|
1362
|
+
|
1363
|
+
if not detected_version:
|
1364
|
+
logger.error("No valid HEC-RAS version found in any plan files.")
|
1365
|
+
ras_exe_path = "Ras.exe"
|
1366
|
+
logger.warning("No valid HEC-RAS version was detected. Running HEC-RAS will fail.")
|
1367
|
+
|
1368
|
+
# Initialize or re-initialize with the determined executable path
|
1369
|
+
ras_object.initialize(project_folder, ras_exe_path)
|
1316
1370
|
|
1317
1371
|
# Always update the global ras object as well
|
1318
1372
|
if ras_object is not ras:
|
1319
|
-
ras.initialize(
|
1320
|
-
logger.
|
1373
|
+
ras.initialize(project_folder, ras_exe_path)
|
1374
|
+
logger.debug("Global 'ras' object also updated to match the new project.")
|
1321
1375
|
|
1322
|
-
logger.
|
1376
|
+
logger.debug(f"Project initialized. Project folder: {ras_object.project_folder}")
|
1377
|
+
logger.debug(f"Using HEC-RAS executable: {ras_exe_path}")
|
1323
1378
|
return ras_object
|
1324
1379
|
|
1325
1380
|
@log_call
|
@@ -1331,36 +1386,29 @@ def get_ras_exe(ras_version=None):
|
|
1331
1386
|
1. If ras_version is a valid file path to an .exe file, use that path
|
1332
1387
|
2. If ras_version is a known version number, use default installation path
|
1333
1388
|
3. If global 'ras' object has ras_exe_path, use that
|
1334
|
-
4. As a fallback, return
|
1389
|
+
4. As a fallback, return "Ras.exe" but log an error
|
1335
1390
|
|
1336
1391
|
Args:
|
1337
1392
|
ras_version (str, optional): Either a version number or a full path to the HEC-RAS executable.
|
1338
1393
|
|
1339
1394
|
Returns:
|
1340
|
-
str: The full path to the HEC-RAS executable.
|
1395
|
+
str: The full path to the HEC-RAS executable or "Ras.exe" if not found.
|
1341
1396
|
|
1342
1397
|
Note:
|
1343
1398
|
- HEC-RAS version numbers include: "6.6", "6.5", "6.4.1", "6.3", etc.
|
1344
1399
|
- The default installation path follows: C:/Program Files (x86)/HEC/HEC-RAS/{version}/Ras.exe
|
1345
|
-
- Returns
|
1346
|
-
-
|
1347
|
-
|
1348
|
-
Example:
|
1349
|
-
>>> # Get path for specific version
|
1350
|
-
>>> ras_path = get_ras_exe("6.6")
|
1351
|
-
>>> print(f"HEC-RAS 6.6 executable: {ras_path}")
|
1352
|
-
>>>
|
1353
|
-
>>> # Provide direct path to executable
|
1354
|
-
>>> custom_path = get_ras_exe("C:/My_Programs/HEC-RAS/Ras.exe")
|
1400
|
+
- Returns "Ras.exe" if no valid path is found, with error logged
|
1401
|
+
- Allows the library to function even without HEC-RAS installed
|
1355
1402
|
"""
|
1356
1403
|
if ras_version is None:
|
1357
1404
|
if hasattr(ras, 'ras_exe_path') and ras.ras_exe_path:
|
1358
1405
|
logger.debug(f"Using HEC-RAS executable from global 'ras' object: {ras.ras_exe_path}")
|
1359
1406
|
return ras.ras_exe_path
|
1360
1407
|
else:
|
1361
|
-
default_path =
|
1362
|
-
logger.
|
1363
|
-
|
1408
|
+
default_path = "Ras.exe"
|
1409
|
+
logger.debug(f"No HEC-RAS version specified and global 'ras' object not initialized or missing ras_exe_path.")
|
1410
|
+
logger.warning(f"HEC-RAS is not installed or version not specified. Running HEC-RAS will fail unless a valid installed version is specified.")
|
1411
|
+
return default_path
|
1364
1412
|
|
1365
1413
|
ras_version_numbers = [
|
1366
1414
|
"6.6", "6.5", "6.4.1", "6.3.1", "6.3", "6.2", "6.1", "6.0",
|
@@ -1368,32 +1416,54 @@ def get_ras_exe(ras_version=None):
|
|
1368
1416
|
"4.1", "4.0", "3.1.3", "3.1.2", "3.1.1", "3.0", "2.2"
|
1369
1417
|
]
|
1370
1418
|
|
1419
|
+
# Check if input is a direct path to an executable
|
1371
1420
|
hecras_path = Path(ras_version)
|
1372
|
-
|
1373
1421
|
if hecras_path.is_file() and hecras_path.suffix.lower() == '.exe':
|
1374
1422
|
logger.debug(f"HEC-RAS executable found at specified path: {hecras_path}")
|
1375
1423
|
return str(hecras_path)
|
1376
1424
|
|
1377
|
-
|
1425
|
+
# Check known version numbers
|
1426
|
+
if str(ras_version) in ras_version_numbers:
|
1378
1427
|
default_path = Path(f"C:/Program Files (x86)/HEC/HEC-RAS/{ras_version}/Ras.exe")
|
1379
1428
|
if default_path.is_file():
|
1380
1429
|
logger.debug(f"HEC-RAS executable found at default path: {default_path}")
|
1381
1430
|
return str(default_path)
|
1382
1431
|
else:
|
1383
|
-
|
1432
|
+
error_msg = f"HEC-RAS Version {ras_version} is not found at expected path. Running HEC-RAS will fail unless a valid installed version is specified."
|
1433
|
+
logger.error(error_msg)
|
1434
|
+
return "Ras.exe"
|
1384
1435
|
|
1436
|
+
# Try to handle other version formats (e.g., just the number without dots)
|
1385
1437
|
try:
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
logger.
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1438
|
+
# First check if it's a direct version number
|
1439
|
+
version_str = str(ras_version)
|
1440
|
+
|
1441
|
+
# Check for paths like "C:/Path/To/Ras.exe"
|
1442
|
+
if os.path.sep in version_str and version_str.lower().endswith('.exe'):
|
1443
|
+
exe_path = Path(version_str)
|
1444
|
+
if exe_path.is_file():
|
1445
|
+
logger.debug(f"HEC-RAS executable found at specified path: {exe_path}")
|
1446
|
+
return str(exe_path)
|
1447
|
+
|
1448
|
+
# Try to find a matching version from our list
|
1449
|
+
for known_version in ras_version_numbers:
|
1450
|
+
if version_str in known_version or known_version.replace('.', '') == version_str:
|
1451
|
+
default_path = Path(f"C:/Program Files (x86)/HEC/HEC-RAS/{known_version}/Ras.exe")
|
1452
|
+
if default_path.is_file():
|
1453
|
+
logger.debug(f"HEC-RAS executable found at default path: {default_path}")
|
1454
|
+
return str(default_path)
|
1455
|
+
|
1456
|
+
# Check if it's a newer version
|
1457
|
+
if '.' in version_str:
|
1458
|
+
major_version = int(version_str.split('.')[0])
|
1459
|
+
if major_version >= 6:
|
1460
|
+
default_path = Path(f"C:/Program Files (x86)/HEC/HEC-RAS/{version_str}/Ras.exe")
|
1461
|
+
if default_path.is_file():
|
1462
|
+
logger.debug(f"HEC-RAS executable found at path for newer version: {default_path}")
|
1463
|
+
return str(default_path)
|
1464
|
+
except Exception as e:
|
1465
|
+
logger.error(f"Error parsing version or finding path: {e}")
|
1399
1466
|
|
1467
|
+
error_msg = f"HEC-RAS Version {ras_version} is not recognized or installed. Running HEC-RAS will fail unless a valid installed version is specified."
|
1468
|
+
logger.error(error_msg)
|
1469
|
+
return "Ras.exe"
|
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=
|
24
|
-
ras_commander/RasPrj.py,sha256=
|
23
|
+
ras_commander/RasPlan.py,sha256=GhAeUSvWRuBcYcOtBCo-qZGUefEWOlhw4ASJQHTGWzU,63872
|
24
|
+
ras_commander/RasPrj.py,sha256=G8AL6No0unxYLc1y0uQgcFLXeZ2TK3RO1WZmsZqAz7c,61281
|
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=8QLpMI_g0OsRBnap8u71IviaH6cgWfq40xd8IbIavWw,2039
|
28
|
+
ras_commander-0.75.0.dist-info/licenses/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
|
29
|
+
ras_commander-0.75.0.dist-info/METADATA,sha256=o57ambIJOv_f_XYOccu5_3uhaNIZuGIAnxWDFf_8EJc,27365
|
30
|
+
ras_commander-0.75.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
31
|
+
ras_commander-0.75.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
|
32
|
+
ras_commander-0.75.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|