Skip to content

Commit

Permalink
fix script
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosbosse committed Dec 10, 2024
1 parent e808f5a commit d904123
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions rsv/run-rsv-forecasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
import requests
from datetime import datetime, timedelta
import pandas as pd
import sys

sys.path.append("..")
from utils import internal_to_actual
import numpy as np


question_id = 30048
url = f"https://metaculus.com/api/posts/{question_id}"
response = requests.get(url).json()

# origin date is the first date of the week for that week's forecast (i.e. the Sunday before the submission due date).
today = datetime.now().date() # this is the submission due date, a Tuesday
today = datetime.now().date() - timedelta(
days=1
) # this is the submission due date, a Tuesday
days_until_sunday = (6 - today.weekday()) % 7 # 6 is Sunday
origin_date = today + timedelta(days=days_until_sunday) - timedelta(days=7)

Expand All @@ -31,7 +37,7 @@
# origin_date is always a Sunday, target_end_date is always a Saturday
horizon = ((target_end_date - origin_date).days + 1) // 7

if horizon not in [0, 1, 2, 3, 4, 5]:
if horizon not in [-1, 0, 1, 2, 3, 4, 5]:
continue

# obtain the scaling of the x-axis
Expand Down Expand Up @@ -69,7 +75,7 @@

forecasts_df = pd.concat(forecasts)

full_horizons = list(range(1, 5)) # NNEDS TO BE 1
full_horizons = list(range(0, 5)) # NEEDS TO BE 1
full_target_end_dates = [origin_date + timedelta(days=7 * h - 1) for h in full_horizons]

full_forecast_df = pd.DataFrame(
Expand Down Expand Up @@ -114,6 +120,9 @@
]
]

# filter horizons to 1, 2, 3, 4
forecasts_df_full = forecasts_df_full[forecasts_df_full["horizon"].isin([1, 2, 3, 4])]

forecasts_df_full.to_csv(
f"rsv/submissions-diagnostics/{origin_date}-Metaculus-cp.csv", index=False
)
Expand Down

0 comments on commit d904123

Please sign in to comment.