Skip to content

Add remaining Genslip parameters to SRFConfig#93

Draft
Copilot wants to merge 2 commits intopegasusfrom
copilot/add-genslip-parameters
Draft

Add remaining Genslip parameters to SRFConfig#93
Copilot wants to merge 2 commits intopegasusfrom
copilot/add-genslip-parameters

Conversation

Copy link

Copilot AI commented Mar 2, 2026

The codebase exposed only a small subset of genslip v5.6.2 parameters. This adds the full parameter set with correct defaults extracted from the genslip source.

Changes

  • defaults.yaml: ~90 new parameters added under srf:, grouped by category (rise time, hybrid correlation length, rupture velocity, tapering, time shift factors, kinematic models, roughness/wavelength, miscellaneous, aseismic)
  • schemas.py: SRF_SCHEMA extended with validators for all new fields
  • realisations.py: SRFConfig dataclass extended with typed fields and docstrings for all new parameters
  • Tests: test_srf_config_example and test_build_genslip_command_static_args updated to cover all new fields

Design decisions

Genslip type Python type Notes
0/1 flags bool Serialised as 0/1 in command
-1, -999, 1e15 sentinels None Skipped by _build_genslip_command
Integer indices (kmodel, kord) float Schema NUMBER coerces to float; passed as 2.0 etc.
Optional file paths str | None Skipped when None

All new parameters flow through the existing _build_genslip_command serialisation loop without modification.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add remaining Genslip parameters into the codebase</issue_title>
<issue_description>Currently we expose a limited subset of genslip parameters in the code base, but we could do to add the rest. Here are the default values in YAML format that I have extracted from genslip_v5.6.2.c:

# Rise time and source time function values
beta_asp: 0.3
beta_deep: 0.13
beta_mid: 0.13
beta_mid_depth: 6.5
beta_mid_depth_range: 1.5
beta_shal: 0.5
beta_shal_depth: 2.0
beta_shal_depth_range: 1.0
beta_subevt: 0.1
deep_risetimedep: 17.5
deep_risetimedep_range: 2.5
deep_risetimefac: 2.0
risetime_coef: 1.6
risetimedep: DEFAULT_DEPTH_SCALING_LEVEL
risetimedep_range: DEFAULT_DEPTH_SCALING_RANGE
risetimefac: 2.0
rt_rand: 0.0
rt_scalefac: DEFAULT_RT_SCALEFAC
stype: null

# Hybrid Correlation Length (hyb_corlen) Parameters
hyb_corlen_deep_wt_end: 1.0
hyb_corlen_deep_wt_start: 0.0
hyb_corlen_dep: DEFAULT_DEPTH_SCALING_LEVEL
hyb_corlen_dep_range: DEFAULT_DEPTH_SCALING_RANGE
hyb_corlen_fac: 2.0
hyb_corlen_flag: 0
hyb_corlen_kmodel: 5
hyb_corlen_shal_wt_end: 0.0
hyb_corlen_shal_wt_start: 1.0
hyb_corlen_side_taper: 0.08

# Rupture Velocity & Fault Dimensions
fdrup_scale_slip: 0
fdrup_time: 0
rupture_delay: 0.0
rvfmax: 1.414
rvfmin: 0.25
rvfrac_slip_sig: -1.0

# Tapering & Slip Level Adjustments
truncate_zero_slip: DEFAULT_TRUNCATE_ZERO_SLIP
slip_water_level: -1.0
slip_sigma: DEFAULT_SLIP_SIGMA
rake_sigma: 15.0
fractal_rake: 0

# Time Shift Factors (tsfac)
tsfac1_scor: 0.8
tsfac1_sigma: 1.0
tsfac2_lambda_max: 5.0
tsfac2_lambda_min: -1.0
tsfac2_scor: 0.5
tsfac2_sigma: 1.0
tsfac_bzero: -0.1
tsfac_coef: 1.1
tsfac_main: -1.0e+15
tsfac_slope: -0.5

# Kinematic Models & Corner Frequencies
circular_average: DEFAULT_CIRCULAR_AVERAGE
kmodel: MAI_FLAG
kord: 4
kx_corner: null
ky_corner: null
magC: 6.3
mag_area_Acoef: -1.0
mag_area_Bcoef: -1.0
mai_wt: 0.5
modified_corners: DEFAULT_MODIFIED_CORNERS
somerville_wt: 0.5
stretch_kcorner: DEFAULT_STRETCH_KCORNER
use_gaus: 1
use_median_mag: 0
xmag_exponent: 0.5
ymag_exponent: 0.5

# Roughness & Wavelength Limits
alpha_rough: -1.0
lambda_max: -1.0
lambda_min: -1.0
roughnessfile: null
wavelength_max: 1.0e+15
wavelength_min: -1.0

# Miscellaneous Slip/Rupture/Rake Vars
asp_taper_fac: 0.05
extend_fac: -1.0
flen_max: -1.0
fwid_max: -1.0
init_slip_file: null
moment_fraction: -1.0
perturb_subfault_location: 1
rand_rake_degs: DEFAULT_RAND_RAKE_DEGS
read_slip_file: 0
rtime1_depth: 2.0
rtime1_depth_range: 1.0
rtime1_scor: 0.8
rtime1_sigma: DEFAULT_SLIP_SIGMA
rtime2_scor: 0.5
rtime2slip_exp: 0.5
rtime_rand: -1.0
set_rake: -999.0
svr_wt: 0
target_savg: -1.0
use_Mw: 1

# Aseismic & Segment Settings
aseis_flag: 0
aseis_smooth: 0
aseis_dep: 10.0
aseis_fac: -1.0
xshift: 0.0
yshift: 0.0

The tasks to complete this feature would be as follows:

  1. Add this YAML block into the root defaults.yaml file: here.
  2. Update the schema in schemas.py: here.
  3. Check that genslip is correctly supplied with these values by running realisation-to-srf with an input realisation. You could probably steal one from Cesar or Ayushi and update it using the migration tool on your new branch. The genslip command is built automatically from the realisation config in _build_genslip_command.
  4. Update the test cases in tests/test_realisation_to_srf.py and tests/test_realisation.py to include these new defaults.
    </issue_description>

<agent_instructions>You may use these defaults for named constants
#define DEFAULT_DHYPO_FRAC 0.75 /* hypo at 0.75 down-dip width /
#define DEFAULT_SHYPO_STEP 20.0 /
hypo spacing at 20 km along strike /
#define DEFAULT_SHYPO_MIN_OFF 1.0 /
hypos start at 1.0 km along strike /
#define DEFAULT_SLIPS_TO_HYPOS 2 /
#slip models = 2 times #hypos */

#define DEFAULT_DT 0.1
#define NTMAX 10000
#define SOMERVILLE_FLAG 1
#define MAI_FLAG 2
#define INPUT_CORNERS_FLAG -1
#define MINSLIP 1.0e-02

#define DEFAULT_KMODEL 2
#define DEFAULT_FLIP_AT_SURFACE 1
#define DEFAULT_STRETCH_KCORNER 0
#define DEFAULT_CIRCULAR_AVERAGE 0
#define DEFAULT_MODIFIED_CORNERS 0
#define DEFAULT_TRUNCATE_ZERO_SLIP 1
#define DEFAULT_RAND_RAKE_DEGS 60.0
#define DEFAULT_SLIP_SIGMA 0.85

#define DEFAULT_TSFAC -0.5
#define DEFAULT_TSFAC_COEF 1.8
#define DEFAULT_TSFAC_FACTOR 1

#define DEFAULT_RT_SCALEFAC 1

#define DEFAULT_VR_TO_VS_FRAC 0.8 /* vrup = 0.8 times local Vs /
#define DEFAULT_SHAL_VRUP_FRAC 0.7 /
shallow_vrup...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…tests

Co-authored-by: lispandfound <12835929+lispandfound@users.noreply.github.com>
Copilot AI changed the title [WIP] Add remaining Genslip parameters into the codebase Add remaining Genslip parameters to SRFConfig Mar 2, 2026
@lispandfound lispandfound self-requested a review March 2, 2026 21:51
@lispandfound
Copy link
Contributor

Testing Instructions

To test that your defaults are validated by your schema:

  1. Install the "test" optional dependencies,
  2. Run pytest tests/test_realisation.py::test_defaults_are_loadable.

There are a couple of tests that use the SRFConfig block, the relevant tests are test_realisation_to_srf.py and test_realisation.py::test_srf_config_example.

Comment on lines +671 to +674
Literal(
"kmodel",
description="Kinematic model index: 1=SOMERVILLE_FLAG, 2=MAI_FLAG, -1=INPUT_CORNERS_FLAG.",
): And(NUMBER, _is_positive),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an Enum. Definitely not a float.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like:

class KModel(Enum):
    SOMERVILLE = 1
    MAI = 2
    FRANKEL = 3
    MAI_SOMERVILLE 4
    SUZUKI = 5
    INPUT_CORNERS = -1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use(KModel)

Not, And(NUMBER, _is_positive)

Comment on lines +724 to +727
Literal(
"roughnessfile",
description="Path to roughness file (null = no file).",
): Or(str, None),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this, it should be passed as a command line argument (at a later date). Make sure it is removed from the tests and yaml defaults as well.

Comment on lines +538 to +541
Literal(
"stype",
description="Slip time function type for genslip (null = use genslip default).",
): Or(str, None),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the SType StrEnum that Andrew wrote.

Comment on lines +596 to +607
Literal(
"rvfmax",
description="Maximum rupture velocity fraction.",
): And(NUMBER, _is_positive),
Literal(
"rvfmin",
description="Minimum rupture velocity fraction.",
): And(NUMBER, _is_positive),
Literal(
"rvfrac_slip_sig",
description="Rupture velocity fraction slip sigma (null = disabled).",
): Or(NUMBER, None),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be moved to RuptureVelocity config (because they may be synced with HF rupture velocity values at a later date).

Comment on lines +753 to +756
Literal(
"init_slip_file",
description="Path to initial slip file (null = no file).",
): Or(str, None),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be a command line argument (we will add it at a later date). So this default should be removed.

Literal(
"hyb_corlen_kmodel",
description="Hybrid correlation length k-model index.",
): And(NUMBER, _is_positive),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
): And(NUMBER, _is_positive),
): Use(KModel),

hyb_corlen_dep_range=1.5,
hyb_corlen_fac=2.0,
hyb_corlen_flag=False,
hyb_corlen_kmodel=5.0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hyb_corlen_kmodel=5.0,
hyb_corlen_kmodel=KModel.SUZUKI,

"hyb_corlen_dep_range": 1.5,
"hyb_corlen_fac": 2.0,
"hyb_corlen_flag": False,
"hyb_corlen_kmodel": 5.0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"hyb_corlen_kmodel": 5.0,
"hyb_corlen_kmodel": KModel.SUZUKI,

hyb_corlen_dep_range=1.5,
hyb_corlen_fac=2.0,
hyb_corlen_flag=False,
hyb_corlen_kmodel=5.0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hyb_corlen_kmodel=5.0,
hyb_corlen_kmodel=KModel.SUZUKI,

"hyb_corlen_dep_range=1.5",
"hyb_corlen_fac=2.0",
"hyb_corlen_flag=0",
"hyb_corlen_kmodel=5.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"hyb_corlen_kmodel=5.0",
"hyb_corlen_kmodel=KModel.SUZUKI",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add remaining Genslip parameters into the codebase

3 participants