Skip to content

Add mock scenario

jannisvisser edited this page Jan 17, 2025 · 3 revisions

GUIDE: Add or update mock scenarios

An integral part of any non-production environment is mock data. This guide explains how to add or update mock scenarios.

NOTE: The setup of the mock data aims to follow the structure of the API-calls being made from a pipeline, as detailed per disasterType there.

  • with most data being on event-basis
  • but some data also being across events, outside of event-loop.
  1. Mock data is
  • in the mock-data folder
  • then split by disasterType
  • then split by countryCodeISO3
  1. The countryCodeISO3 contains a scenarios.json (example MWI flash-floods)
  • which contains multiple scenarios:
  • REQUIRED: no-trigger scenario. This does not come with events.
    • This is the scenario that can be loaded from Portal as No trigger
    • And is loaded by mock/all when using triggered: false
  • REQUIRED: trigger scenario, this also has defaultScenario: true.
    • This is the scenario that can be loaded from Portal as Trigger
    • And is loaded by mock/all when using triggered: true
  • Any amount of other scenarios can be loaded here.
    • These can be separately loaded from Swagger Interface, but currently not from Portal.
  1. Each scenario (except no-trigger) has an events array with one or more events.
  • an event has an eventName, which can have certain restrictions
    • flash-floods: equal to admin-level 2 area name.
    • drought: equal to <regionName> <seasonName> as defined in droughtSeasonRegions of countries.json
    • floods: equal to Glofas station name or Glofas station code.
    • malaria: equal to leadTime (NOTE: this is a hacky use of events, and is up for refactor)
    • typhoon: no restrictions
  • and typically a leadTime
    • except for drought, where this is calculated based on current month
    • NOTE: ongoing event should be set by a 0-hour/0-day-0-month leadTime
  1. Per scenario create a folder matching the scenarioName
  • and in it, a folder per event matching the eventName, which contains:
    • json file per dynamic admin-area layer as defined in indicator-metadata.json
      • this file should only include those placeCodes that are part of the event.
    • json filer per dynamically updated points or lines layer (currently flash-floods only)
    • Additonally
      • for typhoon: add typhoon-track.json
      • for floods: add
        • glofas-station.json, contains only the station of this event
        • triggers-per-leadtime.json, contains trigger status for all leadTimes, thereby indicating duration/complete evolution of the event, instead of just the starting leadTime
      • for flash-floods: dynamic gauge data (if gauges layer present)
  • some data is additionally required overall, not per event:
    • floods: glofas-stations-no-trigger.json. This contains all stations not part of an event.
    • raster data: This data is also not per event, but is handled/placed differently because of it's data format. See 5. Mock raster data.
  1. Mock raster data
  • Raster data is handled via Geoserver
  • Mock raster data is placed in (gitignored) mock-output folder in raster-files folder.
  • Create a .tif file per dynamic raster layer.
  • Name format is
    • <layerName>_<leadTimeUnit>_<countryCodeISO3>, where leadTimeUnit is e.g. day/hour/month
    • UNLESS the mock setup requires different raster layers per leadTime, in which case replace leadTimeUnit by leadTime, e.g. 6-hour.
  • NOTE: the mock data file you use, should preferably be immediately of the correct bounding box for the country/region, as the Geoserver-layer that is created based on this data bases bounding box on this. So if you do not have the correct data yet, use another raster file of the same country as dummy, and not a copy of another country.
  • NOTE 2: Since this mock data is not part of the repo, you have to transfer it to remote environments separately.