Created
March 3, 2021 11:15
-
-
Save lewcpe/5e9946ca8105bbae101bda91a1d642ab to your computer and use it in GitHub Desktop.
Extract raw data from SputnikV paper
This file contains hidden or 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
PLACEBO_DATA = "h 12.837 v 1.644 h 2.57 v 0.82 h 2.56 v 0.82 h 2.57 v 2.464 h 2.569 v 1.639 h 7.699 v 0.82 h 2.569 v 1.639 h 2.569 v 1.644 h 2.562 v 1.639 h 2.568 v 0.82 h 2.57 v 0.825 h 2.561 v 4.103 h 2.569 v 1.639 h 2.569 v 1.64 h 2.569 v 1.671 h 2.561 v 2.556 h 2.57 v 3.451 h 2.568 v 2.62 h 5.13 v 3.597 h 2.57 v 2.723 h 2.569 v 0.906 h 2.569 v 1.822 h 2.561 v 3.645 h 2.569 v 0.911 h 2.569 v 2.745 h 2.561 v 1.827 h 2.569 v 2.75 h 2.569 v 3.666 h 5.131 v 0.923 h 2.568 v 0.922 h 2.569 v 0.922 h 2.57 v 1.849 h 5.13 v 2.782 h 2.57 v 1.855 h 2.568 v 0.933 h 2.562 v 1.866 h 2.569 v 0.932 h 7.698 v 0.944 h 2.57 v 2.863 h 2.569 v 2.879 h 7.699 v 1.041 h 2.569 v 1.073 h 7.7 v 1.191 h 2.569 v 2.454 h 7.698 v 1.396 h 2.57 v 1.462 h 2.561 v 3.084 h 2.569 35.935 2.569" | |
VACCINATED_DATA = "h 2.569 v 0.55 h 2.569 v 0.545 h 5.131 V 1.92 h 2.568 v 1.095 h 2.57 v 0.819 h 2.56 v 1.095 h 2.57 v 1.644 h 2.569 v 0.819 h 2.569 v 0.545 h 2.561 v 1.37 h 2.569 v 0.549 h 2.569 v 1.365 h 2.569 v 0.55 h 2.562 v 1.644 h 2.568 v 0.27 h 2.57 v 0.275 h 2.561 v 0.82 h 2.569 v 0.824 h 2.569 v 0.545 h 2.569 v 0.281 h 2.561 v 0.851 h 7.708 v 0.296 h 5.13 v 0.303 h 7.699 v 0.307 h 7.699 v 0.302 h 15.406 v 0.307 h 5.131 v 0.62 h 2.569 23.106 2.56 v 0.324 h 2.57 v 0.334 h 12.838 v 0.394 h 2.569 v 0.819 h 2.561 v 0.426 h 2.569 v 0.443 h 2.568 v 0.469 h 5.131 v 0.512 h 2.569 35.935 2.569" | |
CASE_HEIGHT_PLACEBO = 0.921 | |
CASE_HEIGHT_VACCINE = 0.306 | |
DAY_WIDTH = 2.56 | |
def parse_data(data): | |
ldata = data.lower().split() | |
filtered_ldata = list() | |
operation = "" | |
value = None | |
for token in ldata: | |
if token in ["h", "v"]: | |
if token == operation: | |
print("FATAL: Duplicated Operation") | |
exit() | |
if value is not None: | |
filtered_ldata.append((operation, value)) | |
operation = token | |
value = 0 | |
else: | |
cval = float(token) | |
value += cval | |
if value is not None: | |
filtered_ldata.append((operation, value)) | |
return filtered_ldata | |
def calc_oper(oper, data): | |
return sum(val for c_oper, val in data if c_oper == oper) | |
def calc_day_case(data, ref_height): | |
total_day = 0 | |
total_case = 0 | |
retdict = dict() | |
idx = 0 | |
while idx <= len(data) - 2: | |
day_oper, c_width = data[idx] | |
case_oper, c_height = data[idx+1] | |
idx += 2 | |
if day_oper != "h" or case_oper != "v": | |
print("FATAL: Wrong operation") | |
exit() | |
day_count = round(c_width / DAY_WIDTH) | |
case_count = round(c_height / ref_height) | |
total_day += day_count | |
total_case += case_count | |
retdict[total_day] = case_count | |
return total_day, total_case, retdict | |
if __name__ == "__main__": | |
parsed_placebo = parse_data(PLACEBO_DATA) | |
parsed_vaccinated = parse_data(VACCINATED_DATA) | |
print("TOTAL HEIGHT PLACEBO = ",calc_oper('v',parsed_placebo)) | |
print("TOTAL HEIGHT VACCINE = ",calc_oper('v',parsed_vaccinated)) | |
print(calc_day_case(parsed_vaccinated, CASE_HEIGHT_VACCINE)) | |
print(calc_day_case(parsed_placebo, CASE_HEIGHT_PLACEBO)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment