ras-commander 0.46.0__py3-none-any.whl → 0.48.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/HdfBndry.py CHANGED
@@ -70,9 +70,9 @@ class HdfBndry:
70
70
  return gpd.GeoDataFrame(
71
71
  {
72
72
  "bc_line_id": bc_line_ids,
73
- "name": names,
73
+ "Name": names,
74
74
  "mesh_name": mesh_names,
75
- "type": types,
75
+ "Type": types,
76
76
  "geometry": geoms,
77
77
  },
78
78
  geometry="geometry",
@@ -110,7 +110,7 @@ class HdfBndry:
110
110
  )
111
111
  geoms = HdfBndry._get_polylines(hdf_file, breaklines_path)
112
112
  return gpd.GeoDataFrame(
113
- {"bl_id": bl_line_ids, "name": names, "geometry": geoms},
113
+ {"bl_id": bl_line_ids, "Name": names, "geometry": geoms},
114
114
  geometry="geometry",
115
115
  crs=HdfUtils.projection(hdf_file),
116
116
  )
@@ -158,7 +158,7 @@ class HdfBndry:
158
158
  )
159
159
  )
160
160
  return gpd.GeoDataFrame(
161
- {"rr_id": rr_ids, "name": names, "geometry": geoms},
161
+ {"rr_id": rr_ids, "Name": names, "geometry": geoms},
162
162
  geometry="geometry",
163
163
  crs=HdfUtils.projection(hdf_file),
164
164
  )
@@ -242,9 +242,9 @@ class HdfBndry:
242
242
  return gpd.GeoDataFrame(
243
243
  {
244
244
  "refln_id": refline_ids,
245
- "refln_name": names,
246
- "mesh_name": mesh_names,
247
- "type": types,
245
+ "Name": names,
246
+ "mesh-name": mesh_names,
247
+ "Type": types,
248
248
  "geometry": geoms,
249
249
  },
250
250
  geometry="geometry",
@@ -286,9 +286,9 @@ class HdfBndry:
286
286
  return gpd.GeoDataFrame(
287
287
  {
288
288
  "refpt_id": range(attributes.shape[0]),
289
- "refpt_name": names,
289
+ "Name": names,
290
290
  "mesh_name": mesh_names,
291
- "cell_id": cell_id,
291
+ "Cell Index": cell_id,
292
292
  "geometry": list(map(Point, points)),
293
293
  },
294
294
  geometry="geometry",
@@ -3,7 +3,6 @@ import pandas as pd
3
3
  import geopandas as gpd
4
4
  import matplotlib.pyplot as plt
5
5
  from collections import defaultdict
6
- from rtree import index
7
6
  from shapely.geometry import LineString, MultiLineString
8
7
  from tqdm import tqdm
9
8
 
@@ -236,6 +235,11 @@ class HdfFluvialPluvial:
236
235
 
237
236
  @staticmethod
238
237
  def _process_cell_adjacencies(cell_polygons_gdf: gpd.GeoDataFrame) -> Tuple[Dict[int, List[int]], Dict[int, Dict[int, LineString]]]:
238
+ """
239
+ Process cell adjacencies and common edges using R-tree indexing.
240
+ """
241
+ # Install rtree using pip install rtree if not already installed
242
+ from rtree import index
239
243
  cell_adjacency = defaultdict(list)
240
244
  common_edges = defaultdict(dict)
241
245
  idx = index.Index()
@@ -314,4 +318,9 @@ class HdfFluvialPluvial:
314
318
  - GeoDataFrame with the specified projection.
315
319
  """
316
320
  gdf = gpd.GeoDataFrame(df, geometry='geometry', crs=projection)
321
+
317
322
  return gdf
323
+
324
+
325
+
326
+
ras_commander/HdfMesh.py CHANGED
@@ -64,7 +64,7 @@ class HdfMesh:
64
64
  return list()
65
65
  return list(
66
66
  [
67
- HdfUtils.convert_ras_hdf_string(n)
67
+ HdfUtils.convert_ras_hdf_string(n.decode('utf-8')) # Decode as UTF-8
68
68
  for n in hdf_file["Geometry/2D Flow Areas/Attributes"][()]["Name"]
69
69
  ]
70
70
  )
@@ -174,12 +174,11 @@ class HdfMesh:
174
174
  except Exception as e:
175
175
  logger.error(f"Error reading mesh cell polygons from {hdf_path}: {str(e)}")
176
176
  return GeoDataFrame()
177
-
178
177
  @staticmethod
179
178
  @standardize_input(file_type='plan_hdf')
180
179
  def mesh_cell_points(hdf_path: Path) -> GeoDataFrame:
181
180
  """
182
- Return 2D flow mesh cell points.
181
+ Return 2D flow mesh cell center points.
183
182
 
184
183
  Parameters
185
184
  ----------
@@ -189,29 +188,29 @@ class HdfMesh:
189
188
  Returns
190
189
  -------
191
190
  GeoDataFrame
192
- A GeoDataFrame containing the 2D flow mesh cell points.
191
+ A GeoDataFrame containing the 2D flow mesh cell center points.
193
192
  """
194
193
  try:
195
194
  with h5py.File(hdf_path, 'r') as hdf_file:
196
195
  mesh_area_names = HdfMesh.mesh_area_names(hdf_path)
197
196
  if not mesh_area_names:
198
197
  return GeoDataFrame()
198
+
199
199
  pnt_dict = {"mesh_name": [], "cell_id": [], "geometry": []}
200
- for i, mesh_name in enumerate(mesh_area_names):
201
- starting_row, count = hdf_file["Geometry/2D Flow Areas/Cell Info"][()][i]
202
- cell_pnt_coords = hdf_file["Geometry/2D Flow Areas/Cell Points"][()][
203
- starting_row : starting_row + count
204
- ]
205
- pnt_dict["mesh_name"] += [mesh_name] * cell_pnt_coords.shape[0]
206
- pnt_dict["cell_id"] += range(count)
200
+ for mesh_name in mesh_area_names:
201
+ cell_center_coords = hdf_file[f"Geometry/2D Flow Areas/{mesh_name}/Cells Center Coordinate"][()]
202
+ cell_count = len(cell_center_coords)
203
+
204
+ pnt_dict["mesh_name"] += [mesh_name] * cell_count
205
+ pnt_dict["cell_id"] += range(cell_count)
207
206
  pnt_dict["geometry"] += list(
208
207
  np.vectorize(lambda coords: Point(coords), signature="(n)->()")(
209
- cell_pnt_coords
208
+ cell_center_coords
210
209
  )
211
210
  )
212
211
  return GeoDataFrame(pnt_dict, geometry="geometry", crs=HdfUtils.projection(hdf_path))
213
212
  except Exception as e:
214
- self.logger.error(f"Error reading mesh cell points from {hdf_path}: {str(e)}")
213
+ logger.error(f"Error reading mesh cell points from {hdf_path}: {str(e)}")
215
214
  return GeoDataFrame()
216
215
 
217
216
  @staticmethod
@@ -293,7 +292,7 @@ class HdfMesh:
293
292
  try:
294
293
  value = d2_flow_area[name][()]
295
294
  if isinstance(value, bytes):
296
- value = value.decode('utf-8')
295
+ value = value.decode('utf-8') # Decode as UTF-8
297
296
  result[name] = value
298
297
  except Exception as e:
299
298
  logger.warning(f"Error converting attribute '{name}': {str(e)}")
@@ -305,7 +304,6 @@ class HdfMesh:
305
304
  logger.error(f"Error reading 2D flow area attributes from {hdf_path}: {str(e)}")
306
305
  return {}
307
306
 
308
-
309
307
  @staticmethod
310
308
  @standardize_input(file_type='geom_hdf')
311
309
  def get_face_property_tables(hdf_path: Path) -> Dict[str, pd.DataFrame]:
@@ -340,10 +338,10 @@ class HdfMesh:
340
338
  for z, area, wetted_perimeter, mannings_n in face_values:
341
339
  face_data.append({
342
340
  'Face ID': face_id,
343
- 'Z': z,
344
- 'Area': area,
345
- 'Wetted Perimeter': wetted_perimeter,
346
- "Manning's n": mannings_n
341
+ 'Z': str(z),
342
+ 'Area': str(area),
343
+ 'Wetted Perimeter': str(wetted_perimeter),
344
+ "Manning's n": str(mannings_n)
347
345
  })
348
346
 
349
347
  result[mesh_name] = pd.DataFrame(face_data)
@@ -352,4 +350,4 @@ class HdfMesh:
352
350
 
353
351
  except Exception as e:
354
352
  logger.error(f"Error extracting face property tables from {hdf_path}: {str(e)}")
355
- return {}
353
+ return {}
ras_commander/RasPrj.py CHANGED
@@ -107,7 +107,7 @@ class RasPrj:
107
107
  # Add Geom_File to plan_df
108
108
  self.plan_df['Geom_File'] = self.plan_df.apply(lambda row: self._get_geom_file_for_plan(row['plan_number']), axis=1)
109
109
 
110
- @log_call
110
+
111
111
  def _get_geom_file_for_plan(self, plan_number):
112
112
  """
113
113
  Get the geometry file path for a given plan number.
@@ -133,7 +133,7 @@ class RasPrj:
133
133
  logger.error(f"Error reading plan file for geometry: {e}")
134
134
  return None
135
135
 
136
- @log_call
136
+
137
137
  def _parse_plan_file(self, plan_file_path):
138
138
  """
139
139
  Parse a plan file and extract critical information.
@@ -193,9 +193,6 @@ class RasPrj:
193
193
 
194
194
  return plan_info
195
195
 
196
-
197
-
198
- @log_call
199
196
  def _get_prj_entries(self, entry_type):
200
197
  """
201
198
  Extract entries of a specific type from the HEC-RAS project file.
@@ -242,7 +239,6 @@ class RasPrj:
242
239
 
243
240
  return pd.DataFrame(entries)
244
241
 
245
- @log_call
246
242
  def _parse_unsteady_file(self, unsteady_file_path):
247
243
  """
248
244
  Parse an unsteady flow file and extract critical information.
@@ -617,7 +613,6 @@ class RasPrj:
617
613
 
618
614
  return merged_df
619
615
 
620
- @log_call
621
616
  def _parse_boundary_condition(self, block: str, unsteady_number: str, bc_number: int) -> Tuple[Dict, str]:
622
617
  lines = block.split('\n')
623
618
  bc_info = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ras-commander
3
- Version: 0.46.0
3
+ Version: 0.48.0
4
4
  Summary: A Python library for automating HEC-RAS operations
5
5
  Home-page: https://github.com/billk-FM/ras-commander
6
6
  Author: William M. Katzenmeyer
@@ -61,7 +61,7 @@ Create a virtual environment with conda or venv (ask ChatGPT if you need help)
61
61
 
62
62
  In your virtual environment, install ras-commander using pip:
63
63
  ```
64
- pip install h5py numpy pandas requests tqdm scipy
64
+ pip install h5py numpy pandas requests tqdm scipy xarray geopandas matplotlib ras-commander ipython psutil shapely fiona pathlib rtree
65
65
  pip install --upgrade ras-commander
66
66
  ```
67
67
 
@@ -1,8 +1,8 @@
1
1
  ras_commander/Decorators.py,sha256=i5AEQbe7JeI8Y3O_dQ5OO4Ab0KO5SiZTiysFBGxqTRU,4978
2
2
  ras_commander/HdfBase.py,sha256=HV5ccV9QH2lz4ZRYqK2d7_S833cTSUcostzxxSPb4O4,7129
3
- ras_commander/HdfBndry.py,sha256=LWaDMHeo0V_VOpx7D9q7W_0WvWsD6NQThiSLYPY8ApE,20761
4
- ras_commander/HdfFluvialPluvial.py,sha256=Ca0Yd8Vk7Em2xJz9sM5IXkvCiH5Qm0DKrJcookGYmgw,13765
5
- ras_commander/HdfMesh.py,sha256=1P_780k6CaTOcOTdzMnG8qzs6U7-_JyNDOw0sgQaY10,14648
3
+ ras_commander/HdfBndry.py,sha256=29SAcn-LGf3QiNCeRmlT7JsGI94Dwl9NMm-zHNBuXlA,20752
4
+ ras_commander/HdfFluvialPluvial.py,sha256=5OwYYEoLRJ4gfzi4kOBPO9_LVI_OyqW-Z8Jr7POOr34,13965
5
+ ras_commander/HdfMesh.py,sha256=lNzEN7npA4KXUB9ZLyCMRk-EuL0oPD6J5MPZYamV7xU,14657
6
6
  ras_commander/HdfPipe.py,sha256=StL7D5hgdknzwS8VRSd9Rg_U9VOstepDvYvquLYCLOs,34348
7
7
  ras_commander/HdfPlan.py,sha256=DDnkMZ4Px4_4Netb7rLyxpDG1N-C742Yce4fDmNZAVo,6977
8
8
  ras_commander/HdfPump.py,sha256=LPQPjOL6dWpJBW2F9pQVzNyqQL1XvNvUmjtf_hDygV4,10486
@@ -18,13 +18,13 @@ ras_commander/RasExamples.py,sha256=FDit6FWzTQbv42Xx0gtSJB17HDeol_eykxV0qVpnwIk,
18
18
  ras_commander/RasGeo.py,sha256=x7eFvUQ_dPZxAVq2Gw_GIRzn-Cf7DLKZDTwk1fjrkf8,5395
19
19
  ras_commander/RasGpt.py,sha256=1Nitlf5QyeBQo8Q8I8pJKaTtQ0GdsBQA71LIKUAOycA,839
20
20
  ras_commander/RasPlan.py,sha256=fVuWQL6bnRCoHm-WiWv2mWZ8vTsDXn1BxcwUf03ma8s,51276
21
- ras_commander/RasPrj.py,sha256=ePLcPNcKVMgijvJKkJIWwQslQi2D6zq2UTW-8XCFmto,36159
21
+ ras_commander/RasPrj.py,sha256=Ppmv3Yx_iN1ARKWC_dfSGVhdi4tHIuapDSdLbuAAGLU,36084
22
22
  ras_commander/RasToGo.py,sha256=UiUbvpjcAxAkWdSc-9Yywy7eOkGJaTHs24p4cjiL7co,588
23
23
  ras_commander/RasUnsteady.py,sha256=4j5Ga5hP8LepgR93uywjUjOEDhznLF7UnNtRmBS5d48,30779
24
24
  ras_commander/RasUtils.py,sha256=NBMxTHWHoTH2MJzqJ0y1_00fgKSS1GnNuEikwZ3Pqzs,34153
25
25
  ras_commander/__init__.py,sha256=-8mrN9qNbKiK0RfgCJasORkzuIKPHmY6RfYLzZqm2ok,1804
26
- ras_commander-0.46.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
27
- ras_commander-0.46.0.dist-info/METADATA,sha256=zmHXWeiuu3WRcnmcJJXiBLCvkTACli-Dm4uUpwJ9F9k,15935
28
- ras_commander-0.46.0.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
29
- ras_commander-0.46.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
30
- ras_commander-0.46.0.dist-info/RECORD,,
26
+ ras_commander-0.48.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
27
+ ras_commander-0.48.0.dist-info/METADATA,sha256=sEeBUJL0yGQez4hOPSqMr39IWLOzqMK90hLiaVFT45k,16020
28
+ ras_commander-0.48.0.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
29
+ ras_commander-0.48.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
30
+ ras_commander-0.48.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (75.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5