ras-commander 0.43.0__py3-none-any.whl → 0.45.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.
@@ -1,17 +1,28 @@
1
+ """
2
+ Class: HdfResultsXsec
3
+
4
+ Attribution: A substantial amount of code in this file is sourced or derived
5
+ from the https://github.com/fema-ffrd/rashdf library,
6
+ released under MIT license and Copyright (c) 2024 fema-ffrd
7
+
8
+ The file has been forked and modified for use in RAS Commander.
9
+ """
10
+
11
+ from pathlib import Path
12
+ from typing import Union, Optional, List
13
+
1
14
  import h5py
2
15
  import numpy as np
3
16
  import pandas as pd
4
- from pathlib import Path
5
- from typing import Union, Optional, List
17
+ import xarray as xr
18
+
6
19
  from .HdfBase import HdfBase
7
20
  from .HdfUtils import HdfUtils
8
21
  from .Decorators import standardize_input, log_call
9
- from .LoggingConfig import setup_logging, get_logger
10
- import xarray as xr
22
+ from .LoggingConfig import get_logger
11
23
 
12
24
  logger = get_logger(__name__)
13
25
 
14
-
15
26
  class HdfResultsXsec:
16
27
  """
17
28
  A class for handling cross-section results from HEC-RAS HDF files.
@@ -225,3 +236,208 @@ class HdfResultsXsec:
225
236
  """
226
237
  return HdfResultsXsec.steady_profile_xs_output(hdf_path, "Velocity Total")
227
238
 
239
+
240
+ @staticmethod
241
+ @log_call
242
+ @standardize_input(file_type='plan_hdf')
243
+ def get_pipe_network_summary(hdf_path: Path) -> pd.DataFrame:
244
+ """
245
+ Extract summary data for pipe networks from the HDF file.
246
+
247
+ Args:
248
+ hdf_path (Path): Path to the HDF file.
249
+
250
+ Returns:
251
+ pd.DataFrame: DataFrame containing pipe network summary data.
252
+
253
+ Raises:
254
+ KeyError: If the required datasets are not found in the HDF file.
255
+ """
256
+ try:
257
+ with h5py.File(hdf_path, 'r') as hdf:
258
+ # Extract summary data
259
+ summary_path = "/Results/Unsteady/Summary/Pipe Network"
260
+ if summary_path not in hdf:
261
+ logger.warning("Pipe Network summary data not found in HDF file")
262
+ return pd.DataFrame()
263
+
264
+ summary_data = hdf[summary_path][()]
265
+
266
+ # Create DataFrame
267
+ df = pd.DataFrame(summary_data)
268
+
269
+ # Convert column names
270
+ df.columns = [col.decode('utf-8') if isinstance(col, bytes) else col for col in df.columns]
271
+
272
+ # Convert byte string values to regular strings
273
+ for col in df.columns:
274
+ if df[col].dtype == object:
275
+ df[col] = df[col].apply(lambda x: x.decode('utf-8') if isinstance(x, bytes) else x)
276
+
277
+ return df
278
+
279
+ except KeyError as e:
280
+ logger.error(f"Required dataset not found in HDF file: {e}")
281
+ raise
282
+ except Exception as e:
283
+ logger.error(f"Error extracting pipe network summary data: {e}")
284
+ raise
285
+
286
+ @staticmethod
287
+ @log_call
288
+ @standardize_input(file_type='plan_hdf')
289
+ def get_pump_station_summary(hdf_path: Path) -> pd.DataFrame:
290
+ """
291
+ Extract summary data for pump stations from the HDF file.
292
+
293
+ Args:
294
+ hdf_path (Path): Path to the HDF file.
295
+
296
+ Returns:
297
+ pd.DataFrame: DataFrame containing pump station summary data.
298
+
299
+ Raises:
300
+ KeyError: If the required datasets are not found in the HDF file.
301
+ """
302
+ try:
303
+ with h5py.File(hdf_path, 'r') as hdf:
304
+ # Extract summary data
305
+ summary_path = "/Results/Unsteady/Summary/Pump Station"
306
+ if summary_path not in hdf:
307
+ logger.warning("Pump Station summary data not found in HDF file")
308
+ return pd.DataFrame()
309
+
310
+ summary_data = hdf[summary_path][()]
311
+
312
+ # Create DataFrame
313
+ df = pd.DataFrame(summary_data)
314
+
315
+ # Convert column names
316
+ df.columns = [col.decode('utf-8') if isinstance(col, bytes) else col for col in df.columns]
317
+
318
+ # Convert byte string values to regular strings
319
+ for col in df.columns:
320
+ if df[col].dtype == object:
321
+ df[col] = df[col].apply(lambda x: x.decode('utf-8') if isinstance(x, bytes) else x)
322
+
323
+ return df
324
+
325
+ except KeyError as e:
326
+ logger.error(f"Required dataset not found in HDF file: {e}")
327
+ raise
328
+ except Exception as e:
329
+ logger.error(f"Error extracting pump station summary data: {e}")
330
+ raise
331
+
332
+ @staticmethod
333
+ @log_call
334
+ @standardize_input(file_type='plan_hdf')
335
+ def get_pipe_network_profile_output(hdf_path: Path) -> pd.DataFrame:
336
+ """
337
+ Extract pipe network profile output data from the HDF file.
338
+
339
+ Args:
340
+ hdf_path (Path): Path to the HDF file.
341
+
342
+ Returns:
343
+ pd.DataFrame: DataFrame containing pipe network profile output data.
344
+
345
+ Raises:
346
+ KeyError: If the required datasets are not found in the HDF file.
347
+ """
348
+ try:
349
+ with h5py.File(hdf_path, 'r') as hdf:
350
+ # Extract profile output data
351
+ profile_path = "/Results/Unsteady/Output/Output Blocks/DSS Profile Output/Unsteady Time Series/Pipe Networks"
352
+ if profile_path not in hdf:
353
+ logger.warning("Pipe Network profile output data not found in HDF file")
354
+ return pd.DataFrame()
355
+
356
+ # Initialize an empty list to store data from all pipe networks
357
+ all_data = []
358
+
359
+ # Iterate through all pipe networks
360
+ for network in hdf[profile_path].keys():
361
+ network_path = f"{profile_path}/{network}"
362
+
363
+ # Extract data for each variable
364
+ for var in hdf[network_path].keys():
365
+ data = hdf[f"{network_path}/{var}"][()]
366
+
367
+ # Create a DataFrame for this variable
368
+ df = pd.DataFrame(data)
369
+ df['Network'] = network
370
+ df['Variable'] = var
371
+
372
+ all_data.append(df)
373
+
374
+ # Concatenate all DataFrames
375
+ result_df = pd.concat(all_data, ignore_index=True)
376
+
377
+ # Add time information
378
+ time = HdfBase._get_unsteady_datetimes(hdf)
379
+ result_df['Time'] = [time[i] for i in result_df.index]
380
+
381
+ return result_df
382
+
383
+ except KeyError as e:
384
+ logger.error(f"Required dataset not found in HDF file: {e}")
385
+ raise
386
+ except Exception as e:
387
+ logger.error(f"Error extracting pipe network profile output data: {e}")
388
+ raise
389
+
390
+ @staticmethod
391
+ @log_call
392
+ @standardize_input(file_type='plan_hdf')
393
+ def get_pump_station_profile_output(hdf_path: Path) -> pd.DataFrame:
394
+ """
395
+ Extract pump station profile output data from the HDF file.
396
+
397
+ Args:
398
+ hdf_path (Path): Path to the HDF file.
399
+
400
+ Returns:
401
+ pd.DataFrame: DataFrame containing pump station profile output data.
402
+
403
+ Raises:
404
+ KeyError: If the required datasets are not found in the HDF file.
405
+ """
406
+ try:
407
+ with h5py.File(hdf_path, 'r') as hdf:
408
+ # Extract profile output data
409
+ profile_path = "/Results/Unsteady/Output/Output Blocks/DSS Profile Output/Unsteady Time Series/Pumping Stations"
410
+ if profile_path not in hdf:
411
+ logger.warning("Pump Station profile output data not found in HDF file")
412
+ return pd.DataFrame()
413
+
414
+ # Initialize an empty list to store data from all pump stations
415
+ all_data = []
416
+
417
+ # Iterate through all pump stations
418
+ for station in hdf[profile_path].keys():
419
+ station_path = f"{profile_path}/{station}/Structure Variables"
420
+
421
+ data = hdf[station_path][()]
422
+
423
+ # Create a DataFrame for this pump station
424
+ df = pd.DataFrame(data, columns=['Flow', 'Stage HW', 'Stage TW', 'Pump Station', 'Pumps on'])
425
+ df['Station'] = station
426
+
427
+ all_data.append(df)
428
+
429
+ # Concatenate all DataFrames
430
+ result_df = pd.concat(all_data, ignore_index=True)
431
+
432
+ # Add time information
433
+ time = HdfBase._get_unsteady_datetimes(hdf)
434
+ result_df['Time'] = [time[i] for i in result_df.index]
435
+
436
+ return result_df
437
+
438
+ except KeyError as e:
439
+ logger.error(f"Required dataset not found in HDF file: {e}")
440
+ raise
441
+ except Exception as e:
442
+ logger.error(f"Error extracting pump station profile output data: {e}")
443
+ raise
ras_commander/HdfStruc.py CHANGED
@@ -1,3 +1,12 @@
1
+ """
2
+ Class: HdfStruc
3
+
4
+ Attribution: A substantial amount of code in this file is sourced or derived
5
+ from the https://github.com/fema-ffrd/rashdf library,
6
+ released under MIT license and Copyright (c) 2024 fema-ffrd
7
+
8
+ The file has been forked and modified for use in RAS Commander.
9
+ """
1
10
  from typing import Dict, Any, List, Union
2
11
  from pathlib import Path
3
12
  import h5py
ras_commander/HdfUtils.py CHANGED
@@ -1,3 +1,12 @@
1
+ """
2
+ Class: HdfUtils
3
+
4
+ Attribution: A substantial amount of code in this file is sourced or derived
5
+ from the https://github.com/fema-ffrd/rashdf library,
6
+ released under MIT license and Copyright (c) 2024 fema-ffrd
7
+
8
+ The file has been forked and modified for use in RAS Commander.
9
+ """
1
10
  import logging
2
11
  from pathlib import Path
3
12
  import h5py
@@ -338,30 +347,27 @@ class HdfUtils:
338
347
  return parsed_dt
339
348
 
340
349
  @staticmethod
341
- def _ras_timesteps_to_datetimes(timesteps: np.ndarray, start_time: datetime, time_unit: str, round_to: str = "0.1 s") -> List[datetime]:
350
+ def _ras_timesteps_to_datetimes(timesteps: np.ndarray, start_time: datetime, time_unit: str = "days", round_to: str = "100ms") -> pd.DatetimeIndex:
342
351
  """
343
- Convert an array of RAS timesteps into a list of datetime objects.
352
+ Convert RAS timesteps to datetime objects.
344
353
 
345
354
  Args:
346
- timesteps (np.ndarray): An array of RAS timesteps.
347
- start_time (datetime): The start time of the simulation.
348
- time_unit (str): The time unit of the timesteps.
349
- round_to (str): The time unit to round the datetimes to. Default is "0.1 s".
355
+ timesteps (np.ndarray): Array of timesteps.
356
+ start_time (datetime): Start time of the simulation.
357
+ time_unit (str): Unit of the timesteps. Default is "days".
358
+ round_to (str): Frequency string to round the times to. Default is "100ms" (100 milliseconds).
350
359
 
351
360
  Returns:
352
- List[datetime]: A list of datetime objects corresponding to the timesteps.
353
-
354
- Note:
355
- The `round_to` parameter uses Pandas time string notation. For example:
356
- - "0.1 s" means round to the nearest 0.1 seconds
357
- - "1 s" means round to the nearest second
358
- - "1 min" means round to the nearest minute
359
- For more options, see Pandas documentation on time string notation.
360
- """
361
- return [
362
- start_time + pd.Timedelta(timestep, unit=time_unit).round(round_to)
363
- for timestep in timesteps.astype(np.float64)
364
- ]
361
+ pd.DatetimeIndex: DatetimeIndex of converted and rounded datetimes.
362
+ """
363
+ if time_unit == "days":
364
+ datetimes = start_time + pd.to_timedelta(timesteps, unit='D')
365
+ elif time_unit == "hours":
366
+ datetimes = start_time + pd.to_timedelta(timesteps, unit='H')
367
+ else:
368
+ raise ValueError(f"Unsupported time unit: {time_unit}")
369
+
370
+ return pd.DatetimeIndex(datetimes).round(round_to)
365
371
 
366
372
  @staticmethod
367
373
  def _hdf5_attrs_to_dict(attrs: Union[h5py.AttributeManager, Dict], prefix: Optional[str] = None) -> Dict:
ras_commander/HdfXsec.py CHANGED
@@ -1,3 +1,13 @@
1
+ """
2
+ Class: HdfXsec
3
+
4
+ Attribution: A substantial amount of code in this file is sourced or derived
5
+ from the https://github.com/fema-ffrd/rashdf library,
6
+ released under MIT license and Copyright (c) 2024 fema-ffrd
7
+
8
+ The file has been forked and modified for use in RAS Commander.
9
+ """
10
+
1
11
  from pathlib import Path
2
12
  import h5py
3
13
  import numpy as np
ras_commander/__init__.py CHANGED
@@ -32,6 +32,8 @@ from .HdfResultsXsec import HdfResultsXsec
32
32
  from .HdfStruc import HdfStruc
33
33
  from .HdfUtils import HdfUtils
34
34
  from .HdfXsec import HdfXsec
35
+ from .HdfPump import HdfPump
36
+ from .HdfPipe import HdfPipe
35
37
 
36
38
  # Define __all__ to specify what should be imported when using "from ras_commander import *"
37
39
  __all__ = [
@@ -45,6 +47,8 @@ __all__ = [
45
47
  "HdfStruc",
46
48
  "HdfUtils",
47
49
  "HdfXsec",
50
+ "HdfPump",
51
+ "HdfPipe",
48
52
  "standardize_input",
49
53
  "ras",
50
54
  "init_ras_project",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ras-commander
3
- Version: 0.43.0
3
+ Version: 0.45.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
@@ -62,7 +62,7 @@ Create a virtual environment with conda or venv (ask ChatGPT if you need help)
62
62
  In your virtual environment, install ras-commander using pip:
63
63
  ```
64
64
  pip install h5py numpy pandas requests tqdm scipy
65
- pip install ras-commander
65
+ pip install --upgrade ras-commander
66
66
  ```
67
67
 
68
68
  If you have dependency issues with pip (especially if you have errors with numpy), try clearing your local pip packages 'C:\Users\your_username\AppData\Roaming\Python\' and then creating a new virtual environment.
@@ -299,6 +299,13 @@ These acknowledgments recognize the contributions and inspirations that have hel
299
299
  4. [HEC-Commander Tools](https://github.com/billk-FM/HEC-Commander) - Inspiration and initial code base for the development of RAS Commander.
300
300
 
301
301
 
302
+ ## Official RAS Commander AI-Generated Songs:
303
+
304
+ [No More Wait and See (Bluegrass)](https://suno.com/song/16889f3e-50f1-4afe-b779-a41738d7617a)
305
+
306
+ [No More Wait and See (Cajun Zydeco)](https://suno.com/song/4441c45d-f6cd-47b9-8fbc-1f7b277ee8ed)
307
+
308
+
302
309
  ## Contact
303
310
 
304
311
  For questions, suggestions, or support, please contact:
@@ -0,0 +1,28 @@
1
+ ras_commander/Decorators.py,sha256=i5AEQbe7JeI8Y3O_dQ5OO4Ab0KO5SiZTiysFBGxqTRU,4978
2
+ ras_commander/HdfBase.py,sha256=HV5ccV9QH2lz4ZRYqK2d7_S833cTSUcostzxxSPb4O4,7129
3
+ ras_commander/HdfBndry.py,sha256=LWaDMHeo0V_VOpx7D9q7W_0WvWsD6NQThiSLYPY8ApE,20761
4
+ ras_commander/HdfMesh.py,sha256=JKWn6S-FcdFs3fZQMQ8mkIEIFFxUdVjWb5r7jAh3ujw,12668
5
+ ras_commander/HdfPipe.py,sha256=agGhMNeANi92eS62CEoaPDimS0I0yGoAoMv1c8YAIk4,9432
6
+ ras_commander/HdfPlan.py,sha256=nt1Q03cPNX_yVX0mOUqeWGPicqtusUnuBSTcBw8n0Vg,6967
7
+ ras_commander/HdfPump.py,sha256=8mBfFg0epaq74txDyUfBPkWqzvRQCb8OojEgDGCridM,9416
8
+ ras_commander/HdfResultsMesh.py,sha256=Ke6HSpdKBd-TUa0QIuMaxhyj--lfuQGlMDlDuk2qrd8,28064
9
+ ras_commander/HdfResultsPlan.py,sha256=-4tTMLiSkuOs3pKn7sA_1RoGmBxaG8jMUJ9qvVlc2Q0,17299
10
+ ras_commander/HdfResultsXsec.py,sha256=4BHIX-VTfkh1YwIUJDZpnnz_-wGctOJO2XVCTsiUXDs,16393
11
+ ras_commander/HdfStruc.py,sha256=NNTSwUQmLMLn8SPyrLIKXaUaqKavTos_TDDB6Mja7-4,5595
12
+ ras_commander/HdfUtils.py,sha256=dUU9QkNO-FhaCjD_TEOv_FNNrZI3TUOQ6QjSiXrJGSc,18403
13
+ ras_commander/HdfXsec.py,sha256=ccJ-GAVKwS2Z-k6CCWAYvw974xCBTTF-5Hh1CnikVG4,11562
14
+ ras_commander/LoggingConfig.py,sha256=5bYd_5KMlf81bXsiu2mABBlw0USMhcu5uRv8DIYJSFE,2317
15
+ ras_commander/RasCmdr.py,sha256=qZtdvwQnZxOjhU3pZWRCJ80aH5QWOJD_F7P_05geSHA,25020
16
+ ras_commander/RasExamples.py,sha256=FDit6FWzTQbv42Xx0gtSJB17HDeol_eykxV0qVpnwIk,16688
17
+ ras_commander/RasGeo.py,sha256=x7eFvUQ_dPZxAVq2Gw_GIRzn-Cf7DLKZDTwk1fjrkf8,5395
18
+ ras_commander/RasGpt.py,sha256=1Nitlf5QyeBQo8Q8I8pJKaTtQ0GdsBQA71LIKUAOycA,839
19
+ ras_commander/RasPlan.py,sha256=_0EjxQnamd9FhzzKlYNqJ3chv2bvxfk0DXEwfHntXFo,40287
20
+ ras_commander/RasPrj.py,sha256=ePLcPNcKVMgijvJKkJIWwQslQi2D6zq2UTW-8XCFmto,36159
21
+ ras_commander/RasUnsteady.py,sha256=oBVC9QFQMrSx8LY2Cb1CjUyCQEUoIEnEuVJsATYiVYs,4649
22
+ ras_commander/RasUtils.py,sha256=NBMxTHWHoTH2MJzqJ0y1_00fgKSS1GnNuEikwZ3Pqzs,34153
23
+ ras_commander/__init__.py,sha256=8sg6T5I_uAqGe2pInrMnBrhS8NZbfnF7Pp7uwzQOqIo,1722
24
+ ras_commander-0.45.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
25
+ ras_commander-0.45.0.dist-info/METADATA,sha256=Y7H1Fq4aG4C2ujRl6VkjxBLOaNZUzX1X7gNd5UJDU7s,15935
26
+ ras_commander-0.45.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
27
+ ras_commander-0.45.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
28
+ ras_commander-0.45.0.dist-info/RECORD,,
@@ -1,26 +0,0 @@
1
- ras_commander/Decorators.py,sha256=i5AEQbe7JeI8Y3O_dQ5OO4Ab0KO5SiZTiysFBGxqTRU,4978
2
- ras_commander/HdfBase.py,sha256=xAaQdHa80EAjhjjp2UMLIFzWf7xVncunj0bxbPJciFg,6863
3
- ras_commander/HdfBndry.py,sha256=dXyM9yVEyNcvCJFsCr5R6XY1V8LnDUQTbScnkeqSuuI,20469
4
- ras_commander/HdfMesh.py,sha256=EETuwOqDnmus1tbATmfANq5MLoN6GTw6K9IAm5vGqx0,12386
5
- ras_commander/HdfPlan.py,sha256=gj34nSlzXOxa5EPYNYoL9ocWa83lzUuMOMl7kvKzaIk,6674
6
- ras_commander/HdfResultsMesh.py,sha256=vFR3DpyS55W_QhgCypYKq6bRFwjIBc8D4ql9ZISn9RY,28295
7
- ras_commander/HdfResultsPlan.py,sha256=htRCxZh26_fwgZtJt5USifcapUg0WRChsZRWzgC4bMU,17141
8
- ras_commander/HdfResultsXsec.py,sha256=nxj0WUA149EoB_WjlIqlGyb3QJt4LMc32X7unsJM62A,8126
9
- ras_commander/HdfStruc.py,sha256=P9rEfmvqlD1CgJ7OFzBm4ST3K-5IrxmrON6PwT68yMg,5303
10
- ras_commander/HdfUtils.py,sha256=94ojuG7FV_IT9KjYIBS_zL8LqdmVi1s0eppXnY-_338,18274
11
- ras_commander/HdfXsec.py,sha256=moPbWcGhoIK5xEKoFvebTOKNlcwXAmQtQVZW9DTlhzQ,11269
12
- ras_commander/LoggingConfig.py,sha256=5bYd_5KMlf81bXsiu2mABBlw0USMhcu5uRv8DIYJSFE,2317
13
- ras_commander/RasCmdr.py,sha256=qZtdvwQnZxOjhU3pZWRCJ80aH5QWOJD_F7P_05geSHA,25020
14
- ras_commander/RasExamples.py,sha256=FDit6FWzTQbv42Xx0gtSJB17HDeol_eykxV0qVpnwIk,16688
15
- ras_commander/RasGeo.py,sha256=x7eFvUQ_dPZxAVq2Gw_GIRzn-Cf7DLKZDTwk1fjrkf8,5395
16
- ras_commander/RasGpt.py,sha256=1Nitlf5QyeBQo8Q8I8pJKaTtQ0GdsBQA71LIKUAOycA,839
17
- ras_commander/RasPlan.py,sha256=_0EjxQnamd9FhzzKlYNqJ3chv2bvxfk0DXEwfHntXFo,40287
18
- ras_commander/RasPrj.py,sha256=ePLcPNcKVMgijvJKkJIWwQslQi2D6zq2UTW-8XCFmto,36159
19
- ras_commander/RasUnsteady.py,sha256=oBVC9QFQMrSx8LY2Cb1CjUyCQEUoIEnEuVJsATYiVYs,4649
20
- ras_commander/RasUtils.py,sha256=NBMxTHWHoTH2MJzqJ0y1_00fgKSS1GnNuEikwZ3Pqzs,34153
21
- ras_commander/__init__.py,sha256=3MuobRXVEQNvoGwf9AlbvuJg8meni3eWw_JZMFOuMt4,1630
22
- ras_commander-0.43.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
23
- ras_commander-0.43.0.dist-info/METADATA,sha256=yMVLfZpTzUgJVVR-njq5izBxTcgwBHVVr6238PHvG2M,15671
24
- ras_commander-0.43.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
25
- ras_commander-0.43.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
26
- ras_commander-0.43.0.dist-info/RECORD,,