ras-commander 0.34.0__py3-none-any.whl → 0.36.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.
@@ -0,0 +1,80 @@
1
+ # logging_config.py
2
+
3
+ import logging
4
+ import logging.handlers
5
+ from pathlib import Path
6
+ import functools
7
+
8
+ # Define log levels
9
+ DEBUG = logging.DEBUG
10
+ INFO = logging.INFO
11
+ WARNING = logging.WARNING
12
+ ERROR = logging.ERROR
13
+ CRITICAL = logging.CRITICAL
14
+
15
+
16
+ _logging_setup_done = False
17
+
18
+ def setup_logging(log_file=None, log_level=logging.INFO):
19
+ """Set up logging configuration for the ras-commander library."""
20
+ global _logging_setup_done
21
+ if _logging_setup_done:
22
+ return
23
+
24
+ # Define log format
25
+ log_format = logging.Formatter(
26
+ '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
27
+ )
28
+
29
+ # Configure console handler
30
+ console_handler = logging.StreamHandler()
31
+ console_handler.setFormatter(log_format)
32
+
33
+ # Set up root logger
34
+ root_logger = logging.getLogger()
35
+ root_logger.setLevel(log_level)
36
+ root_logger.addHandler(console_handler)
37
+
38
+ # Configure file handler if log_file is provided
39
+ if log_file:
40
+ log_dir = Path('logs')
41
+ log_dir.mkdir(exist_ok=True)
42
+ log_file_path = log_dir / log_file
43
+
44
+ file_handler = logging.handlers.RotatingFileHandler(
45
+ log_file_path, maxBytes=10*1024*1024, backupCount=5
46
+ )
47
+ file_handler.setFormatter(log_format)
48
+ root_logger.addHandler(file_handler)
49
+
50
+ _logging_setup_done = True
51
+
52
+ def get_logger(name):
53
+ """Get a logger for a specific module."""
54
+ return logging.getLogger(name)
55
+
56
+ def log_call(logger=None):
57
+ """Decorator to log function calls."""
58
+ def get_logger():
59
+ # Check if logger is None or doesn't have a debug method
60
+ if logger is None or not hasattr(logger, 'debug'):
61
+ return logging.getLogger(__name__)
62
+ return logger
63
+
64
+ def decorator(func):
65
+ @functools.wraps(func)
66
+ def wrapper(*args, **kwargs):
67
+ log = get_logger()
68
+ log.debug(f"Calling {func.__name__}")
69
+ result = func(*args, **kwargs)
70
+ log.debug(f"Finished {func.__name__}")
71
+ return result
72
+ return wrapper
73
+
74
+ # Check if we're being called as @log_call or @log_call()
75
+ if callable(logger):
76
+ return decorator(logger)
77
+ return decorator
78
+
79
+ # Set up logging when this module is imported
80
+ setup_logging()
@@ -1,23 +1,25 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ras-commander
3
- Version: 0.34.0
3
+ Version: 0.36.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
7
7
  Author-email: billk@fenstermaker.com
8
- Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
9
10
  Classifier: License :: OSI Approved :: MIT License
10
11
  Classifier: Operating System :: OS Independent
11
12
  Requires-Python: >=3.9
12
13
  Description-Content-Type: text/markdown
13
14
  License-File: LICENSE
14
- Requires-Dist: pandas>=1.0.0
15
- Requires-Dist: numpy>=1.18.0
15
+ Requires-Dist: pandas>=2.0
16
+ Requires-Dist: numpy>=2.0
16
17
  Requires-Dist: h5py>=3.1.0
17
18
  Requires-Dist: requests>=2.25.0
18
- Requires-Dist: pathlib>=1.0.1
19
19
  Requires-Dist: scipy>=1.5.0
20
20
  Requires-Dist: matplotlib>=3.3.0
21
+ Requires-Dist: tqdm>=4.50.0
22
+ Requires-Dist: psutil>=5.7.0
21
23
  Provides-Extra: dev
22
24
  Requires-Dist: pytest>=6.2.0; extra == "dev"
23
25
  Requires-Dist: flake8>=3.9.0; extra == "dev"
@@ -31,14 +33,21 @@ Requires-Dist: twine>=3.3.0; extra == "dev"
31
33
  RAS Commander is a Python library for automating HEC-RAS operations, providing a set of tools to interact with HEC-RAS project files, execute simulations, and manage project data. This library is an evolution of the RASCommander 1.0 Python Notebook Application previously released under the [HEC-Commander tools repository](https://github.com/billk-FM/HEC-Commander).
32
34
 
33
35
  ## Contributors:
34
- William Katzenmeyer, P.E., C.F.M. - billk@fenstermaker.com
36
+ William Katzenmeyer, P.E., C.F.M.
35
37
 
36
- Sean Micek, P.E., C.F.M. - smicek@fenstermaker.com
38
+ Sean Micek, P.E., C.F.M.
37
39
 
38
- Aaron Nichols, P.E., C.F.M. - anichols@fenstermaker.com
40
+ Aaron Nichols, P.E., C.F.M.
39
41
 
40
42
  (Additional Contributors Here)
41
43
 
44
+ ## Don't Ask Me, Ask ChatGPT!
45
+
46
+ Before you read any further, you can [chat directly with ChatGPT on this topic.](https://chatgpt.com/g/g-TZRPR3oAO-ras-commander-library-assistant) Ask it anything, and it will use its tools to answer your questions and help you learn. You can even upload your own plan, unsteady and HDF files to inspect and help determine how to automate your workflows or visualize your results.
47
+
48
+ There are also [AI Assistant Knowledge Bases](https://github.com/billk-FM/ras-commander/tree/main/ai_tools/assistant_knowledge_bases) with various versions available to directly use with large context LLM models such as Anthropic's Claude, Google Gemini and OpenAI's GPT4o and o1 models.
49
+
50
+ FUTURE: TEMPLATES are available to use with AI Assistant Notebooks to build your own automation tools. When used with large context models, these templates allow you to ask GPT to build a workflow from scratch to automate your projects.
42
51
 
43
52
  ## Background
44
53
  The ras-commander library emerged from the initial test-bed of AI-driven coding represented by the HEC-Commander tools Python notebooks. These notebooks served as a proof of concept, demonstrating the value proposition of automating HEC-RAS operations. The transition from notebooks to a structured library aims to provide a more robust, maintainable, and extensible solution for water resources engineers.
@@ -116,18 +125,21 @@ results = RasCmdr.compute_parallel(
116
125
  RasPlan.set_geom("01", "02")
117
126
  ```
118
127
 
128
+ Certainly! I'll provide you with an updated Key Components section and Project Organization diagram based on the current structure of the ras-commander library.
129
+
119
130
  ## Key Components
120
131
 
121
- - `RasPrj`: Manages HEC-RAS projects
132
+ - `RasPrj`: Manages HEC-RAS projects, handling initialization and data loading
122
133
  - `RasCmdr`: Handles execution of HEC-RAS simulations
123
134
  - `RasPlan`: Provides functions for modifying and updating plan files
124
135
  - `RasGeo`: Handles operations related to geometry files
125
136
  - `RasUnsteady`: Manages unsteady flow file operations
126
137
  - `RasUtils`: Contains utility functions for file operations and data management
127
138
  - `RasExamples`: Manages and loads HEC-RAS example projects
128
-
139
+ - `RasHdf`: Provides utilities for working with HDF files in HEC-RAS projects
129
140
 
130
141
  ## Project Organization Diagram
142
+
131
143
  ```
132
144
  ras_commander
133
145
  ├── .github
@@ -135,9 +147,11 @@ ras_commander
135
147
  │ └── python-package.yml
136
148
  ├── ras_commander
137
149
  │ ├── __init__.py
150
+ │ ├── _version.py
138
151
  │ ├── RasCmdr.py
139
152
  │ ├── RasExamples.py
140
153
  │ ├── RasGeo.py
154
+ │ ├── RasHdf.py
141
155
  │ ├── RasPlan.py
142
156
  │ ├── RasPrj.py
143
157
  │ ├── RasUnsteady.py
@@ -155,7 +169,12 @@ ras_commander
155
169
  │ ├── 10_arguments_for_compute.py
156
170
  │ ├── 11_Using_RasExamples.ipynb
157
171
  │ ├── 12_plan_set_execution.py
158
- │ └── 13_multiple_project_operations.py
172
+ │ ├── 13_multiple_project_operations.py
173
+ │ ├── 14_Core_Sensitivity.ipynb
174
+ │ ├── 15_plan_key_operations.py
175
+ │ ├── 16_scanning_ras_project_info.py
176
+ │ ├── 17_parallel_execution_ble.py
177
+ │ └── HEC_RAS_2D_HDF_Analysis.ipynb
159
178
  ├── tests
160
179
  │ └── ... (test files)
161
180
  ├── .gitignore
@@ -190,7 +209,6 @@ projects = ras_examples.list_projects("Steady Flow")
190
209
  extracted_paths = ras_examples.extract_project(["Bald Eagle Creek", "Muncie"])
191
210
  ```
192
211
 
193
-
194
212
  ## RasPrj
195
213
 
196
214
  The `RasPrj` class is central to managing HEC-RAS projects within the ras-commander library. It handles project initialization, data loading, and provides access to project components.
@@ -218,6 +236,28 @@ custom_project = RasPrj()
218
236
  init_ras_project("/path/to/another_project", "6.5", ras_instance=custom_project)
219
237
  ```
220
238
 
239
+ ## RasHdf
240
+
241
+ The `RasHdf` class provides utilities for working with HDF files in HEC-RAS projects, enabling easy access to simulation results and model data.
242
+
243
+ Example usage:
244
+
245
+ ```python
246
+ from ras_commander import RasHdf, init_ras_project, RasPrj
247
+
248
+ # Initialize project with a custom ras object
249
+ custom_ras = RasPrj()
250
+ init_ras_project("/path/to/project", "6.5", ras_instance=custom_ras)
251
+
252
+ # Get runtime data for a specific plan
253
+ plan_number = "01"
254
+ runtime_data = RasHdf.get_runtime_data(plan_number, ras_object=custom_ras)
255
+ print(runtime_data)
256
+ ```
257
+
258
+ This class simplifies the process of extracting and analyzing data from HEC-RAS HDF output files, supporting tasks such as post-processing and result visualization.
259
+
260
+
221
261
  ## Documentation
222
262
 
223
263
  For detailed usage instructions and API documentation, please refer to the [Comprehensive Library Guide](Comprehensive_Library_Guide.md).
@@ -255,7 +295,27 @@ ras-commander is released under the MIT License. See the license file for detail
255
295
 
256
296
  ## Acknowledgments
257
297
 
258
- RAS Commander is based on the HEC-Commander project's "Command Line is All You Need" approach, leveraging the HEC-RAS command-line interface for automation. The initial development of this library was presented in the HEC-Commander Tools repository. In a 2024 Australian Water School webinar, Bill demonstrated the derivation of basic HEC-RAS automation functions from plain language instructions. Leveraging the previously developed code and AI tools, the library was created. The primary tools used for this initial development were Anthropic's Claude, GPT-4o, Google's Gemini Experimental models, and the Cursor AI Coding IDE.
298
+ RAS Commander is based on the HEC-Commander project's "Command Line is All You Need" approach, leveraging the HEC-RAS command-line interface for automation. The initial development of this library was presented in the HEC-Commander Tools repository. In a 2024 Australian Water School webinar, Bill demonstrated the derivation of basic HEC-RAS automation functions from plain language instructions. Leveraging the previously developed code and AI tools, the library was created. The primary tools used for this initial development were Anthropic's Claude, GPT-4, Google's Gemini Experimental models, and the Cursor AI Coding IDE.
299
+
300
+ Additionally, we would like to acknowledge the following notable contributions and attributions for open source projects which significantly influenced the development of RAS Commander:
301
+
302
+ 1. Contributions: Sean Micek's [`funkshuns`](https://github.com/openSourcerer9000/funkshuns), [`TXTure`](https://github.com/openSourcerer9000/TXTure), and [`RASmatazz`](https://github.com/openSourcerer9000/RASmatazz) libraries provided inspiration, code examples and utility functions which were adapted with AI for use in RAS Commander. Sean has also contributed heavily to
303
+
304
+ - Development of additional HDF functions for detailed analysis and mapping of HEC-RAS results within the RasHdf class.
305
+ - Development of the prototype `RasCmdr` class for executing HEC-RAS simulations.
306
+ - Optimization examples and methods from (INSERT REFERENCE) for use in the Ras-Commander library examples
307
+
308
+ 2. Attribution: The [`pyHMT2D`](https://github.com/psu-efd/pyHMT2D/) project by Xiaofeng Liu, which provided insights into HDF file handling methods for HEC-RAS outputs. Many of the functions in the [Ras_2D_Data.py](https://github.com/psu-efd/pyHMT2D/blob/main/pyHMT2D/Hydraulic_Models_Data/RAS_2D/RAS_2D_Data.py) file were adapted with AI for use in RAS Commander.
309
+
310
+ Xiaofeng Liu, Ph.D., P.E., Associate Professor, Department of Civil and Environmental Engineering
311
+ Institute of Computational and Data Sciences, Penn State University
312
+
313
+ These acknowledgments recognize the contributions and inspirations that have helped shape RAS Commander, ensuring proper attribution for the ideas and code that have influenced its development.
314
+
315
+ 3. Chris Goodell, "Breaking the HEC-RAS Code" - Studied and used as a reference for understanding the inner workings of HEC-RAS, providing valuable insights into the software's functionality and structure.
316
+
317
+ 4. [HEC-Commander Tools](https://github.com/billk-FM/HEC-Commander) - Inspiration and initial code base for the development of RAS Commander.
318
+
259
319
 
260
320
  ## Contact
261
321
 
@@ -0,0 +1,17 @@
1
+ ras_commander/RasCmdr.py,sha256=_opzPdFuja2wXmFu2iayP6igJqGeILAavPC1XsCC6ks,25010
2
+ ras_commander/RasExamples.py,sha256=g2HIbppxIVeCKriy9Th1RDtrCPzFkdoP-BWEzHPsedY,25112
3
+ ras_commander/RasGeo.py,sha256=cqKpN-1r_uXw24acqA8ubGGw2-Od51p-I_X0kGSkWBE,5395
4
+ ras_commander/RasGpt.py,sha256=-524sU_PBPxCmjDKJbDXg6Q3k1-Uhk2tYj6HeW8QFJ8,4201
5
+ ras_commander/RasHdf.py,sha256=_aJ2PAqFPAnTWN2btmASjWT8dHAFZveAorAu6QXLwgA,77162
6
+ ras_commander/RasPlan.py,sha256=p9IVQ5vKzv01jcrY0-Lbx8N7YwkPf4WKovBNx_FgXpE,48835
7
+ ras_commander/RasPrj.py,sha256=qDJJiWnAaf-Uzc31DVI5aTKjOulIEoVeH05-kjb4tZQ,34444
8
+ ras_commander/RasUnsteady.py,sha256=37GKaYNJZ39y-khhy01LbHwZnf7HT0V2XKQ-UUaJHlY,4639
9
+ ras_commander/RasUtils.py,sha256=P9SopqMd6awZyj0U2xNxc-pl1-HEktmyY1lz3LiduPs,25079
10
+ ras_commander/__init__.py,sha256=h4xld8gpvjTTpOOJcPKXwsRMUVGtg8tRqf64AHwZB3k,1051
11
+ ras_commander/_version.py,sha256=BReLomJ164W3bJhfQJi0gbNKc3DXCzwusmCheUzClB8,478
12
+ ras_commander/logging_config.py,sha256=5bYd_5KMlf81bXsiu2mABBlw0USMhcu5uRv8DIYJSFE,2317
13
+ ras_commander-0.36.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
14
+ ras_commander-0.36.0.dist-info/METADATA,sha256=izerc1IGczuZ6ESEZV2fU5HtEXJA7w5jBMY_u9qFEAE,16187
15
+ ras_commander-0.36.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
16
+ ras_commander-0.36.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
17
+ ras_commander-0.36.0.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- ras_commander/RasCmdr.py,sha256=vaB1_33nJMISwCbayYawaVZKjrXy_Jne8KEnfvKxot8,24285
2
- ras_commander/RasExamples.py,sha256=7A3dt3DnWSdFsZYn9Jqvr93bWNoFSwJYLMiy21hzvgo,16412
3
- ras_commander/RasGeo.py,sha256=6DO5utVBjkIhqJ_WYQSeU4i74Bv_pZO3pmWdVf-jj3U,5137
4
- ras_commander/RasHdf.py,sha256=rxe9tlQdeh_wOIUa1lplxbj8JM8HCWZigEHSkySNri4,11222
5
- ras_commander/RasPlan.py,sha256=5M1ra2oOxGUa2YTRhuKInKq64sXSuVc8bZjvd9N3rOo,53314
6
- ras_commander/RasPrj.py,sha256=Clso7BccVDd51zCrN3eoAzJ8EXfK6Aai88_spGymOuM,30330
7
- ras_commander/RasUnsteady.py,sha256=jgV3gqGFsIMV0c9eFaXjVM5pqAb82Du_7ObiIPnemJs,4077
8
- ras_commander/RasUtils.py,sha256=ESsjQNjPsojZ8SINnMbMZDDWeyBqF6owaPV8brtS3S8,24435
9
- ras_commander/__init__.py,sha256=7H3JDR5VmTo6P0fJFJe9mTozMWp-owrrHjy7lADVA6Q,1167
10
- ras_commander/_version.py,sha256=BReLomJ164W3bJhfQJi0gbNKc3DXCzwusmCheUzClB8,478
11
- ras_commander-0.34.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
12
- ras_commander-0.34.0.dist-info/METADATA,sha256=qAoJZW8ITX0vGKiqdanV3UUOGph_MeH_SbDOMSFoeaI,11826
13
- ras_commander-0.34.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
14
- ras_commander-0.34.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
15
- ras_commander-0.34.0.dist-info/RECORD,,