ras-commander 0.79.1__tar.gz → 0.80.2__tar.gz

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.
Files changed (39) hide show
  1. {ras_commander-0.79.1/ras_commander.egg-info → ras_commander-0.80.2}/PKG-INFO +1 -1
  2. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfXsec.py +24 -17
  3. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/RasExamples.py +26 -6
  4. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/RasGeo.py +537 -537
  5. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/RasMap.py +466 -466
  6. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/__init__.py +1 -1
  7. {ras_commander-0.79.1 → ras_commander-0.80.2/ras_commander.egg-info}/PKG-INFO +1 -1
  8. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander.egg-info/SOURCES.txt +2 -1
  9. {ras_commander-0.79.1 → ras_commander-0.80.2}/setup.py +1 -1
  10. ras_commander-0.80.2/tests/test_ras_examples_initialization.py +241 -0
  11. {ras_commander-0.79.1 → ras_commander-0.80.2}/LICENSE +0 -0
  12. {ras_commander-0.79.1 → ras_commander-0.80.2}/README.md +0 -0
  13. {ras_commander-0.79.1 → ras_commander-0.80.2}/pyproject.toml +0 -0
  14. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/Decorators.py +0 -0
  15. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfBase.py +0 -0
  16. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfBndry.py +0 -0
  17. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfFluvialPluvial.py +0 -0
  18. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfInfiltration.py +0 -0
  19. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfMesh.py +0 -0
  20. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfPipe.py +0 -0
  21. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfPlan.py +0 -0
  22. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfPlot.py +0 -0
  23. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfPump.py +0 -0
  24. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfResultsMesh.py +0 -0
  25. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfResultsPlan.py +0 -0
  26. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfResultsPlot.py +0 -0
  27. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfResultsXsec.py +0 -0
  28. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfStruc.py +0 -0
  29. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/HdfUtils.py +0 -0
  30. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/LoggingConfig.py +0 -0
  31. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/RasCmdr.py +0 -0
  32. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/RasPlan.py +0 -0
  33. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/RasPrj.py +0 -0
  34. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/RasUnsteady.py +0 -0
  35. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander/RasUtils.py +0 -0
  36. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander.egg-info/dependency_links.txt +0 -0
  37. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander.egg-info/requires.txt +0 -0
  38. {ras_commander-0.79.1 → ras_commander-0.80.2}/ras_commander.egg-info/top_level.txt +0 -0
  39. {ras_commander-0.79.1 → ras_commander-0.80.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ras-commander
3
- Version: 0.79.1
3
+ Version: 0.80.2
4
4
  Summary: A Python library for automating HEC-RAS 6.x operations
5
5
  Home-page: https://github.com/gpt-cmdr/ras-commander
6
6
  Author: William M. Katzenmeyer, P.E., C.F.M.
@@ -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
- ineff_blocks = hdf['/Geometry/Cross Sections/Ineffective Blocks'][:]
119
- ineff_info = hdf['/Geometry/Cross Sections/Ineffective Info'][:]
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
- ineff_start_idx = ineff_info[i][0]
169
- ineff_count = ineff_info[i][1]
170
- if ineff_count > 0:
171
- blocks = ineff_blocks[ineff_start_idx:ineff_start_idx + ineff_count]
172
- blocks_list = []
173
- for block in blocks:
174
- block_dict = {
175
- 'Left Sta': float(block['Left Sta']),
176
- 'Right Sta': float(block['Right Sta']),
177
- 'Elevation': float(block['Elevation']),
178
- 'Permanent': bool(block['Permanent'])
179
- }
180
- blocks_list.append(block_dict)
181
- ineffective_blocks.append(blocks_list)
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
 
@@ -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 = cls.projects_dir
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 = cls.projects_dir / project_name
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 = cls.projects_dir / f"{project_name}_temp.zip"
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...")