ras-commander 0.77.0__py3-none-any.whl → 0.79.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/HdfFluvialPluvial.py +276 -414
- ras_commander/HdfResultsMesh.py +0 -16
- ras_commander/RasExamples.py +121 -2
- ras_commander/RasGeo.py +2 -2
- ras_commander/RasMap.py +467 -252
- ras_commander/RasPrj.py +2 -1
- ras_commander/__init__.py +1 -1
- {ras_commander-0.77.0.dist-info → ras_commander-0.79.0.dist-info}/METADATA +2 -3
- {ras_commander-0.77.0.dist-info → ras_commander-0.79.0.dist-info}/RECORD +12 -12
- {ras_commander-0.77.0.dist-info → ras_commander-0.79.0.dist-info}/WHEEL +1 -1
- {ras_commander-0.77.0.dist-info → ras_commander-0.79.0.dist-info}/licenses/LICENSE +0 -0
- {ras_commander-0.77.0.dist-info → ras_commander-0.79.0.dist-info}/top_level.txt +0 -0
ras_commander/HdfResultsMesh.py
CHANGED
@@ -42,22 +42,6 @@ HdfUtils for common operations. Methods use @log_call decorator for logging and
|
|
42
42
|
|
43
43
|
|
44
44
|
|
45
|
-
REVISIONS MADE:
|
46
|
-
|
47
|
-
Use get_ prefix for functions that return data.
|
48
|
-
BUT, we will never set results data, so we should use get_ for results data.
|
49
|
-
|
50
|
-
Renamed functions:
|
51
|
-
- mesh_summary_output() to get_mesh_summary()
|
52
|
-
- mesh_timeseries_output() to get_mesh_timeseries()
|
53
|
-
- mesh_faces_timeseries_output() to get_mesh_faces_timeseries()
|
54
|
-
- mesh_cells_timeseries_output() to get_mesh_cells_timeseries()
|
55
|
-
- mesh_last_iter() to get_mesh_last_iter()
|
56
|
-
- mesh_max_ws() to get_mesh_max_ws()
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
45
|
|
62
46
|
|
63
47
|
|
ras_commander/RasExamples.py
CHANGED
@@ -69,6 +69,12 @@ class RasExamples:
|
|
69
69
|
examples_dir = base_dir
|
70
70
|
projects_dir = examples_dir / 'example_projects'
|
71
71
|
csv_file_path = examples_dir / 'example_projects.csv'
|
72
|
+
|
73
|
+
# Special projects that are not in the main zip file
|
74
|
+
SPECIAL_PROJECTS = {
|
75
|
+
'NewOrleansMetro': 'https://www.hec.usace.army.mil/confluence/rasdocs/hgt/files/latest/299502039/299502111/1/1747692522764/NewOrleansMetroPipesExample.zip',
|
76
|
+
'BeaverLake': 'https://www.hec.usace.army.mil/confluence/rasdocs/hgt/files/latest/299501780/299502090/1/1747692179014/BeaverLake-SWMM-Import-Solution.zip'
|
77
|
+
}
|
72
78
|
|
73
79
|
_folder_df = None
|
74
80
|
_zip_file_path = None
|
@@ -148,6 +154,17 @@ class RasExamples:
|
|
148
154
|
extracted_paths = []
|
149
155
|
|
150
156
|
for project_name in project_names:
|
157
|
+
# Check if this is a special project
|
158
|
+
if project_name in cls.SPECIAL_PROJECTS:
|
159
|
+
try:
|
160
|
+
special_path = cls._extract_special_project(project_name)
|
161
|
+
extracted_paths.append(special_path)
|
162
|
+
continue
|
163
|
+
except Exception as e:
|
164
|
+
logger.error(f"Failed to extract special project '{project_name}': {e}")
|
165
|
+
continue
|
166
|
+
|
167
|
+
# Regular project extraction logic
|
151
168
|
logger.info("----- RasExamples Extracting Project -----")
|
152
169
|
logger.info(f"Extracting project '{project_name}'")
|
153
170
|
project_path = cls.projects_dir
|
@@ -319,6 +336,9 @@ class RasExamples:
|
|
319
336
|
def list_projects(cls, category=None):
|
320
337
|
"""
|
321
338
|
List all projects or projects in a specific category.
|
339
|
+
|
340
|
+
Note: Special projects (NewOrleansMetro, BeaverLake) are also available but not listed
|
341
|
+
in categories as they are downloaded separately.
|
322
342
|
"""
|
323
343
|
if cls._folder_df is None:
|
324
344
|
logger.warning("No projects available. Make sure the zip file is properly loaded.")
|
@@ -328,7 +348,10 @@ class RasExamples:
|
|
328
348
|
logger.info(f"Projects in category '{category}': {', '.join(projects)}")
|
329
349
|
else:
|
330
350
|
projects = cls._folder_df['Project'].unique()
|
331
|
-
|
351
|
+
# Add special projects to the list
|
352
|
+
all_projects = list(projects) + list(cls.SPECIAL_PROJECTS.keys())
|
353
|
+
logger.info(f"All available projects: {', '.join(all_projects)}")
|
354
|
+
return all_projects
|
332
355
|
return projects.tolist()
|
333
356
|
|
334
357
|
@classmethod
|
@@ -421,4 +444,100 @@ class RasExamples:
|
|
421
444
|
raise ValueError(f"Invalid size string: {size_str}")
|
422
445
|
|
423
446
|
number, unit = float(re.findall(r'[\d\.]+', size_str)[0]), re.findall(r'[BKMGT]B?', size_str)[0]
|
424
|
-
return int(number * units[unit])
|
447
|
+
return int(number * units[unit])
|
448
|
+
|
449
|
+
@classmethod
|
450
|
+
def _extract_special_project(cls, project_name: str) -> Path:
|
451
|
+
"""
|
452
|
+
Download and extract special projects that are not in the main zip file.
|
453
|
+
|
454
|
+
Args:
|
455
|
+
project_name: Name of the special project ('NewOrleansMetro' or 'BeaverLake')
|
456
|
+
|
457
|
+
Returns:
|
458
|
+
Path: Path to the extracted project directory
|
459
|
+
|
460
|
+
Raises:
|
461
|
+
ValueError: If the project is not a recognized special project
|
462
|
+
"""
|
463
|
+
if project_name not in cls.SPECIAL_PROJECTS:
|
464
|
+
raise ValueError(f"'{project_name}' is not a recognized special project")
|
465
|
+
|
466
|
+
logger.info(f"----- RasExamples Extracting Special Project -----")
|
467
|
+
logger.info(f"Extracting special project '{project_name}'")
|
468
|
+
|
469
|
+
# Create the project directory
|
470
|
+
project_path = cls.projects_dir / project_name
|
471
|
+
|
472
|
+
# Check if already exists
|
473
|
+
if project_path.exists():
|
474
|
+
logger.info(f"Special project '{project_name}' already exists. Deleting existing folder...")
|
475
|
+
try:
|
476
|
+
shutil.rmtree(project_path)
|
477
|
+
logger.info(f"Existing folder for project '{project_name}' has been deleted.")
|
478
|
+
except Exception as e:
|
479
|
+
logger.error(f"Failed to delete existing project folder '{project_name}': {e}")
|
480
|
+
raise
|
481
|
+
|
482
|
+
# Create the project directory
|
483
|
+
project_path.mkdir(parents=True, exist_ok=True)
|
484
|
+
|
485
|
+
# Download the zip file
|
486
|
+
url = cls.SPECIAL_PROJECTS[project_name]
|
487
|
+
zip_file_path = cls.projects_dir / f"{project_name}_temp.zip"
|
488
|
+
|
489
|
+
logger.info(f"Downloading special project from: {url}")
|
490
|
+
logger.info("This may take a few moments...")
|
491
|
+
|
492
|
+
try:
|
493
|
+
response = requests.get(url, stream=True, timeout=300)
|
494
|
+
response.raise_for_status()
|
495
|
+
|
496
|
+
# Get total file size if available
|
497
|
+
total_size = int(response.headers.get('content-length', 0))
|
498
|
+
|
499
|
+
# Download with progress bar
|
500
|
+
with open(zip_file_path, 'wb') as file:
|
501
|
+
if total_size > 0:
|
502
|
+
with tqdm(
|
503
|
+
desc=f"Downloading {project_name}",
|
504
|
+
total=total_size,
|
505
|
+
unit='iB',
|
506
|
+
unit_scale=True,
|
507
|
+
unit_divisor=1024,
|
508
|
+
) as progress_bar:
|
509
|
+
for chunk in response.iter_content(chunk_size=8192):
|
510
|
+
size = file.write(chunk)
|
511
|
+
progress_bar.update(size)
|
512
|
+
else:
|
513
|
+
# No content length, download without progress bar
|
514
|
+
for chunk in response.iter_content(chunk_size=8192):
|
515
|
+
file.write(chunk)
|
516
|
+
|
517
|
+
logger.info(f"Downloaded special project zip file to {zip_file_path}")
|
518
|
+
|
519
|
+
except requests.exceptions.RequestException as e:
|
520
|
+
logger.error(f"Failed to download special project '{project_name}': {e}")
|
521
|
+
if zip_file_path.exists():
|
522
|
+
zip_file_path.unlink()
|
523
|
+
raise
|
524
|
+
|
525
|
+
# Extract the zip file directly to the project directory
|
526
|
+
try:
|
527
|
+
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
|
528
|
+
# Extract directly to the project directory (no internal folder structure)
|
529
|
+
zip_ref.extractall(project_path)
|
530
|
+
logger.info(f"Successfully extracted special project '{project_name}' to {project_path}")
|
531
|
+
|
532
|
+
except Exception as e:
|
533
|
+
logger.error(f"Failed to extract special project '{project_name}': {e}")
|
534
|
+
if project_path.exists():
|
535
|
+
shutil.rmtree(project_path)
|
536
|
+
raise
|
537
|
+
finally:
|
538
|
+
# Clean up the temporary zip file
|
539
|
+
if zip_file_path.exists():
|
540
|
+
zip_file_path.unlink()
|
541
|
+
logger.debug(f"Removed temporary zip file: {zip_file_path}")
|
542
|
+
|
543
|
+
return project_path
|
ras_commander/RasGeo.py
CHANGED
@@ -206,10 +206,10 @@ class RasGeo:
|
|
206
206
|
|
207
207
|
# Create DataFrame
|
208
208
|
if base_table_rows:
|
209
|
-
df = pd.DataFrame(base_table_rows, columns=['Table Number', 'Land Cover Name', 'Base
|
209
|
+
df = pd.DataFrame(base_table_rows, columns=['Table Number', 'Land Cover Name', 'Base Mannings n Value'])
|
210
210
|
return df
|
211
211
|
else:
|
212
|
-
return pd.DataFrame(columns=['Table Number', 'Land Cover Name', 'Base
|
212
|
+
return pd.DataFrame(columns=['Table Number', 'Land Cover Name', 'Base Mannings n Value'])
|
213
213
|
|
214
214
|
|
215
215
|
@staticmethod
|