forked from InstituteforDiseaseModeling/covasim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into serialInterval
- Loading branch information
Showing
39 changed files
with
960 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Covasim CI workflow | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build_and_push_docker: | ||
runs-on: ubuntu-latest | ||
name: Build and Publish Docker Image | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v1 | ||
|
||
- name: Set lowercase repo env variable | ||
shell: python | ||
run: print("::set-env name=LOWER_REPO::{}".format('${{github.repository}}'.lower())) | ||
- name: Build Docker | ||
run: | | ||
docker build -f docker/Dockerfile -t docker.pkg.github.com/${LOWER_REPO}/covasim:latest . | ||
- name: Push the image to GPR | ||
run: | | ||
docker login docker.pkg.github.com -u publisher -p "${GITHUB_PACKAGE_REGISTRY_TOKEN}" | ||
docker push docker.pkg.github.com/${LOWER_REPO}/covasim:latest | ||
env: | ||
GITHUB_PACKAGE_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .loaders import * |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
''' | ||
Load data | ||
''' | ||
|
||
#%% Housekeeping | ||
import numpy as np | ||
import sciris as sc | ||
from . import country_age_distributions as cad | ||
|
||
__all__ = ['get_age_distribution'] | ||
|
||
|
||
def get_age_distribution(location=None): | ||
''' | ||
Load age distribution for a given country or countries. | ||
Args: | ||
location (str or list): name of the country or countries to load the age distribution for | ||
Returns: | ||
age_data (array): Numpy array of age distributions | ||
''' | ||
|
||
# Load the raw data | ||
json = cad.get_country_age_distributions() | ||
countries = [entry["country"].lower() for entry in json] # Pull out available countries | ||
|
||
# Set parameters | ||
max_age = 99 | ||
if location is None: | ||
location = countries | ||
else: | ||
location = sc.promotetolist(location) | ||
|
||
# Define a mapping for common mistakes | ||
mapping = { | ||
'Bolivia': 'Bolivia (Plurinational State of)', | ||
'Burkina': 'Burkina Faso', | ||
'Cape Verde': 'Cabo Verdeo', | ||
'Hong Kong': 'China, Hong Kong Special Administrative Region', | ||
'Macao': 'China, Macao Special Administrative Region', | ||
"Cote d'Ivore": 'Côte d’Ivoire', | ||
'DRC': 'Democratic Republic of the Congo', | ||
'Iran': 'Iran (Islamic Republic of)', | ||
'Laos': "Lao People's Democratic Republic", | ||
'Micronesia': 'Micronesia (Federated States of)', | ||
'Korea': 'Republic of Korea', | ||
'South Korea': 'Republic of Korea', | ||
'Moldova': 'Republic of Moldova', | ||
'Russia': 'Russian Federation', | ||
'Palestine': 'State of Palestine', | ||
'Syria': 'Syrian Arab Republic', | ||
'Taiwan': 'Taiwan Province of China', | ||
'Macedonia': 'The former Yugoslav Republic of Macedonia', | ||
'UK': 'United Kingdom of Great Britain and Northern Ireland', | ||
'United Kingdom': 'United Kingdom of Great Britain and Northern Ireland', | ||
'Tanzania': 'United Republic of Tanzania', | ||
'USA': 'United States of America', | ||
'United States': 'United States of America', | ||
'Venezuela': 'Venezuela (Bolivarian Republic of)', | ||
'Vietnam': 'Viet Nam', | ||
} | ||
mapping = {key.lower():val.lower() for key,val in mapping.items()} # Convert to lowercase | ||
|
||
result = {} | ||
for loc in location: | ||
loc = loc.lower() | ||
if loc in mapping: | ||
loc = mapping[loc] | ||
try: | ||
ind = countries.index(loc.lower()) | ||
entry = json[ind] | ||
except ValueError: | ||
suggestions = sc.suggest(loc, countries, n=4) | ||
errormsg = f'Location "{loc}" not recognized, did you mean {suggestions}?' | ||
raise ValueError(errormsg) | ||
age_distribution = entry["ageDistribution"] | ||
total_pop = sum(age_distribution.values()) | ||
local_pop = [] | ||
|
||
for age, age_pop in age_distribution.items(): | ||
if age[-1] == '+': | ||
val = [int(age[:-1]), max_age, age_pop/total_pop] | ||
else: | ||
ages = age.split('-') | ||
val = [int(ages[0]), int(ages[1]), age_pop/total_pop] | ||
local_pop.append(val) | ||
result[loc] = np.array(local_pop) | ||
|
||
if len(location) == 1: | ||
result = result[loc] | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.