ras-commander 0.79.1__py3-none-any.whl → 0.80.2__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/HdfXsec.py +24 -17
- ras_commander/RasExamples.py +26 -6
- ras_commander/RasGeo.py +537 -537
- ras_commander/RasMap.py +466 -466
- ras_commander/__init__.py +1 -1
- {ras_commander-0.79.1.dist-info → ras_commander-0.80.2.dist-info}/METADATA +1 -1
- {ras_commander-0.79.1.dist-info → ras_commander-0.80.2.dist-info}/RECORD +10 -10
- {ras_commander-0.79.1.dist-info → ras_commander-0.80.2.dist-info}/WHEEL +0 -0
- {ras_commander-0.79.1.dist-info → ras_commander-0.80.2.dist-info}/licenses/LICENSE +0 -0
- {ras_commander-0.79.1.dist-info → ras_commander-0.80.2.dist-info}/top_level.txt +0 -0
ras_commander/HdfXsec.py
CHANGED
@@ -114,9 +114,13 @@ class HdfXsec:
|
|
114
114
|
mann_info = hdf["/Geometry/Cross Sections/Manning's n Info"][:]
|
115
115
|
mann_values = hdf["/Geometry/Cross Sections/Manning's n Values"][:]
|
116
116
|
|
117
|
-
# Get ineffective blocks data
|
118
|
-
|
119
|
-
|
117
|
+
# Get ineffective blocks data if they exist
|
118
|
+
if '/Geometry/Cross Sections/Ineffective Blocks' in hdf:
|
119
|
+
ineff_blocks = hdf['/Geometry/Cross Sections/Ineffective Blocks'][:]
|
120
|
+
ineff_info = hdf['/Geometry/Cross Sections/Ineffective Info'][:]
|
121
|
+
else:
|
122
|
+
ineff_blocks = None
|
123
|
+
ineff_info = None
|
120
124
|
|
121
125
|
# Initialize lists to store data
|
122
126
|
geometries = []
|
@@ -165,20 +169,23 @@ class HdfXsec:
|
|
165
169
|
mannings_n.append(mann_n_dict)
|
166
170
|
|
167
171
|
# Extract ineffective blocks data
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
172
|
+
if ineff_info is not None and ineff_blocks is not None:
|
173
|
+
ineff_start_idx = ineff_info[i][0]
|
174
|
+
ineff_count = ineff_info[i][1]
|
175
|
+
if ineff_count > 0:
|
176
|
+
blocks = ineff_blocks[ineff_start_idx:ineff_start_idx + ineff_count]
|
177
|
+
blocks_list = []
|
178
|
+
for block in blocks:
|
179
|
+
block_dict = {
|
180
|
+
'Left Sta': float(block['Left Sta']),
|
181
|
+
'Right Sta': float(block['Right Sta']),
|
182
|
+
'Elevation': float(block['Elevation']),
|
183
|
+
'Permanent': bool(block['Permanent'])
|
184
|
+
}
|
185
|
+
blocks_list.append(block_dict)
|
186
|
+
ineffective_blocks.append(blocks_list)
|
187
|
+
else:
|
188
|
+
ineffective_blocks.append([])
|
182
189
|
else:
|
183
190
|
ineffective_blocks.append([])
|
184
191
|
|
ras_commander/RasExamples.py
CHANGED
@@ -128,11 +128,14 @@ class RasExamples:
|
|
128
128
|
self._save_to_csv()
|
129
129
|
|
130
130
|
@classmethod
|
131
|
-
def extract_project(cls, project_names: Union[str, List[str]]) -> Union[Path, List[Path]]:
|
131
|
+
def extract_project(cls, project_names: Union[str, List[str]], output_path: Union[str, Path] = None) -> Union[Path, List[Path]]:
|
132
132
|
"""Extract one or more specific HEC-RAS projects from the zip file.
|
133
133
|
|
134
134
|
Args:
|
135
135
|
project_names: Single project name as string or list of project names
|
136
|
+
output_path: Optional path where the project folder will be placed.
|
137
|
+
Can be a relative path (creates subfolder in current directory)
|
138
|
+
or an absolute path. If None, uses default 'example_projects' folder.
|
136
139
|
|
137
140
|
Returns:
|
138
141
|
Path: Single Path object if one project extracted
|
@@ -151,13 +154,26 @@ class RasExamples:
|
|
151
154
|
if isinstance(project_names, str):
|
152
155
|
project_names = [project_names]
|
153
156
|
|
157
|
+
# Determine the output directory
|
158
|
+
if output_path is None:
|
159
|
+
# Use default 'example_projects' folder
|
160
|
+
base_output_path = cls.projects_dir
|
161
|
+
else:
|
162
|
+
# Convert to Path object
|
163
|
+
base_output_path = Path(output_path)
|
164
|
+
# If relative path, make it relative to current working directory
|
165
|
+
if not base_output_path.is_absolute():
|
166
|
+
base_output_path = Path.cwd() / base_output_path
|
167
|
+
# Create the directory if it doesn't exist
|
168
|
+
base_output_path.mkdir(parents=True, exist_ok=True)
|
169
|
+
|
154
170
|
extracted_paths = []
|
155
171
|
|
156
172
|
for project_name in project_names:
|
157
173
|
# Check if this is a special project
|
158
174
|
if project_name in cls.SPECIAL_PROJECTS:
|
159
175
|
try:
|
160
|
-
special_path = cls._extract_special_project(project_name)
|
176
|
+
special_path = cls._extract_special_project(project_name, base_output_path)
|
161
177
|
extracted_paths.append(special_path)
|
162
178
|
continue
|
163
179
|
except Exception as e:
|
@@ -167,7 +183,7 @@ class RasExamples:
|
|
167
183
|
# Regular project extraction logic
|
168
184
|
logger.info("----- RasExamples Extracting Project -----")
|
169
185
|
logger.info(f"Extracting project '{project_name}'")
|
170
|
-
project_path =
|
186
|
+
project_path = base_output_path
|
171
187
|
|
172
188
|
if (project_path / project_name).exists():
|
173
189
|
logger.info(f"Project '{project_name}' already exists. Deleting existing folder...")
|
@@ -447,12 +463,13 @@ class RasExamples:
|
|
447
463
|
return int(number * units[unit])
|
448
464
|
|
449
465
|
@classmethod
|
450
|
-
def _extract_special_project(cls, project_name: str) -> Path:
|
466
|
+
def _extract_special_project(cls, project_name: str, output_path: Path = None) -> Path:
|
451
467
|
"""
|
452
468
|
Download and extract special projects that are not in the main zip file.
|
453
469
|
|
454
470
|
Args:
|
455
471
|
project_name: Name of the special project ('NewOrleansMetro' or 'BeaverLake')
|
472
|
+
output_path: Base output directory path. If None, uses cls.projects_dir
|
456
473
|
|
457
474
|
Returns:
|
458
475
|
Path: Path to the extracted project directory
|
@@ -466,8 +483,11 @@ class RasExamples:
|
|
466
483
|
logger.info(f"----- RasExamples Extracting Special Project -----")
|
467
484
|
logger.info(f"Extracting special project '{project_name}'")
|
468
485
|
|
486
|
+
# Use provided output_path or default
|
487
|
+
base_path = output_path if output_path else cls.projects_dir
|
488
|
+
|
469
489
|
# Create the project directory
|
470
|
-
project_path =
|
490
|
+
project_path = base_path / project_name
|
471
491
|
|
472
492
|
# Check if already exists
|
473
493
|
if project_path.exists():
|
@@ -484,7 +504,7 @@ class RasExamples:
|
|
484
504
|
|
485
505
|
# Download the zip file
|
486
506
|
url = cls.SPECIAL_PROJECTS[project_name]
|
487
|
-
zip_file_path =
|
507
|
+
zip_file_path = base_path / f"{project_name}_temp.zip"
|
488
508
|
|
489
509
|
logger.info(f"Downloading special project from: {url}")
|
490
510
|
logger.info("This may take a few moments...")
|