ras-commander 0.67.0__tar.gz → 0.68.0__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 (38) hide show
  1. {ras_commander-0.67.0/ras_commander.egg-info → ras_commander-0.68.0}/PKG-INFO +1 -1
  2. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/Decorators.py +30 -8
  3. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfResultsMesh.py +26 -26
  4. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/__init__.py +1 -1
  5. {ras_commander-0.67.0 → ras_commander-0.68.0/ras_commander.egg-info}/PKG-INFO +1 -1
  6. {ras_commander-0.67.0 → ras_commander-0.68.0}/setup.py +1 -1
  7. {ras_commander-0.67.0 → ras_commander-0.68.0}/LICENSE +0 -0
  8. {ras_commander-0.67.0 → ras_commander-0.68.0}/README.md +0 -0
  9. {ras_commander-0.67.0 → ras_commander-0.68.0}/pyproject.toml +0 -0
  10. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfBase.py +0 -0
  11. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfBndry.py +0 -0
  12. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfFluvialPluvial.py +0 -0
  13. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfInfiltration.py +0 -0
  14. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfMesh.py +0 -0
  15. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfPipe.py +0 -0
  16. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfPlan.py +0 -0
  17. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfPlot.py +0 -0
  18. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfPump.py +0 -0
  19. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfResultsPlan.py +0 -0
  20. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfResultsPlot.py +0 -0
  21. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfResultsXsec.py +0 -0
  22. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfStruc.py +0 -0
  23. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfUtils.py +0 -0
  24. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/HdfXsec.py +0 -0
  25. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/LoggingConfig.py +0 -0
  26. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/RasCmdr.py +0 -0
  27. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/RasExamples.py +0 -0
  28. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/RasGeo.py +0 -0
  29. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/RasMapper.py +0 -0
  30. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/RasPlan.py +0 -0
  31. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/RasPrj.py +0 -0
  32. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/RasUnsteady.py +0 -0
  33. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander/RasUtils.py +0 -0
  34. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander.egg-info/SOURCES.txt +0 -0
  35. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander.egg-info/dependency_links.txt +0 -0
  36. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander.egg-info/requires.txt +0 -0
  37. {ras_commander-0.67.0 → ras_commander-0.68.0}/ras_commander.egg-info/top_level.txt +0 -0
  38. {ras_commander-0.67.0 → ras_commander-0.68.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ras-commander
3
- Version: 0.67.0
3
+ Version: 0.68.0
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.
@@ -44,13 +44,24 @@ def standardize_input(file_type: str = 'plan_hdf'):
44
44
  # Check if the function expects an hdf_path parameter
45
45
  sig = inspect.signature(func)
46
46
  param_names = list(sig.parameters.keys())
47
+
48
+ # If first parameter is 'hdf_file', pass an h5py object
49
+ if param_names and param_names[0] == 'hdf_file':
50
+ if isinstance(args[0], h5py.File):
51
+ return func(*args, **kwargs)
52
+ elif isinstance(args[0], (str, Path)):
53
+ with h5py.File(args[0], 'r') as hdf:
54
+ return func(hdf, *args[1:], **kwargs)
55
+ else:
56
+ raise ValueError(f"Expected h5py.File or path, got {type(args[0])}")
47
57
 
48
58
  # Handle both static method calls and regular function calls
49
59
  if args and isinstance(args[0], type):
50
60
  # Static method call, remove the class argument
51
61
  args = args[1:]
52
62
 
53
- hdf_input = kwargs.pop('hdf_path', None) or (args[0] if args else None)
63
+ # Get hdf_input from kwargs if provided with hdf_path key, or take first positional arg
64
+ hdf_input = kwargs.pop('hdf_path', None) if 'hdf_path' in kwargs else (args[0] if args else None)
54
65
 
55
66
  # Import ras here to ensure we get the most current instance
56
67
  from .RasPrj import ras as ras
@@ -113,18 +124,23 @@ def standardize_input(file_type: str = 'plan_hdf'):
113
124
  hdf_path = Path(str(hdf_path_str))
114
125
  except Exception as e:
115
126
  logger.warning(f"Error retrieving plan HDF path: {str(e)}")
127
+
128
+
116
129
  elif file_type == 'geom_hdf':
117
130
  try:
118
- # Convert geom_number column to integers for comparison
119
- geom_info = ras_obj.geom_df[ras_obj.geom_df['geom_number'].astype(int) == number_int]
131
+ # Convert geometry_number column to integers for comparison
132
+ geom_info = ras_obj.plan_df[ras_obj.plan_df['geometry_number'].astype(int) == number_int]
120
133
  if not geom_info.empty:
121
- hdf_path_str = geom_info.iloc[0]['hdf_path']
134
+ hdf_path_str = ras_obj.geom_df.iloc[0]['hdf_path']
122
135
  if pd.notna(hdf_path_str):
123
136
  hdf_path = Path(str(hdf_path_str))
124
137
  except Exception as e:
125
138
  logger.warning(f"Error retrieving geometry HDF path: {str(e)}")
126
139
  else:
127
140
  raise ValueError(f"Invalid file type: {file_type}")
141
+
142
+
143
+
128
144
 
129
145
  # Handle integer inputs (assuming they're plan or geom numbers)
130
146
  elif isinstance(hdf_input, int):
@@ -148,10 +164,10 @@ def standardize_input(file_type: str = 'plan_hdf'):
148
164
  logger.warning(f"Error retrieving plan HDF path: {str(e)}")
149
165
  elif file_type == 'geom_hdf':
150
166
  try:
151
- # Convert geom_number column to integers for comparison
152
- geom_info = ras_obj.geom_df[ras_obj.geom_df['geom_number'].astype(int) == number_int]
167
+ # Convert geometry_number column to integers for comparison
168
+ geom_info = ras_obj.plan_df[ras_obj.plan_df['geometry_number'].astype(int) == number_int]
153
169
  if not geom_info.empty:
154
- hdf_path_str = geom_info.iloc[0]['hdf_path']
170
+ hdf_path_str = ras_obj.geom_df.iloc[0]['hdf_path']
155
171
  if pd.notna(hdf_path_str):
156
172
  hdf_path = Path(str(hdf_path_str))
157
173
  except Exception as e:
@@ -177,7 +193,13 @@ def standardize_input(file_type: str = 'plan_hdf'):
177
193
  # Continue anyway, let the function handle detailed validation
178
194
 
179
195
  # Pass all original arguments and keywords, replacing hdf_input with standardized hdf_path
180
- new_args = (hdf_path,) + args[1:]
196
+ # If the original input was positional, replace the first argument
197
+ if args and 'hdf_path' not in kwargs:
198
+ new_args = (hdf_path,) + args[1:]
199
+ else:
200
+ new_args = args
201
+ kwargs['hdf_path'] = hdf_path
202
+
181
203
  return func(*new_args, **kwargs)
182
204
 
183
205
  return wrapper
@@ -150,8 +150,8 @@ class HdfResultsMesh:
150
150
  Valid variables include:
151
151
  "Water Surface", "Face Velocity", "Cell Velocity X"...
152
152
  """
153
- with h5py.File(hdf_path, 'r') as hdf_file:
154
- return HdfResultsMesh._get_mesh_timeseries_output(hdf_file, mesh_name, var, truncate)
153
+ with h5py.File(hdf_path, 'r') as hdf_path:
154
+ return HdfResultsMesh._get_mesh_timeseries_output(hdf_path, mesh_name, var, truncate)
155
155
 
156
156
  @staticmethod
157
157
  @log_call
@@ -210,8 +210,8 @@ class HdfResultsMesh:
210
210
  - Variable metadata
211
211
  """
212
212
  try:
213
- with h5py.File(hdf_path, 'r') as hdf_file:
214
- return HdfResultsMesh._get_mesh_cells_timeseries_output(hdf_file, mesh_names, var, truncate)
213
+ with h5py.File(hdf_path, 'r') as hdf_path:
214
+ return HdfResultsMesh._get_mesh_cells_timeseries_output(hdf_path, mesh_names, var, truncate)
215
215
  except Exception as e:
216
216
  logger.error(f"Error in get_mesh_cells_timeseries: {str(e)}")
217
217
  raise ValueError(f"Error processing timeseries output data: {e}")
@@ -219,7 +219,7 @@ class HdfResultsMesh:
219
219
  @staticmethod
220
220
  @log_call
221
221
  @standardize_input(file_type='plan_hdf')
222
- def get_mesh_last_iter(hdf_path: Path) -> pd.DataFrame:
222
+ def get_mesh_last_iter(hdf_file: Path) -> pd.DataFrame:
223
223
  """
224
224
  Get last iteration count for each mesh cell.
225
225
 
@@ -229,7 +229,7 @@ class HdfResultsMesh:
229
229
  Returns:
230
230
  pd.DataFrame: DataFrame containing last iteration counts.
231
231
  """
232
- return HdfResultsMesh.get_mesh_summary_output(hdf_path, "Cell Last Iteration")
232
+ return HdfResultsMesh.get_mesh_summary_output(hdf_file, "Cell Last Iteration")
233
233
 
234
234
 
235
235
  @staticmethod
@@ -394,7 +394,7 @@ class HdfResultsMesh:
394
394
 
395
395
 
396
396
  @staticmethod
397
- def _get_mesh_cells_timeseries_output(hdf_file: h5py.File,
397
+ def _get_mesh_cells_timeseries_output(hdf_path: h5py.File,
398
398
  mesh_names: Optional[Union[str, List[str]]] = None,
399
399
  var: Optional[str] = None,
400
400
  truncate: bool = False) -> Dict[str, xr.Dataset]:
@@ -402,7 +402,7 @@ class HdfResultsMesh:
402
402
  Get mesh cells timeseries output for specified meshes and variables.
403
403
 
404
404
  Args:
405
- hdf_file (h5py.File): Open HDF file object.
405
+ hdf_path (h5py.File): Open HDF file object.
406
406
  mesh_names (Optional[Union[str, List[str]]]): Name(s) of the mesh(es). If None, processes all available meshes.
407
407
  var (Optional[str]): Name of the variable to retrieve. If None, retrieves all variables.
408
408
  truncate (bool): If True, truncates the output to remove trailing zeros.
@@ -431,11 +431,11 @@ class HdfResultsMesh:
431
431
  }
432
432
 
433
433
  try:
434
- start_time = HdfBase.get_simulation_start_time(hdf_file)
435
- time_stamps = HdfBase.get_unsteady_timestamps(hdf_file)
434
+ start_time = HdfBase.get_simulation_start_time(hdf_path)
435
+ time_stamps = HdfBase.get_unsteady_timestamps(hdf_path)
436
436
 
437
437
  if mesh_names is None:
438
- mesh_names = HdfResultsMesh._get_available_meshes(hdf_file)
438
+ mesh_names = HdfResultsMesh._get_available_meshes(hdf_path)
439
439
  elif isinstance(mesh_names, str):
440
440
  mesh_names = [mesh_names]
441
441
 
@@ -450,7 +450,7 @@ class HdfResultsMesh:
450
450
  for variable in variables:
451
451
  try:
452
452
  path = HdfResultsMesh._get_mesh_timeseries_output_path(mesh_name, variable)
453
- dataset = hdf_file[path]
453
+ dataset = hdf_path[path]
454
454
  values = dataset[:]
455
455
  units = dataset.attrs.get("Units", "").decode("utf-8")
456
456
 
@@ -495,12 +495,12 @@ class HdfResultsMesh:
495
495
 
496
496
 
497
497
  @staticmethod
498
- def _get_mesh_timeseries_output(hdf_file: h5py.File, mesh_name: str, var: str, truncate: bool = True) -> xr.DataArray:
498
+ def _get_mesh_timeseries_output(hdf_path: h5py.File, mesh_name: str, var: str, truncate: bool = True) -> xr.DataArray:
499
499
  """
500
500
  Get timeseries output for a specific mesh and variable.
501
501
 
502
502
  Args:
503
- hdf_file (h5py.File): Open HDF file object.
503
+ hdf_path (h5py.File): Open HDF file object.
504
504
  mesh_name (str): Name of the mesh.
505
505
  var (str): Variable name to retrieve.
506
506
  truncate (bool): Whether to truncate the output to remove trailing zeros (default True).
@@ -514,18 +514,18 @@ class HdfResultsMesh:
514
514
  try:
515
515
  path = HdfResultsMesh._get_mesh_timeseries_output_path(mesh_name, var)
516
516
 
517
- if path not in hdf_file:
517
+ if path not in hdf_path:
518
518
  raise ValueError(f"Path {path} not found in HDF file")
519
519
 
520
- dataset = hdf_file[path]
520
+ dataset = hdf_path[path]
521
521
  values = dataset[:]
522
522
  units = dataset.attrs.get("Units", "").decode("utf-8")
523
523
 
524
524
  # Get start time and timesteps
525
- start_time = HdfBase.get_simulation_start_time(hdf_file)
525
+ start_time = HdfBase.get_simulation_start_time(hdf_path)
526
526
  # Updated to use the new function name from HdfUtils
527
527
  timesteps = HdfUtils.convert_timesteps_to_datetimes(
528
- np.array(hdf_file["Results/Unsteady/Output/Output Blocks/Base Output/Unsteady Time Series/Time"][:]),
528
+ np.array(hdf_path["Results/Unsteady/Output/Output Blocks/Base Output/Unsteady Time Series/Time"][:]),
529
529
  start_time
530
530
  )
531
531
 
@@ -555,12 +555,12 @@ class HdfResultsMesh:
555
555
 
556
556
 
557
557
  @staticmethod
558
- def _get_mesh_timeseries_output_values_units(hdf_file: h5py.File, mesh_name: str, var: str) -> Tuple[np.ndarray, str]:
558
+ def _get_mesh_timeseries_output_values_units(hdf_path: h5py.File, mesh_name: str, var: str) -> Tuple[np.ndarray, str]:
559
559
  """
560
560
  Get the mesh timeseries output values and units for a specific variable from the HDF file.
561
561
 
562
562
  Args:
563
- hdf_file (h5py.File): Open HDF file object.
563
+ hdf_path (h5py.File): Open HDF file object.
564
564
  mesh_name (str): Name of the mesh.
565
565
  var (str): Variable name to retrieve.
566
566
 
@@ -568,7 +568,7 @@ class HdfResultsMesh:
568
568
  Tuple[np.ndarray, str]: A tuple containing the output values and units.
569
569
  """
570
570
  path = HdfResultsMesh._get_mesh_timeseries_output_path(mesh_name, var)
571
- group = hdf_file[path]
571
+ group = hdf_path[path]
572
572
  values = group[:]
573
573
  units = group.attrs.get("Units")
574
574
  if units is not None:
@@ -577,17 +577,17 @@ class HdfResultsMesh:
577
577
 
578
578
 
579
579
  @staticmethod
580
- def _get_available_meshes(hdf_file: h5py.File) -> List[str]:
580
+ def _get_available_meshes(hdf_path: h5py.File) -> List[str]:
581
581
  """
582
582
  Get the names of all available meshes in the HDF file.
583
583
 
584
584
  Args:
585
- hdf_file (h5py.File): Open HDF file object.
585
+ hdf_path (h5py.File): Open HDF file object.
586
586
 
587
587
  Returns:
588
588
  List[str]: A list of mesh names.
589
589
  """
590
- return HdfMesh.get_mesh_area_names(hdf_file)
590
+ return HdfMesh.get_mesh_area_names(hdf_path)
591
591
 
592
592
 
593
593
  @staticmethod
@@ -599,7 +599,7 @@ class HdfResultsMesh:
599
599
 
600
600
  Parameters
601
601
  ----------
602
- hdf_file : h5py.File
602
+ hdf_path : h5py.File
603
603
  Open HDF file object.
604
604
  var : str
605
605
  The summary output variable to retrieve.
@@ -734,7 +734,7 @@ class HdfResultsMesh:
734
734
  Return the HDF group for a given mesh and summary output variable.
735
735
 
736
736
  Args:
737
- hdf_file (h5py.File): Open HDF file object.
737
+ hdf_path (h5py.File): Open HDF file object.
738
738
  mesh_name (str): Name of the mesh.
739
739
  var (str): Name of the summary output variable.
740
740
 
@@ -10,7 +10,7 @@ try:
10
10
  __version__ = version("ras-commander")
11
11
  except PackageNotFoundError:
12
12
  # package is not installed
13
- __version__ = "0.67.0"
13
+ __version__ = "0.68.0"
14
14
 
15
15
  # Set up logging
16
16
  setup_logging()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ras-commander
3
- Version: 0.67.0
3
+ Version: 0.68.0
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.
@@ -28,7 +28,7 @@ class CustomBuildPy(build_py):
28
28
 
29
29
  setup(
30
30
  name="ras-commander",
31
- version="0.67.0",
31
+ version="0.68.0",
32
32
  packages=find_packages(),
33
33
  include_package_data=True,
34
34
  python_requires='>=3.10',
File without changes
File without changes
File without changes