|
13 | 13 | import pandas as pd |
14 | 14 | import xarray as xr |
15 | 15 |
|
| 16 | +import forecasttools |
| 17 | + |
16 | 18 | # %% DEMONSTRATION OF EXPECTED BEHAVIOR |
17 | 19 |
|
18 | | -obs_data = np.random.normal(loc=0, scale=1, size=(1,)) |
| 20 | +num_days = 1 |
| 21 | +obs_data = np.random.normal(loc=0, scale=1, size=(num_days,)) |
19 | 22 | obs_dim_name = "obs_dim_0" |
20 | 23 | start_date = "2023-01-01" |
21 | 24 | interval_dates = pd.date_range(start=start_date, periods=1, freq="D") |
22 | 25 | obs_group = xr.Dataset( |
23 | | - {"obs": ([obs_dim_name], obs_data)}, coords={obs_dim_name: np.arange(1)} |
| 26 | + {"obs": ([obs_dim_name], obs_data)}, |
| 27 | + coords={obs_dim_name: np.arange(num_days)}, |
24 | 28 | ) |
25 | 29 | idata = az.from_dict(observed_data={"obs": obs_group["obs"].values}) |
26 | 30 | idata.observed_data = idata.observed_data.assign_coords( |
27 | 31 | {obs_dim_name: interval_dates} |
28 | 32 | ) |
29 | | -df = idata.observed_data.to_dataframe() |
30 | | -print(df) |
| 33 | +obs_df = idata.observed_data.to_dataframe() |
| 34 | +print(obs_df) |
31 | 35 |
|
32 | | -# %% FAILED EXAMPLE |
| 36 | +# %% FAILED? EXAMPLE |
33 | 37 |
|
34 | 38 |
|
35 | 39 | def convert_date_or_datetime_to_np( |
@@ -115,7 +119,15 @@ def generate_time_range_for_dim( |
115 | 119 | idata.observed_data = idata.observed_data.assign_coords( |
116 | 120 | {obs_dim_name: interval_dates} |
117 | 121 | ) |
118 | | -df = idata.observed_data.to_dataframe() |
119 | | -print(df) |
| 122 | +obs_df = idata.observed_data.to_dataframe() |
| 123 | +print(obs_df) |
| 124 | + |
| 125 | +# %% FINAL EXAMPLE |
| 126 | + |
| 127 | +idata_w_dates = forecasttools.nhsn_flu_forecast_w_dates |
| 128 | +obs_df = idata_w_dates.observed_data.to_dataframe() |
| 129 | +print(obs_df) |
| 130 | +idata_df = idata_w_dates.to_dataframe() |
| 131 | +print(idata_df.columns) |
120 | 132 |
|
121 | 133 | # %% |
0 commit comments