|
2 | 2 | """ |
3 | 3 | BSD 3-Clause License |
4 | 4 |
|
5 | | -Copyright (c) 2025, University of Southern California |
| 5 | +Copyright (c) 2026, University of Southern California |
6 | 6 | All rights reserved. |
7 | 7 |
|
8 | 8 | Redistribution and use in source and binary forms, with or without |
@@ -200,7 +200,7 @@ def generate_xml(install, numsim, srcdir, xmldir, |
200 | 200 | skip_rupgen, srf_prefix, only_rup, |
201 | 201 | gmpe_group_name, allmetrics, |
202 | 202 | site_response, multiseg, segment, |
203 | | - source_file, fasgof): |
| 203 | + source_file, fasgof, station_list=None): |
204 | 204 | """ |
205 | 205 | Generates xml files in the xmldir for numsim simulations whose |
206 | 206 | source files are in the srcdir using the validation event and |
@@ -252,7 +252,13 @@ def generate_xml(install, numsim, srcdir, xmldir, |
252 | 252 | optfile.write('n\n') # Skip rupture generator |
253 | 253 | else: |
254 | 254 | optfile.write('y\n') # Run rupture generator |
255 | | - optfile.write('1\n') # All validation stations |
| 255 | + if station_list is None: |
| 256 | + optfile.write('1\n') # All validation stations |
| 257 | + else: |
| 258 | + # Use provided station list instead |
| 259 | + optfile.write('2\n') # Custom list |
| 260 | + optfile.write('2\n') # Enter path to station file |
| 261 | + optfile.write('%s\n' % (station_list)) # STL file |
256 | 262 | if skip_rupgen: |
257 | 263 | # We should provide SRF file |
258 | 264 | optfile.write('2\n') # Enter path to src/srf file |
@@ -390,6 +396,14 @@ def main(): |
390 | 396 | help="Use a site response module: %s" % (SITE_MODULES)) |
391 | 397 | parser.add_option("--fas", action="store_true", dest="fasgof", |
392 | 398 | help="Run both FAS and PSA validations") |
| 399 | + parser.add_option("--src", "--source", type="string", action="store", |
| 400 | + dest="source", |
| 401 | + help="Use this source description file instead of the one " |
| 402 | + "provided in the validation package") |
| 403 | + parser.add_option("--stl", "--station-list", type="string", action="store", |
| 404 | + dest="station_list", |
| 405 | + help="Use this station list file instead of the one " |
| 406 | + "provided in the validation package") |
393 | 407 |
|
394 | 408 | (options, args) = parser.parse_args() |
395 | 409 |
|
@@ -499,12 +513,27 @@ def main(): |
499 | 513 | else: |
500 | 514 | hypo_rand = False |
501 | 515 |
|
502 | | - try: |
503 | | - source_file = val_obj.get_input(codebase, "source") |
504 | | - except KeyError: |
505 | | - print("Unable to get source file for event %s, codebase %s!" % |
506 | | - (event, codebase)) |
507 | | - sys.exit(1) |
| 516 | + # Check if user provided a custom SRC file for this run |
| 517 | + source_file = options.source |
| 518 | + if source_file is not None: |
| 519 | + # Got a file from the user, parse the input |
| 520 | + |
| 521 | + # First, we make a list |
| 522 | + pieces = source_file.split(",") |
| 523 | + pieces = [piece.strip() for piece in pieces] |
| 524 | + |
| 525 | + # Check if single file or list of files |
| 526 | + if len(pieces) == 1: |
| 527 | + source_file = pieces[0] |
| 528 | + else: |
| 529 | + source_file = pieces |
| 530 | + else: |
| 531 | + try: |
| 532 | + source_file = val_obj.get_input(codebase, "source") |
| 533 | + except KeyError: |
| 534 | + print("Unable to get source file for event %s, codebase %s!" % |
| 535 | + (event, codebase)) |
| 536 | + sys.exit(1) |
508 | 537 | if not source_file: |
509 | 538 | print("Source file for event %s, codebase %s not specified!" % |
510 | 539 | (event, codebase)) |
@@ -587,6 +616,18 @@ def main(): |
587 | 616 | gmpe_group_index = gmpe_groups_available_lc.index(gmpe_group_name.lower()) |
588 | 617 | gmpe_group_name = gmpe_groups_available[gmpe_group_index] |
589 | 618 |
|
| 619 | + # Check for user-provided station list |
| 620 | + station_list = options.station_list |
| 621 | + if station_list is not None: |
| 622 | + # Custom station list provided by the user |
| 623 | + # Make it a full path |
| 624 | + station_list = os.path.realpath(station_list) |
| 625 | + # Make sure station list exists and is readable |
| 626 | + if (not os.path.isfile(station_list) or |
| 627 | + not os.access(station_list, os.R_OK)): |
| 628 | + print("Station list does not seem to be accessible!") |
| 629 | + sys.exit(1) |
| 630 | + |
590 | 631 | # Make sure user has configured the setup_bbp_env.sh script |
591 | 632 | setup_bbp_env = os.path.join(bbp_install.A_INSTALL_ROOT, |
592 | 633 | "utils/batch/setup_bbp_env.sh") |
@@ -622,7 +663,8 @@ def main(): |
622 | 663 | logsdir, event, codebase, prefix, |
623 | 664 | skip_rupgen, srf_prefix, only_rup, |
624 | 665 | gmpe_group_name, allmetrics, site_response, |
625 | | - multiseg, segment, source_file, fasgof) |
| 666 | + multiseg, segment, source_file, fasgof, |
| 667 | + station_list) |
626 | 668 |
|
627 | 669 | # Write .info file |
628 | 670 | info_file = open(os.path.join(simdir, "%s.info" % (prefix)), 'w') |
|
0 commit comments