Skip to content

Commit e9541f9

Browse files
committed
make sure no empty dataframes
1 parent 07e15ca commit e9541f9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

flasc/analysis/expected_power_analysis_by.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,19 @@ def __init__(
119119
w_bins = df_[f"{wd_or_ws}_bin"].unique().sort().to_numpy()
120120

121121
# Initialize the results arrays
122-
energy_uplift_ctr_pc = np.zeros((len(uplift_pairs), len(w_bins)))
123-
energy_uplift_lb_pc = np.zeros((len(uplift_pairs), len(w_bins)))
124-
energy_uplift_ub_pc = np.zeros((len(uplift_pairs), len(w_bins)))
122+
energy_uplift_ctr_pc = np.zeros((len(uplift_pairs), len(w_bins))) * np.nan
123+
energy_uplift_lb_pc = np.zeros((len(uplift_pairs), len(w_bins))) * np.nan
124+
energy_uplift_ub_pc = np.zeros((len(uplift_pairs), len(w_bins))) * np.nan
125125

126126
# Loop over the wind (dir/speed) bins
127127
for w_idx, w_bin in enumerate(w_bins):
128128
# Make a subset a_in
129129
df_list_sub = [d[d[f"{wd_or_ws}_bin"] == w_bin] for d in df_list]
130+
131+
# If the subset is empty, or has less than num_blocks rows, skip
132+
if any([len(d) < num_blocks for d in df_list_sub]):
133+
continue
134+
130135
a_in_sub = AnalysisInput(df_list_sub, df_names, num_blocks)
131136

132137
# Run the analysis

0 commit comments

Comments
 (0)