GNS-Science / nzshm-model

logic tree definition and changelog for the New Zealand NSHM
1 stars 2 forks source link

oq_build_sites.py #96

Closed chrisdicaprio closed 2 months ago

chrisdicaprio commented 3 months ago
chrisdicaprio commented 2 months ago

proposed API:

Option1

from nzshm_model import get_model_version()
sites = ["WLG, "-40~175", "NZ"]
model = get_model_version("NSHM_v1.0.4")
model.hazard_config.set_sites(sites)

Option2

from nzshm_model import get_model_version()
from nzshm_common.location.location import get_locations
sites = ["WLG, "-40~175", "NZ"]
locations = get_locations(sites)  # type: CodedLocation
vs30s = [100, 200, 400, ...]
model = get_model_version("NSHM_v1.0.4")
model.hazard_config.set_sites(sites, vs30s)

# single vs30
vs30 = 400
model.hazard_config.set_sites(sites, vs30)  # all sites have same vs30

Will need to coordinate w/ vs30 setting of config. Will need to set z1p0 and z2p5 as well as vs30 for individual sites

What about backarc flag? --> set same as vs30, make it up to user to control (I would leverage common)

def set_sites(
    locations: Iterable[CodedLocation],
    vs30s: Optional[Union[int, Iterable[int]]],
    backarc_flag: Optional[Union[bool, Iterable[bool]]]
):

Because there are a large number of possible site parameters (https://docs.openquake.org/oq-engine/manual/latest/user-guide/inputs/site-model-inputs.html), perhaps it is best to use a dict or keyword args

def set_sites(locations: Iterable[CodedLocation], **kwargs):

Any kwargs that are scalers are set for every site, anything that is an iterable is set in order of the locations