epidemics / covid

epidemicforcasting.org visualization repository
http://epidemicforecasting.org
GNU Affero General Public License v3.0
20 stars 12 forks source link

BUG: The "country-scenarios" link to Neherlab does not work #533

Closed gavento closed 4 years ago

gavento commented 4 years ago

Describe the bug The link from country-scenarios" to https://covid19-scenarios.org/ does not work properly: it ignores all the passed arguments and displays a generic US scenario. It seems the URL parameter schema at Neherlab has changed.

To Reproduce Steps to reproduce the behavior:

  1. Go to http://epidemicforecasting.org/country-scenarios
  2. Click on "Run Simulation"
  3. See that the page is not for the selected country
witzatom commented 4 years ago

Some additional info on how the generator was made.

I wrote this script to generate the scenarios.json file that we have in our repository.

import {scenarioNames, getScenario} from "../src/components/Main/state/getScenario"
import {ageDistributionNames, getAgeDistribution} from "../src/components/Main/state/getAgeDistribution"
import {scenarioNames as severityNames, getSeverityDistribution} from "../src/components/Main/state/getSeverityDistribution"
import {serialize} from "../src/components/Main/state/serialization/serialize"
import fs from 'fs';

let ageDistributionNamesSet: Set<string> = new Set(ageDistributionNames);
let commonNames = scenarioNames.filter(x => ageDistributionNamesSet.has(x));
let severityDefault = severityNames[0];

let supportedPresets: { [id: string]: any } = {};

commonNames.forEach((countryName) => {
    let countryData = {
      scenario: getScenario(countryName),
      scenarioName: countryName,
      ageDistribution: getAgeDistribution(countryName),
      ageDistributionName: countryName,
      severity: getSeverityDistribution(severityDefault),
      severityName: severityDefault,
    };
    //delete all interventions
    countryData.scenario.mitigation.mitigationIntervals = [];
    const serialized = serialize(countryData);
    supportedPresets[countryName] = JSON.parse(serialized);
  }
);

fs.writeFile('scenarios.json', JSON.stringify(supportedPresets), function (err) {
  if (err) return console.log(err);
  console.log('Scenario configs written to scenarios.json');
});

It is entirely possible all that has to be done to fix the incompatibility is to regenerate the scenarios.json. Its possible neherlabs added some parameter here or there.

It looks like the imports moved into the io folder: https://github.com/neherlab/covid19_scenarios/tree/b27f596dd26f3d4666718cbfa430db4007d8f88a/src/io so its possible that just by fixing that it might work. At a glance the actual serialization did not change.