GNS-Science/nzshm-model

demo: list the branch properties for a given model/branch_set

Closed this issue · 1 comments

We want a simple demo script the shows some simple interactions with a model, so that we can inform our user documentation work. Maybe this script can be in icluded in docs as example code ??

Done when:

  • new function in new module to easily obtain branches for a given model/branch_set (aka fault_system)
  • test module to verify the function behaviour
  • add example code using the function for our new user docs
  • add exception into test to catch the error of invalid arguments

based on real world example (Jack)

where we need to find the specific Ids, weights and tags for the crustal branches in NSHM_v1.0.4 ....

>>> for b in get_branch_set('CRU').branches:
...     print( b.inversion_solution_id, b.values )
...
U2NhbGVkSW52ZXJzaW9uU29sdXRpb246MTIwNzIy [dmgeodetic, tdFalse, bN[0.823, 2.7], C4.2, s0.66]
U2NhbGVkSW52ZXJzaW9uU29sdXRpb246MTIwNzE3 [dmgeodetic, tdFalse, bN[0.823, 2.7], C4.2, s1.0]
U2NhbGVkSW52ZXJzaW9uU29sdXRpb246MTIwNzQx [dmgeodetic, tdFalse, bN[0.823, 2.7], C4.2, s1.41]```
....

Pt 2. Make the branch_set argument more versatile

because these high-level helper functions should be flexible. So. of the users specifies a valid model_version, and

  • branch_set is Null (or an empty list), then => all the branches for all the branch_sets
  • a single branch_set = current behaviour => the branches for the single branch_set
  • a list of one or more branch_set => the branches for all matched branch_sets

Part 3 iterate the branches (not the branch_sets)

NB this was actually removed after migration as it was really just a demonstration/tutorial exercise.

we want to fully implement 1st 'done when' item...

  • to easily obtain branches for a given model/branch_set (aka fault_system)

here we need a function that generate the branches for the given model/ branch_set_filter ....

>>> for b in get_branches(model_version='"NSHM_V1.0.4", 'CRU'):
...     print( b.branch_set.short_name, b.inversion_solution_id, b.values,  )
...
PUY U2NhbGVkSW52ZXJzaW9uU29sdXRpb246MTIwNzIy [dmgeodetic, tdFalse, bN[0.823, 2.7], C4.2, s0.66]
PUY U2NhbGVkSW52ZXJzaW9uU29sdXRpb246MTIwNzE3 [dmgeodetic, tdFalse, bN[0.823, 2.7], C4.2, s1.0]

HIK = Hikurangi, CRU= Crustal, PUY = Puysegur