opensha / opensha-fault-sys-tools

Tools for Fault Systems: building and analyzing Rupture Sets, inverting for Solutions, computing and disaggregating hazard
Apache License 2.0
3 stars 1 forks source link

Script to break apart and stitch back together connected fault clusters #2

Open heathercrume-moodys opened 3 weeks ago

heathercrume-moodys commented 3 weeks ago

It would be very useful to be able to pull out a connected cluster of faults from the NSHM23 WUS inversion so it can be run separately and then stitched back together with the rest of the connected fault clusters. Is it possible to include a Java script that does this, i.e., breaks apart connected clusters and then stitches them back together?

kevinmilner commented 2 days ago

OK, I have a draft tool ready. FST should detected the update automatically and rebuild, but you can force it to update via fst_force_opensha_update.sh. The new tool is fst_cluster_tool.sh and it can be used both to split and re-stitch clusters.

The basic usage to split is:

fst_cluster_tool.sh --split --input /path/to/solution_or_rupture_set.zip --output /path/to/split_output_dir

The basic usage to combine is:

fst_cluster_tool.sh --combine --input /path/to/split_output_dir --output /path/to/output_solution_or_rupture_set.zip

Here are all of the command line options:

$ fst_cluster_tool.sh --help
usage: ClusterSplitterAndCombinerTool [-?] [--combine] [--full-rupture-set <arg>] --input <arg> --output <arg> [--remap] [--split]
 -?,--help                     Displays usage including command line arguments, and exits.
    --combine                  Flag to enable combining mode; --input is assumed to be a directory and --output is assumed to be a file
    --full-rupture-set <arg>   Path the original full rupture set, optionally used with --combine if directory supplied via --input contains solutions.
                               If supplied, the given rupture set will be used and all attached modules kept, rather than building a stripped down
                               rupture set from the sections and ruptures encountered in the input files. Cluster-specific rupture sets must have
                               mappings to their original sections/ruptures attached (which they will if they were split using this tool).
    --input <arg>              Path to the input solution/rupture set file (if --split) or directory containing cluster-specific zip files (if
                               --combine). In combine mode, input zip files must start with `cluster` and end with `.zip` (and no other files should
                               match that pattern).
    --output <arg>             Path to the putput solution/rupture set file (if --combine) or directory to write cluster-specific zip files (if
                               --split)
    --remap                    Flag to ignore attached rupture set mappings and assign new indexes in combine mode. This is useful if you want to
                               delete a cluster.
    --split                    Flag to enable splitting mode; --input is assumed to be a single file and --output is assumed to be a directory

Give it a try and let me know how it goes.

TODO: documentation page (feel free to write and contribute it!)