ras-commander 0.61.0__py3-none-any.whl → 0.65.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 +91 -7
- ras_commander/HdfInfiltration.py +7 -1
- ras_commander/HdfPlan.py +44 -5
- ras_commander/HdfResultsMesh.py +24 -14
- ras_commander/HdfResultsPlan.py +380 -364
- ras_commander/HdfStruc.py +30 -8
- ras_commander/RasMapper.py +1 -82
- ras_commander/RasPlan.py +262 -52
- ras_commander/RasPrj.py +186 -41
- ras_commander/__init__.py +3 -7
- {ras_commander-0.61.0.dist-info → ras_commander-0.65.0.dist-info}/METADATA +48 -47
- {ras_commander-0.61.0.dist-info → ras_commander-0.65.0.dist-info}/RECORD +15 -15
- {ras_commander-0.61.0.dist-info → ras_commander-0.65.0.dist-info}/LICENSE +0 -0
- {ras_commander-0.61.0.dist-info → ras_commander-0.65.0.dist-info}/WHEEL +0 -0
- {ras_commander-0.61.0.dist-info → ras_commander-0.65.0.dist-info}/top_level.txt +0 -0
ras_commander/RasPrj.py
CHANGED
@@ -161,47 +161,100 @@ class RasPrj:
|
|
161
161
|
|
162
162
|
This method initializes DataFrames for plan, flow, unsteady, and geometry entries
|
163
163
|
by calling the _get_prj_entries method for each entry type.
|
164
|
+
Also extracts unsteady_number and geometry_number from plan files and adds them to plan_df.
|
165
|
+
Now includes Geom Path, Flow Path, and other required columns.
|
164
166
|
"""
|
165
|
-
#
|
167
|
+
# Load unsteady first to ensure consistent handling of unsteady numbers
|
168
|
+
self.unsteady_df = self._get_prj_entries('Unsteady')
|
166
169
|
self.plan_df = self._get_prj_entries('Plan')
|
167
170
|
self.flow_df = self._get_prj_entries('Flow')
|
168
|
-
self.
|
169
|
-
self.geom_df = self.get_geom_entries() # Use get_geom_entries instead of _get_prj_entries
|
171
|
+
self.geom_df = self.get_geom_entries()
|
170
172
|
|
171
|
-
#
|
172
|
-
|
173
|
+
# Set geometry and flow paths
|
174
|
+
for idx, row in self.plan_df.iterrows():
|
175
|
+
try:
|
176
|
+
# Add Geom Path
|
177
|
+
if row['Geom File'] is not None:
|
178
|
+
geom_hdf_path = self.project_folder / f"{self.project_name}.g{row['Geom File']}"
|
179
|
+
self.plan_df.at[idx, 'Geom Path'] = str(geom_hdf_path)
|
180
|
+
|
181
|
+
# Add Flow Path
|
182
|
+
if row['Flow File'] is not None:
|
183
|
+
# Determine if this is a steady or unsteady flow file
|
184
|
+
if row['unsteady_number'] is not None:
|
185
|
+
flow_path = self.project_folder / f"{self.project_name}.u{row['Flow File']}"
|
186
|
+
else:
|
187
|
+
flow_path = self.project_folder / f"{self.project_name}.f{row['Flow File']}"
|
188
|
+
self.plan_df.at[idx, 'Flow Path'] = str(flow_path)
|
189
|
+
|
190
|
+
if not self.suppress_logging:
|
191
|
+
logger.info(f"Plan {row['plan_number']} paths set up")
|
192
|
+
except Exception as e:
|
193
|
+
logger.error(f"Error processing plan file {row['plan_number']}: {e}")
|
173
194
|
|
174
|
-
|
175
|
-
def _get_geom_file_for_plan(self, plan_number):
|
195
|
+
def _get_geom_file_from_plan(self, plan_file_path):
|
176
196
|
"""
|
177
|
-
|
197
|
+
Extract the geometry number from a plan file by finding the Geom File value
|
198
|
+
and stripping the leading 'g'.
|
178
199
|
|
179
|
-
|
180
|
-
|
200
|
+
Parameters:
|
201
|
+
-----------
|
202
|
+
plan_file_path : str or Path
|
203
|
+
Path to the plan file.
|
181
204
|
|
182
205
|
Returns:
|
183
|
-
|
206
|
+
--------
|
207
|
+
tuple: (str, str)
|
208
|
+
A tuple containing (geometry_number, full_hdf_path) or (None, None) if not found.
|
209
|
+
geometry_number is the number after 'g' in the Geom File value
|
210
|
+
full_hdf_path is the path to the geometry HDF file
|
211
|
+
"""
|
212
|
+
content, encoding = read_file_with_fallback_encoding(plan_file_path)
|
213
|
+
|
214
|
+
if content is None:
|
215
|
+
return None, None
|
216
|
+
|
217
|
+
try:
|
218
|
+
match = re.search(r'Geom File=g(\d+)', content)
|
219
|
+
if match:
|
220
|
+
geom_number = match.group(1) # This gets just the number after 'g'
|
221
|
+
geom_file = f"g{geom_number}"
|
222
|
+
geom_hdf_path = self.project_folder / f"{self.project_name}.{geom_file}.hdf"
|
223
|
+
if geom_hdf_path.exists():
|
224
|
+
return geom_number, str(geom_hdf_path)
|
225
|
+
except Exception as e:
|
226
|
+
logger.error(f"Error extracting geometry number from {plan_file_path}: {e}")
|
227
|
+
|
228
|
+
return None, None
|
229
|
+
|
230
|
+
def _get_flow_file_from_plan(self, plan_file_path):
|
231
|
+
"""
|
232
|
+
Extract the Flow File value from a plan file.
|
233
|
+
|
234
|
+
Parameters:
|
235
|
+
-----------
|
236
|
+
plan_file_path : str or Path
|
237
|
+
Path to the plan file.
|
238
|
+
|
239
|
+
Returns:
|
240
|
+
--------
|
241
|
+
str or None
|
242
|
+
The Flow File value or None if not found.
|
184
243
|
"""
|
185
|
-
plan_file_path = self.project_folder / f"{self.project_name}.p{plan_number}"
|
186
244
|
content, encoding = read_file_with_fallback_encoding(plan_file_path)
|
187
245
|
|
188
246
|
if content is None:
|
189
247
|
return None
|
190
248
|
|
191
249
|
try:
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
geom_hdf_path = self.project_folder / f"{self.project_name}.{geom_file}.hdf"
|
196
|
-
if geom_hdf_path.exists():
|
197
|
-
return str(geom_hdf_path)
|
198
|
-
else:
|
199
|
-
return None
|
250
|
+
match = re.search(r'Flow File=([^\s]+)', content)
|
251
|
+
if match:
|
252
|
+
return match.group(1)
|
200
253
|
except Exception as e:
|
201
|
-
logger.error(f"Error
|
254
|
+
logger.error(f"Error extracting Flow File from {plan_file_path}: {e}")
|
255
|
+
|
202
256
|
return None
|
203
257
|
|
204
|
-
|
205
258
|
@staticmethod
|
206
259
|
@log_call
|
207
260
|
def get_plan_value(
|
@@ -376,19 +429,16 @@ class RasPrj:
|
|
376
429
|
|
377
430
|
return plan_info
|
378
431
|
|
432
|
+
@log_call
|
379
433
|
def _get_prj_entries(self, entry_type):
|
380
434
|
"""
|
381
435
|
Extract entries of a specific type from the HEC-RAS project file.
|
382
|
-
|
436
|
+
|
383
437
|
Args:
|
384
438
|
entry_type (str): The type of entry to extract (e.g., 'Plan', 'Flow', 'Unsteady', 'Geom').
|
385
|
-
|
439
|
+
|
386
440
|
Returns:
|
387
441
|
pd.DataFrame: A DataFrame containing the extracted entries.
|
388
|
-
|
389
|
-
Note:
|
390
|
-
This method reads the project file and extracts entries matching the specified type.
|
391
|
-
For 'Unsteady' entries, it parses additional information from the unsteady file.
|
392
442
|
"""
|
393
443
|
entries = []
|
394
444
|
pattern = re.compile(rf"{entry_type} File=(\w+)")
|
@@ -400,28 +450,101 @@ class RasPrj:
|
|
400
450
|
if match:
|
401
451
|
file_name = match.group(1)
|
402
452
|
full_path = str(self.project_folder / f"{self.project_name}.{file_name}")
|
453
|
+
entry_number = file_name[1:] # Extract number portion without prefix
|
454
|
+
|
403
455
|
entry = {
|
404
|
-
f'{entry_type.lower()}_number':
|
456
|
+
f'{entry_type.lower()}_number': entry_number,
|
405
457
|
'full_path': full_path
|
406
458
|
}
|
407
|
-
|
408
|
-
if entry_type == 'Plan':
|
409
|
-
plan_info = self._parse_plan_file(Path(full_path))
|
410
|
-
entry.update(plan_info)
|
411
|
-
|
412
|
-
hdf_results_path = self.project_folder / f"{self.project_name}.p{file_name[1:]}.hdf"
|
413
|
-
entry['HDF_Results_Path'] = str(hdf_results_path) if hdf_results_path.exists() else None
|
414
|
-
|
459
|
+
|
415
460
|
if entry_type == 'Unsteady':
|
461
|
+
entry['unsteady_number'] = entry_number
|
416
462
|
unsteady_info = self._parse_unsteady_file(Path(full_path))
|
417
463
|
entry.update(unsteady_info)
|
464
|
+
else:
|
465
|
+
entry.update({
|
466
|
+
'unsteady_number': None,
|
467
|
+
'geometry_number': None
|
468
|
+
})
|
469
|
+
|
470
|
+
if entry_type == 'Plan':
|
471
|
+
plan_info = self._parse_plan_file(Path(full_path))
|
472
|
+
if plan_info:
|
473
|
+
# Handle Flow File (unsteady) number
|
474
|
+
flow_file = plan_info.get('Flow File')
|
475
|
+
if flow_file and flow_file.startswith('u'):
|
476
|
+
entry['unsteady_number'] = flow_file[1:]
|
477
|
+
entry['Flow File'] = flow_file[1:]
|
478
|
+
else:
|
479
|
+
entry['unsteady_number'] = None
|
480
|
+
entry['Flow File'] = flow_file[1:] if flow_file and flow_file.startswith('f') else None
|
481
|
+
|
482
|
+
# Handle Geom File number
|
483
|
+
geom_file = plan_info.get('Geom File')
|
484
|
+
if geom_file and geom_file.startswith('g'):
|
485
|
+
entry['geometry_number'] = geom_file[1:]
|
486
|
+
entry['Geom File'] = geom_file[1:]
|
487
|
+
else:
|
488
|
+
entry['geometry_number'] = None
|
489
|
+
entry['Geom File'] = None
|
490
|
+
|
491
|
+
# Add all plan key information with exact same names
|
492
|
+
for key, value in plan_info.items():
|
493
|
+
if key not in ['Flow File', 'Geom File']:
|
494
|
+
entry[key] = value
|
495
|
+
|
496
|
+
# Add HDF results path
|
497
|
+
hdf_results_path = self.project_folder / f"{self.project_name}.p{entry_number}.hdf"
|
498
|
+
entry['HDF_Results_Path'] = str(hdf_results_path) if hdf_results_path.exists() else None
|
418
499
|
|
419
500
|
entries.append(entry)
|
501
|
+
|
502
|
+
df = pd.DataFrame(entries)
|
503
|
+
|
504
|
+
if not df.empty and entry_type == 'Plan':
|
505
|
+
# Set required column order
|
506
|
+
first_cols = ['plan_number', 'unsteady_number', 'geometry_number']
|
507
|
+
|
508
|
+
# Standard plan key columns in the exact order specified
|
509
|
+
plan_key_cols = [
|
510
|
+
'Plan Title', 'Program Version', 'Short Identifier', 'Simulation Date',
|
511
|
+
'Std Step Tol', 'Computation Interval', 'Output Interval', 'Instantaneous Interval',
|
512
|
+
'Mapping Interval', 'Run HTab', 'Run UNet', 'Run Sediment', 'Run PostProcess',
|
513
|
+
'Run WQNet', 'Run RASMapper', 'UNET Use Existing IB Tables', 'HDF_Results_Path',
|
514
|
+
'UNET 1D Methodology', 'Write IC File', 'Write IC File at Fixed DateTime',
|
515
|
+
'IC Time', 'Write IC File Reoccurance', 'Write IC File at Sim End'
|
516
|
+
]
|
517
|
+
|
518
|
+
# Additional convenience columns
|
519
|
+
file_path_cols = ['Geom File', 'Geom Path', 'Flow File', 'Flow Path']
|
520
|
+
|
521
|
+
# Build the final column list
|
522
|
+
all_cols = first_cols.copy()
|
523
|
+
for col in plan_key_cols:
|
524
|
+
if col in df.columns:
|
525
|
+
all_cols.append(col)
|
526
|
+
|
527
|
+
# Add any remaining columns not explicitly specified
|
528
|
+
other_cols = [col for col in df.columns if col not in all_cols + file_path_cols + ['full_path']]
|
529
|
+
all_cols.extend(other_cols)
|
530
|
+
all_cols.extend(file_path_cols)
|
531
|
+
|
532
|
+
# Rename plan_number column
|
533
|
+
df = df.rename(columns={f'{entry_type.lower()}_number': 'plan_number'})
|
534
|
+
|
535
|
+
# Fill in missing columns with None
|
536
|
+
for col in all_cols:
|
537
|
+
if col not in df.columns:
|
538
|
+
df[col] = None
|
539
|
+
|
540
|
+
# Return DataFrame with specified column order
|
541
|
+
return df[all_cols]
|
542
|
+
|
543
|
+
return df
|
420
544
|
except Exception as e:
|
545
|
+
logger.error(f"Error in _get_prj_entries for {entry_type}: {e}")
|
421
546
|
raise
|
422
547
|
|
423
|
-
return pd.DataFrame(entries)
|
424
|
-
|
425
548
|
def _parse_unsteady_file(self, unsteady_file_path):
|
426
549
|
"""
|
427
550
|
Parse an unsteady flow file and extract critical information.
|
@@ -811,6 +934,28 @@ class RasPrj:
|
|
811
934
|
|
812
935
|
return bc_info, unparsed_lines
|
813
936
|
|
937
|
+
@log_call
|
938
|
+
def get_unsteady_numbers_from_plans(self):
|
939
|
+
"""
|
940
|
+
Get all plans that use unsteady flow files.
|
941
|
+
|
942
|
+
Returns:
|
943
|
+
--------
|
944
|
+
pd.DataFrame
|
945
|
+
A DataFrame containing only plan entries that use unsteady flow files.
|
946
|
+
|
947
|
+
Raises:
|
948
|
+
-------
|
949
|
+
RuntimeError: If the project has not been initialized.
|
950
|
+
"""
|
951
|
+
self.check_initialized()
|
952
|
+
|
953
|
+
# Filter plan_df to only include plans with unsteady_number not None
|
954
|
+
unsteady_plans = self.plan_df[self.plan_df['unsteady_number'].notna()].copy()
|
955
|
+
|
956
|
+
logger.info(f"Found {len(unsteady_plans)} plans using unsteady flow files")
|
957
|
+
|
958
|
+
return unsteady_plans
|
814
959
|
|
815
960
|
# Create a global instance named 'ras'
|
816
961
|
# Defining the global instance allows the init_ras_project function to initialize the project.
|
@@ -881,8 +1026,8 @@ def get_ras_exe(ras_version=None):
|
|
881
1026
|
|
882
1027
|
Args:
|
883
1028
|
ras_version (str, optional): Either a version number or a full path to the HEC-RAS executable.
|
884
|
-
If None, the function will
|
885
|
-
or a default path.
|
1029
|
+
If None, the function will first check the global 'ras' object for a path.
|
1030
|
+
If the global 'ras' object is not initialized or doesn't have a path, a default path will be used.
|
886
1031
|
|
887
1032
|
Returns:
|
888
1033
|
str: The full path to the HEC-RAS executable.
|
ras_commander/__init__.py
CHANGED
@@ -10,7 +10,7 @@ try:
|
|
10
10
|
__version__ = version("ras-commander")
|
11
11
|
except PackageNotFoundError:
|
12
12
|
# package is not installed
|
13
|
-
__version__ = "0.
|
13
|
+
__version__ = "0.65.0"
|
14
14
|
|
15
15
|
# Set up logging
|
16
16
|
setup_logging()
|
@@ -23,8 +23,6 @@ from .RasUnsteady import RasUnsteady
|
|
23
23
|
from .RasUtils import RasUtils
|
24
24
|
from .RasExamples import RasExamples
|
25
25
|
from .RasCmdr import RasCmdr
|
26
|
-
from .RasGpt import RasGpt
|
27
|
-
from .RasToGo import RasToGo
|
28
26
|
from .HdfFluvialPluvial import HdfFluvialPluvial
|
29
27
|
|
30
28
|
# HDF handling
|
@@ -41,7 +39,6 @@ from .HdfXsec import HdfXsec
|
|
41
39
|
from .HdfPump import HdfPump
|
42
40
|
from .HdfPipe import HdfPipe
|
43
41
|
from .HdfInfiltration import HdfInfiltration
|
44
|
-
from .RasMapper import RasMapper
|
45
42
|
|
46
43
|
# Plotting functionality
|
47
44
|
from .HdfPlot import HdfPlot
|
@@ -52,14 +49,13 @@ __all__ = [
|
|
52
49
|
# Core functionality
|
53
50
|
'RasPrj', 'init_ras_project', 'get_ras_exe', 'ras',
|
54
51
|
'RasPlan', 'RasGeo', 'RasUnsteady', 'RasUtils',
|
55
|
-
'RasExamples', 'RasCmdr', '
|
56
|
-
'HdfFluvialPluvial',
|
52
|
+
'RasExamples', 'RasCmdr', 'HdfFluvialPluvial',
|
57
53
|
|
58
54
|
# HDF handling
|
59
55
|
'HdfBase', 'HdfBndry', 'HdfMesh', 'HdfPlan',
|
60
56
|
'HdfResultsMesh', 'HdfResultsPlan', 'HdfResultsXsec',
|
61
57
|
'HdfStruc', 'HdfUtils', 'HdfXsec', 'HdfPump',
|
62
|
-
'HdfPipe', 'HdfInfiltration',
|
58
|
+
'HdfPipe', 'HdfInfiltration',
|
63
59
|
|
64
60
|
# Plotting functionality
|
65
61
|
'HdfPlot', 'HdfResultsPlot',
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ras-commander
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.65.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.
|
@@ -35,22 +35,25 @@ Dynamic: summary
|
|
35
35
|
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 was initially conceptualized in the Australian Water School course "AI Tools for Modelling Innovation", and subsequently expanded to cover the basic functionality of the HECRASController COM32 interface using open-source python libraries. This library uses a Test Driven Development strategy, leveraging the publicly-available HEC-RAS Example projects to create repeatable demonstration examples. The "Commmander" moniker is inspired by the "Command Line is All You Need" approach to HEC-RAS automation that was first implemented in the HEC-Commander Tools repository.
|
36
36
|
|
37
37
|
## Repository Author:
|
38
|
-
|
38
|
+
[William Katzenmeyer, P.E., C.F.M.](https://engineeringwithllms.info)
|
39
|
+
-----
|
39
40
|
|
40
|
-
## Don't Ask Me, Ask GPT!
|
41
|
+
## Don't Ask Me, Ask GPT!
|
41
42
|
|
42
43
|
This repository has several methods of interaction with Large Language Models and LLM-Assisted Coding built right in:
|
43
44
|
|
44
|
-
1. **[
|
45
|
+
1. **[Purpose-Built Knowledge Base Summaries](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/llm_knowledge_bases)**: Up-to-date compilations of the documentation and codebase for use with large language models like Claude, ChatGPT, Gemini or Grok. Look in 'ai_tools/assistant_knowledge_bases/' in the repo. The repo's codebase (without documentation and examples) has been curated to stay within the current ~200k context window limitations of frontier models, and for tasks that do not need an understanding of the underlying code, the Comprehensive Library Guide and any relevant examples from the example folder should be adequate context for leveraging the ras-commander API to complete tasks.
|
45
46
|
|
46
|
-
2. **[
|
47
|
+
2. **[Cursor IDE Integration](https://github.com/gpt-cmdr/ras-commander/blob/main/.cursorrules)**: Custom rules(.cursorrules) for the Cursor IDE to provide context-aware suggestions and documentation. Just open the repository folder in Cursor to recognize these instructions. You can create your own folders "/workspace/, "/projects/", or "my_projects/" as these are already in the .gitignore, and place your custom scripts there for your projects. This will allow easy referencing of the ras-commander documents and individual repo files, the automatic loading of the .cursorrules file. Alternatvely, download the github repo into your projects folder to easily load documents and use cursor rules files.
|
47
48
|
|
48
|
-
3. **[
|
49
|
+
3. **[RAS-Commander Library Assistant](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/library_assistant)**: A full-featured interface for multi-turn conversations, using your own API keys and the ras-commander library for context. The library assistant allows you to load your own scripts and chat with specific examples and/or function classes in the RAS-Commander library to effectively utilize the library's functions in your workflow. To reduce hallucinations, a file browser is included which adds full files to the conversation to ensure grounded responses. A dashboard shows you the total context and estimated cost of each request. **Now with support for Claude 3.7, OpenAI's o1 and o3-mini, and Deepseek V3 and R1 models using US-based Together.ai**
|
50
|
+
|
51
|
+
|
52
|
+
4. **[RAS Commander Library Assistant on ChatGPT](https://chatgpt.com/g/g-TZRPR3oAO-ras-commander-library-assistant)**: A specialized ChatGPT "GPT" with access to the ras-commander codebase and library, available for answering queries and providing code suggestions. 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. _NOTE: GPT's are still quite limited by OpenAI's GPT frameworks and may not be useful for long conversations. Code interpreter cannot run HEC-RAS but can open and view smaller HDF files and projects for demonstration purposes_
|
49
53
|
|
50
|
-
5. **[RAS-Commander Library Assistant](https://github.com/gpt-cmdr/ras-commander/blob/main/library_assistant)**: A full-featured interface for multi-turn conversations, using your own API keys and the ras-commander library for context. The library assistant allows you to load your own scripts and chat with specific examples and/or function classes in the RAS-Commander library to effectively utilize the library's functions in your workflow. To reduce hallucinations, a file browser is included which adds full files to the conversation to ensure grounded responses. A dashboard shows you the total context and estimated cost of each request. **Now with support for OpenAI's o1 and o3-mini, and Deepseek V3 and R1 models using US-based Together.ai**
|
51
54
|
|
52
55
|
## Background
|
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.
|
56
|
+
The ras-commander library emerged from the initial test-bed of AI-driven coding represented by the [HEC-Commander tools](https://github.com/gpt-cmdr/HEC-Commander) Python notebooks. These notebooks served as a proof of concept, demonstrating the value proposition of automating HEC-RAS operations. In 2024, I taught a series of progressively more complex webinars demonstrating how to use simple prompting, example projects and natural language instruction to effectively code HEC-RAS automation workflows, culminating in a 6 hour course. The library published for utilization in that course, [awsrastools](https://github.com/gpt-cmdr/awsrastools) served as a foundation of examples which were iteratively extended into the full RAS-Commander library. Unlike the original notebook by the same name, this library is not focused on parallel execution across multiple machines. Instead, it is focused on providing a general-purpose python API for interacting with HEC-RAS projects, and building an AI-friendly library that will allow new users to quickly scaffold their own workflows into a python script. Example notebooks are provided, but the intention is to empower engineers, software developers, GIS personnel and data analysts to more easily access and interact with HEC-RAS data in a python environment. Also, by publishing these examples publicly, with complete working code examples and LLM optimization, future users can readily rewrite they key functions of the library for inclusion in into their own preferred libraries, languages or return formats.
|
54
57
|
|
55
58
|
## Features
|
56
59
|
|
@@ -92,7 +95,13 @@ In your virtual environment, install ras-commander using pip:
|
|
92
95
|
pip install --upgrade ras-commander
|
93
96
|
```
|
94
97
|
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.
|
95
|
-
|
98
|
+
|
99
|
+
Dependencies can also be manually installed:
|
100
|
+
```
|
101
|
+
pip install h5py numpy pandas requests tqdm scipy xarray geopandas matplotlib shapely pathlib rasterstats rtree
|
102
|
+
```
|
103
|
+
|
104
|
+
|
96
105
|
#### Work in a Local Copy
|
97
106
|
|
98
107
|
If you want to make revisions and work actively in your local version of ras-commander, just skip the pip install rascommander step above and clone a fork of the repo to your local machine using Git (ask ChatGPT if you need help). Most of the notebooks and examples in this repo have a code segment similar to the one below, that works as long as the script is located in a first-level subfolder of the ras-commander repository:
|
@@ -135,24 +144,27 @@ Using the default 'ras" object, othewise substitute your_ras_project for muli-pr
|
|
135
144
|
```
|
136
145
|
print("\nPlan Files DataFrame:")
|
137
146
|
ras.plan_df
|
138
|
-
|
147
|
+
```
|
148
|
+
```
|
139
149
|
print("\nFlow Files DataFrame:")
|
140
150
|
ras.flow_df
|
141
|
-
|
151
|
+
```
|
152
|
+
```
|
142
153
|
print("\nUnsteady Flow Files DataFrame:")
|
143
154
|
ras.unsteady_df
|
144
|
-
|
155
|
+
```
|
156
|
+
```
|
145
157
|
print("\nGeometry Files DataFrame:")
|
146
158
|
ras.geom_df
|
147
|
-
|
148
|
-
|
149
|
-
ras.get_hdf_entries()
|
150
|
-
|
159
|
+
```
|
160
|
+
```
|
151
161
|
print("\nBoundary Conditions DataFrame:")
|
152
162
|
ras.boundaries_df
|
153
|
-
|
154
163
|
```
|
155
|
-
|
164
|
+
```
|
165
|
+
print("\nHDF Entries DataFrame:")
|
166
|
+
ras.get_hdf_entries()
|
167
|
+
```
|
156
168
|
|
157
169
|
|
158
170
|
|
@@ -265,6 +277,11 @@ This is useful for comparing different river systems, running scenario analyses
|
|
265
277
|
|
266
278
|
```
|
267
279
|
ras_commander
|
280
|
+
├── ai_tools
|
281
|
+
│ ├── [AI Knowledge Bases](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/llm_knowledge_bases)
|
282
|
+
│ └── [Library Assistant](https://github.com/gpt-cmdr/ras-commander/tree/main/ai_tools/library_asssistant)
|
283
|
+
├── examples
|
284
|
+
│ └── [Examples Notebooks](https://github.com/gpt-cmdr/ras-commander/tree/main/ras_commander)
|
268
285
|
├── ras_commander
|
269
286
|
│ ├── __init__.py
|
270
287
|
│ ├── _version.py
|
@@ -277,8 +294,6 @@ ras_commander
|
|
277
294
|
│ ├── RasPrj.py
|
278
295
|
│ ├── RasUnsteady.py
|
279
296
|
│ ├── RasUtils.py
|
280
|
-
│ ├── RasToGo.py
|
281
|
-
│ ├── RasGpt.py
|
282
297
|
│ ├── HdfBase.py
|
283
298
|
│ ├── HdfBndry.py
|
284
299
|
│ ├── HdfMesh.py
|
@@ -292,28 +307,13 @@ ras_commander
|
|
292
307
|
│ ├── HdfFluvialPluvial.py
|
293
308
|
│ ├── HdfPlot.py
|
294
309
|
│ └── HdfResultsPlot.py
|
295
|
-
├── examples
|
296
|
-
│ ├── 00_Using_RasExamples.ipynb
|
297
|
-
│ ├── 01_project_initialization.ipynb
|
298
|
-
│ ├── 02_plan_and_geometry_operations.ipynb
|
299
|
-
│ ├── 03_unsteady_flow_operations.ipynb
|
300
|
-
│ ├── 04_multiple_project_operations.ipynb
|
301
|
-
│ ├── 05_single_plan_execution.ipynb
|
302
|
-
│ ├── 06_executing_plan_sets.ipynb
|
303
|
-
│ ├── 07_sequential_plan_execution.ipynb
|
304
|
-
│ ├── 08_parallel_execution.ipynb
|
305
|
-
│ └── 09_plan_parameter_operations.ipynb
|
306
|
-
├── tests
|
307
|
-
│ └── ... (test files)
|
308
310
|
├── .gitignore
|
309
311
|
├── LICENSE
|
310
312
|
├── README.md
|
311
313
|
├── STYLE_GUIDE.md
|
312
314
|
├── Comprehensive_Library_Guide.md
|
313
315
|
├── pyproject.toml
|
314
|
-
├── setup.cfg
|
315
316
|
├── setup.py
|
316
|
-
└── requirements.txt
|
317
317
|
```
|
318
318
|
|
319
319
|
### Accessing HEC Examples through RasExamples
|
@@ -335,6 +335,8 @@ projects = ras_examples.list_projects("Steady Flow")
|
|
335
335
|
extracted_paths = ras_examples.extract_project(["Bald Eagle Creek", "Muncie"])
|
336
336
|
```
|
337
337
|
|
338
|
+
The RasExamples class is used to provide an alternative to traditional unit testing, with example notebooks doubling as tests and in-context examples for the end user. This increases interpretability by LLM's, reducing hallucinations.
|
339
|
+
|
338
340
|
### RasPrj
|
339
341
|
|
340
342
|
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.
|
@@ -459,18 +461,11 @@ The ras-commander library is an ongoing project. Future plans include:
|
|
459
461
|
- [GPT-Commander YouTube Channel](https://www.youtube.com/@GPT_Commander)
|
460
462
|
- [ChatGPT Examples for Water Resources Engineers](https://github.com/gpt-cmdr/HEC-Commander/tree/main/ChatGPT%20Examples)
|
461
463
|
|
462
|
-
## Contributing
|
463
|
-
|
464
|
-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
|
465
464
|
|
466
465
|
## Style Guide
|
467
466
|
|
468
467
|
This project follows a specific style guide to maintain consistency across the codebase. Please refer to the [Style Guide](STYLE_GUIDE.md) for details on coding conventions, documentation standards, and best practices.
|
469
468
|
|
470
|
-
## License
|
471
|
-
|
472
|
-
ras-commander is released under the MIT License. See the license file for details.
|
473
|
-
|
474
469
|
## Acknowledgments
|
475
470
|
|
476
471
|
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.
|
@@ -488,7 +483,7 @@ Additionally, we would like to acknowledge the following notable contributions a
|
|
488
483
|
Xiaofeng Liu, Ph.D., P.E., Associate Professor, Department of Civil and Environmental Engineering
|
489
484
|
Institute of Computational and Data Sciences, Penn State University
|
490
485
|
|
491
|
-
3. Attribution: The[ffrd\rashdf'](https://github.com/fema-ffrd/rashdf) project by FEMA-FFRD (FEMA Future of Flood Risk Data) was incorporated, revised, adapted and extended in rascommander's RasHDF libaries (where noted).
|
486
|
+
3. Attribution: The [ffrd\rashdf'](https://github.com/fema-ffrd/rashdf) project by FEMA-FFRD (FEMA Future of Flood Risk Data) was incorporated, revised, adapted and extended in rascommander's RasHDF libaries (where noted).
|
492
487
|
|
493
488
|
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.
|
494
489
|
|
@@ -499,19 +494,25 @@ These acknowledgments recognize the contributions and inspirations that have hel
|
|
499
494
|
## Official RAS Commander AI-Generated Songs:
|
500
495
|
|
501
496
|
[No More Wait and See (Bluegrass)](https://suno.com/song/16889f3e-50f1-4afe-b779-a41738d7617a)
|
502
|
-
|
497
|
+
|
498
|
+
|
503
499
|
[No More Wait and See (Cajun Zydeco)](https://suno.com/song/4441c45d-f6cd-47b9-8fbc-1f7b277ee8ed)
|
504
|
-
|
500
|
+
|
505
501
|
## Other Resources
|
506
502
|
|
507
|
-
Notebook version of RAS-Commander: [RAS-Commander Notebook in the HEC-Commander Tools Repository](https://github.com/gpt-cmdr/HEC-Commander/tree/main/RAS-Commander)
|
503
|
+
Notebook version of RAS-Commander: [RAS-Commander Notebook in the HEC-Commander Tools Repository](https://github.com/gpt-cmdr/HEC-Commander/tree/main/RAS-Commander)
|
504
|
+
|
508
505
|
Youtube Tutorials for HEC-Commander Tools and RAS-Commander: [GPT-Commander on YouTube](https://www.youtube.com/@GPT_Commander/videos)
|
509
506
|
|
507
|
+
## Contributing
|
508
|
+
|
509
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and suggest improvements.
|
510
|
+
|
510
511
|
## LICENSE
|
511
512
|
|
512
513
|
This software is released under the MIT license.
|
513
514
|
|
514
515
|
## Contact
|
515
516
|
|
516
|
-
For questions, suggestions, or support, please contact:
|
517
|
+
For questions, suggestions, or support, please contact:
|
517
518
|
William Katzenmeyer, P.E., C.F.M. - heccommander@gmail.com
|
@@ -1,18 +1,18 @@
|
|
1
1
|
ras_commander/Decorators.py,sha256=0UIYc-hzmBVS7tovSLMzDp2NIhwrZvOYNrQSvETxhEE,6538
|
2
2
|
ras_commander/HdfBase.py,sha256=Jws6Y8JFkharuiM6Br5ivp6MS64X2fL6y87FOpe3FQw,14219
|
3
|
-
ras_commander/HdfBndry.py,sha256=
|
3
|
+
ras_commander/HdfBndry.py,sha256=FBNFoTz4sXVB-MOsbHJBP8P0dMqJUfBROloKTaxmzCo,16377
|
4
4
|
ras_commander/HdfFluvialPluvial.py,sha256=dlqoFX5i7uSA2BvuRNrV-Fg-z2JaeUxY86_fbZAdGqI,25933
|
5
|
-
ras_commander/HdfInfiltration.py,sha256=
|
5
|
+
ras_commander/HdfInfiltration.py,sha256=SB8EsB-w1zrUHXqn3G8ihEahViTIZF7c7AyPHIrSrOU,15473
|
6
6
|
ras_commander/HdfMesh.py,sha256=zI_4AqxDxb2_31G9RUmWibyld6KDMGhDpI3F8qwzVAw,19139
|
7
7
|
ras_commander/HdfPipe.py,sha256=m-yvPL2GIP23NKt2tcwzOlS7khvgcDPGAshlTPMUAeI,32154
|
8
|
-
ras_commander/HdfPlan.py,sha256=
|
8
|
+
ras_commander/HdfPlan.py,sha256=jCNeyMHlaiMjn6wgGjVXrRElMSh3xwlmFJxHMzOkanM,12317
|
9
9
|
ras_commander/HdfPlot.py,sha256=7MNI5T9qIz-Ava1RdlnB6O9oJElE5BEB29QVF5Y2Xuc,3401
|
10
10
|
ras_commander/HdfPump.py,sha256=Vc2ff16kRISR7jwtnaAqxI0p-gfBSuZKzR3rQbBLQoE,12951
|
11
|
-
ras_commander/HdfResultsMesh.py,sha256=
|
12
|
-
ras_commander/HdfResultsPlan.py,sha256=
|
11
|
+
ras_commander/HdfResultsMesh.py,sha256=nO2dGYEvQiUWr19MAkkVAkU5AW3kKcps8d0zgox73u4,31738
|
12
|
+
ras_commander/HdfResultsPlan.py,sha256=L3IOdF6R3XiA7mbFAyLdczrZJQJogd8hhl7UYJWT5fY,16246
|
13
13
|
ras_commander/HdfResultsPlot.py,sha256=ylzfT78CfgoDO0XAlRwlgMNRzvNQYBMn9eyXyBfjv_w,7660
|
14
14
|
ras_commander/HdfResultsXsec.py,sha256=-P7nXnbjOLAeUnrdSC_lJQSfzrlWKmDF9Z5gEjmxbJY,13031
|
15
|
-
ras_commander/HdfStruc.py,sha256
|
15
|
+
ras_commander/HdfStruc.py,sha256=SznjPvBWiqNVtviZvfCdjB_iwZF4UXxlIxITD8kwjP4,13733
|
16
16
|
ras_commander/HdfUtils.py,sha256=VkIKAXBrLwTlk2VtXSO-W3RU-NHpfHbE1QcZUZgl-t8,15248
|
17
17
|
ras_commander/HdfXsec.py,sha256=flREnFFrIZu4SSKGRQeX9w3SS49q0UWPJnq4zO7DbUM,27342
|
18
18
|
ras_commander/LoggingConfig.py,sha256=gWe5K5XTmMQpSczsTysAqpC9my24i_IyM8dvD85fxYg,2704
|
@@ -20,15 +20,15 @@ ras_commander/RasCmdr.py,sha256=2i9gR5koFfBLwvhYAbNgQFNKKUKqxD1Hf6T9SN9sx-s,2655
|
|
20
20
|
ras_commander/RasExamples.py,sha256=6IZ96LcAsk5LYFehdD0zDW5wyZWxQa6OQu2N9upxWXA,17536
|
21
21
|
ras_commander/RasGeo.py,sha256=M0sVNKlWmmbve8iMXLWq25WgbxqLWBo7_1oDg_rALzU,5607
|
22
22
|
ras_commander/RasGpt.py,sha256=N_7p2nucWrBBXdB2k2ZKvOeOdXNmFD9dIY3W7_5i5nw,1206
|
23
|
-
ras_commander/RasMapper.py,sha256=
|
24
|
-
ras_commander/RasPlan.py,sha256=
|
25
|
-
ras_commander/RasPrj.py,sha256=
|
23
|
+
ras_commander/RasMapper.py,sha256=LO_blvQnd4pwkEU8A30-RoE-CYIoU3s_fNLHBoM8ljw,613
|
24
|
+
ras_commander/RasPlan.py,sha256=9RbOzQyz0_BCRa-gds_ca3_DImNMeX6n5NslkjpfT1w,62477
|
25
|
+
ras_commander/RasPrj.py,sha256=b0d0A5WKkUXRtQobUcDPBTTGymtM_EWZwFbpOrNjqfY,44731
|
26
26
|
ras_commander/RasToGo.py,sha256=TKujfaV1xQhFaOddF4g2ogGy6ky-CLlfelSMPD2J3Nk,1223
|
27
27
|
ras_commander/RasUnsteady.py,sha256=KfCXAag-_bPwwS3JbPZH-s4hbaoHACO0mlRnGrzbFgA,32092
|
28
28
|
ras_commander/RasUtils.py,sha256=P2-aBL61kdRINsjnBpstZVD6VVc7hI_D3RUXqr6ldmc,34863
|
29
|
-
ras_commander/__init__.py,sha256=
|
30
|
-
ras_commander-0.
|
31
|
-
ras_commander-0.
|
32
|
-
ras_commander-0.
|
33
|
-
ras_commander-0.
|
34
|
-
ras_commander-0.
|
29
|
+
ras_commander/__init__.py,sha256=Aojks8MKjFZceg9TEaTqrr6RsgLeJAh6iZrRZVoOdg0,2001
|
30
|
+
ras_commander-0.65.0.dist-info/LICENSE,sha256=_pbd6qHnlsz1iQ-ozDW_49r86BZT6CRwO2iBtw0iN6M,457
|
31
|
+
ras_commander-0.65.0.dist-info/METADATA,sha256=7Ddh7KnY46exroA1XG0YC77l3YKdQJqiNZuyZIUtOPE,26233
|
32
|
+
ras_commander-0.65.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
33
|
+
ras_commander-0.65.0.dist-info/top_level.txt,sha256=i76S7eKLFC8doKcXDl3aiOr9RwT06G8adI6YuKbQDaA,14
|
34
|
+
ras_commander-0.65.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|