GNS-Science / kororaa-graphql-api

The graphql application API for NZHSM Kororaa.
GNU Affero General Public License v3.0
0 stars 0 forks source link

K-API Feature: IFM Analysis query #60

Closed chrisdicaprio closed 9 months ago

chrisdicaprio commented 1 year ago

We want an API query for logic tree components.

API examples:

note that value and value_options fields are encoded as JSON-String types. This is done because the types vary and this is not easily handled in graphql.

get Model options

using source_logic_tree_spec field we can find the options applicable to each fault system branch

query get_model_by_version {
  nzshm_model (version: "NSHM_1.0.0" ) {
    model {
      version
      title
      source_logic_tree_spec {
          fault_system_branches {
              short_name
              long_name
              branches {
                  name
                 long_name
                 value_options
              }
          }
       }
     }
   }
}

returns

{
  "data": {
    "nzshm_model": {
      "model": {
        "version": "NSHM_1.0.0",
        "title": "Initial version",
        "source_logic_tree_spec": {
          "fault_system_branches": [
            {
              "short_name": "PUY",
              "long_name": "Puysegur",
              "branches": [
                {
                  "name": "dm",
                  "long_name": "deformation model",
                  "value_options": "[\"0.7\"]"
                },
                {
                  "name": "bN",
                  "long_name": "bN pair",
                  "value_options": "[[0.902, 4.6]]"
                },
                {
                  "name": "C",
                  "long_name": "area-magnitude scaling",
                  "value_options": "[4.0]"
                },
                {
                  "name": "s",
                  "long_name": "moment rate scaling",
                  "value_options": "[0.28, 1.0, 1.72]"
                }
              ]
            },

... etc

2) get Source Logic Tree

using source_logic_tree field to obtain the complete SLT

query get_model_version {
  nzshm_model(version: "NSHM_1.0.0") {
    model {
      version
      title
      source_logic_tree {
        fault_system_branches {
          long_name
          short_name
          branches {
            weight
            inversion_solution_id
            inversion_solution_type
            onfault_nrml_id
            distributed_nrml_id
            values {
              long_name
              json_value
            }
          }
        }
      }
    }
  }
}

returns

{
  "data": {
    "nzshm_model": {
      "model": {
        "version": "NSHM_1.0.0",
        "title": "Initial version",
        "source_logic_tree": {
          "fault_system_branches": [
            {
              "long_name": "Puysegur",
              "short_name": "PUY",
              "branches": [
                {
                  "weight": 0.21,
                  "inversion_solution_id": "U2NhbGVkSW52ZXJzaW9uU29sdXRpb246MTE4NTQ2",
                  "inversion_solution_type": "ScaledInversionSolution",
                  "onfault_nrml_id": "SW52ZXJzaW9uU29sdXRpb25Ocm1sOjExODcxNw==",
                  "distributed_nrml_id": "RmlsZToxMzA3NTM=",
                  "values": [
                    {
                      "name": "dm",
                      "long_name": "deformation model",
                      "json_value": "\"0.7\""
                    },
                    {
                      "name": "bN",
                      "long_name": "bN pair",
                      "json_value": "[0.902, 4.6]"
                    },
                    {
                      "name": "C",
                      "long_name": "area-magnitude scaling",
                      "json_value": "4.0"
                    },
                    {
                      "name": "s",
                      "long_name": "moment rate scaling",
                      "json_value": "0.28"
                    }
                  ]
                },

etc...