GNS-Science / simple-toshi-ui

basic react UI for Toshi API - experimental using react-relay
GNU Affero General Public License v3.0
0 stars 1 forks source link

Feature: add metadata component for Derived solutions to Filp Chart #401

Open chrisbc opened 2 years ago

chrisbc commented 2 years ago

When the user is using the GT FlipChart with Derived InversionSolutions (ie TimeDependent, Scaled, Aggregate) the meta tags component (not sure what it's really called) is not visible. I think it's because the meta tags are not directly attached to the derived solution.

So, for TD and Scaled solutions please modify the query so that the meta data is retrieved from the InversionSolution ancestor from predecessors and make the meta components visible.

NB I first thoguht to use source_solution, but this doesn't work when we have IS -> TDIS -> SIS (which is common now). So instead please use predecessors, which makes all the ancestors available, then choose the right one (based on __typename)

Done When

Sample query:

query predecessor_meta {
    node_SID:node(id:"U2NhbGVkSW52ZXJzaW9uU29sdXRpb246MTEzNjM0") {
    __typename
    ... on  ScaledInversionSolution {
      meta{k v}
      predecessors {
        __typename
        id
        relationship
        depth
        node {
          ... on File {
            file_meta:meta {k v}
          }
          ... on InversionSolution {
            is_meta:meta {k v}
          }
          ... on TimeDependentInversionSolution {
            td_meta:meta{k v}
          }
        }
      }
    }
  }
}

returns ...

  "data": {
    "node_SID": {
      "__typename": "ScaledInversionSolution",
      "meta": [
        {
          "k": "scale",
          "v": "1.54"
        },
        {
          "k": "polygon_scale",
          "v": "0.8"
        },
        {
          "k": "polygon_max_mag",
          "v": "8"
        },
        {
          "k": "model_type",
          "v": "CRUSTAL"
        }
      ],
      "predecessors": [
        {
          "typename": "TimeDependentInversionSolution",
          "id": "VGltZURlcGVuZGVudEludmVyc2lvblNvbHV0aW9uOjExMzU1Mg==",
          "relationship": "Parent",
          "depth": -1,
          "node": {
            "td_meta": [
              {
                "k": "current_year",
                "v": "2022"
              },
              {
                "k": "mre_enum",
                "v": "CFM_1_1"
              },
              {
                "k": "forecast_timespan",
                "v": "50"
              },
              {
                "k": "model_type",
                "v": "CRUSTAL"
              },
              {
                "k": "file_path",
                "v": "/work/chrisdc/NZSHM-WORKING/PROD/downloads/SW52ZXJzaW9uU29sdXRpb246MTA5ODUz/NZSHM22_InversionSolution-QXV0b21hdGlvblRhc2s6MTA1MTI0.zip"
              }
            ]
          }
        },
        {
          "typename": "InversionSolution",
          "id": "SW52ZXJzaW9uU29sdXRpb246MTA5ODUz",
          "relationship": "Grandparent",
          "depth": -2,
          "node": {
            "is_meta": [
              {
                "k": "round",
                "v": "0"
              },
              {
                "k": "config_type",
                "v": "crustal"
              },
              {
                "k": "deformation_model",
                "v": "GEOD_NO_PRIOR_2022_RmlsZToxMDAwODc_"
              },
              {
                "k": "rupture_set_file_id",
                "v": "RmlsZToxMDAwODc="
              },
              {
                "k": "rupture_set",
                "v": "/WORKING/downloads/RmlsZToxMDAwODc=/NZSHM22_RuptureSet-UnVwdHVyZUdlbmVyYXRpb25UYXNrOjEwMDAzOA==.zip"
              },
              {
                "k": "completion_energy",
                "v": "0.0"
              },
              {
                "k": "max_inversion_time",
                "v": "120"
              },
              {
                "k": "mfd_uncertainty_power",
                "v": "0.25"
              },
              {
                "k": "mfd_uncertainty_scalar",
                "v": "0.1"
              },
              {
                "k": "max_jump_distances",
                "v": "15"
              },
              {
                "k": "slip_uncertainty_scaling_factor",
                "v": "0"
              },
              {
                "k": "slip_use_scaling",
                "v": "0"
              },
              {
                "k": "enable_tvz_mfd",
                "v": "False"
              },
              {
                "k": "max_mag_type",
                "v": "MANIPULATE_MFD"
              },
              {
                "k": "min_mag_sans",
                "v": "6.8"
              },
              {
                "k": "min_mag_tvz",
                "v": "6.8"
              },
              {
                "k": "max_mag_sans",
                "v": "10.0"
              },
              {
                "k": "max_mag_tvz",
                "v": "10.0"
              },
              {
                "k": "mfd_mag_gt_5_sans",
                "v": "4.69"
              },
              {
                "k": "mfd_mag_gt_5_tvz",
                "v": "1.0"
              },
              {
                "k": "mfd_b_value_sans",
                "v": "1.079"
              },
              {
                "k": "mfd_b_value_tvz",
                "v": "1.0"
              },
              {
                "k": "mfd_transition_mag",
                "v": "7.85"
              },
              {
                "k": "sans_slip_rate_factor",
                "v": "0.9"
              },
              {
                "k": "tvz_slip_rate_factor",
                "v": "0.7"
              },
              {
                "k": "selection_interval_secs",
                "v": "1"
              },
              {
                "k": "threads_per_selector",
                "v": "4"
              },
              {
                "k": "averaging_threads",
                "v": "4"
              },
              {
                "k": "averaging_interval_secs",
                "v": "30"
              },
              {
                "k": "non_negativity_function",
                "v": "TRY_ZERO_RATES_OFTEN"
              },
              {
                "k": "perturbation_function",
                "v": "EXPONENTIAL_SCALE"
              },
              {
                "k": "cooling_schedule",
                "v": "FAST_SA"
              },
              {
                "k": "scaling_relationship",
                "v": "SIMPLE_CRUSTAL"
              },
              {
                "k": "scaling_recalc_mag",
                "v": "True"
              },
              {
                "k": "paleo_rate_constraint",
                "v": "PALEO_RI_GEODETIC_MAY24"
              },
              {
                "k": "paleo_probability_model",
                "v": "NZSHM22_C_42"
              },
              {
                "k": "paleo_parent_rate_smoothness_constraint_weight",
                "v": "100000.0"
              },
              {
                "k": "reweight",
                "v": "True"
              },
              {
                "k": "scaling_c_val_dip_slip",
                "v": "4.2"
              },
              {
                "k": "scaling_c_val_strike_slip",
                "v": "4.2"
              },
              {
                "k": "initial_solution_id",
                "v": ""
              },
              {
                "k": "spatial_seis_pdf",
                "v": "FLOOR_ADDOPTIEEPASCOMB_CRU"
              },
              {
                "k": "b_and_n",
                "v": "{'tag': 'N = 4.69, b=1.079', 'enable_tvz_mfd': False, 'b': 1.079, 'N': 4.69}"
              },
              {
                "k": "scaling_c",
                "v": "{'tag': '4.2', 'dip': 4.2, 'strike': 4.2}"
              },
              {
                "k": "constraint_wts",
                "v": "{'tag': 'MFDunc = 0.1, MFDpow = 0.25, Paleosmth = 1e5', 'reweight': True, 'mfd_pow': 0.25, 'mfd_unc_scalar': 0.1, 'sr_scaling': 0, 'sr_use_scaling': 0, 'paleo_smoothing': 100000.0}"
              },
              {
                "k": "mag_ranges",
                "v": "{'min_mag_sans': 6.8, 'min_mag_tvz': 6.8, 'max_mag_sans': 10.0, 'max_mag_tvz': 10.0}"
              },
              {
                "k": "slip_rate_factors",
                "v": "{'tag': 'Sans 0.9 TVZ 0.7', 'slip_factor_sans': 0.9, 'slip_factor_tvz': 0.7}"
              }
            ]
          }
        },
        {
          "typename": "File",
          "id": "RmlsZToxMDAwODc=",
          "relationship": "Great_Grandparent",
          "depth": -3,
          "node": {
            "file_meta": [
              {
                "k": "max_sections",
                "v": "2000"
              },
              {
                "k": "fault_model",
                "v": "CFM_1_0A_DOM_SANSTVZ"
              },
              {
                "k": "min_sub_sects_per_parent",
                "v": "2"
              },
              {
                "k": "min_sub_sections",
                "v": "2"
              },
              {
                "k": "max_jump_distance",
                "v": "15"
              },
              {
                "k": "adaptive_min_distance",
                "v": "6"
              },
              {
                "k": "thinning_factor",
                "v": "0"
              },
              {
                "k": "scaling_relationship",
                "v": "SIMPLE_CRUSTAL"
              },
              {
                "k": "depth_scaling_tvz",
                "v": "0.667"
              },
              {
                "k": "depth_scaling_sans",
                "v": "0.8"
              }
            ]
          }
        }
      ]
    }
  }
}