@@ -116,6 +116,8 @@ def get_data(
116116 else :
117117 points_per_sample = None
118118
119+ fsteps_final = fsteps
120+
119121 for fstep in fsteps :
120122 _logger .info (f"RUN { run_id } - { stream } : Processing fstep { fstep } ..." )
121123 da_tars_fs , da_preds_fs = [], []
@@ -135,6 +137,12 @@ def get_data(
135137 pred = bbox .apply_mask (pred )
136138
137139 npoints = len (target .ipoint )
140+ if npoints == 0 :
141+ _logger .info (
142+ f"Skipping { stream } sample { sample } forecast step: { fstep } . Dataset is empty."
143+ )
144+ fsteps_final .remove (fstep )
145+ continue
138146
139147 da_tars_fs .append (target .squeeze ())
140148 da_preds_fs .append (pred .squeeze ())
@@ -143,31 +151,37 @@ def get_data(
143151 _logger .debug (
144152 f"Concatenating targets and predictions for stream { stream } , forecast_step { fstep } ..."
145153 )
146- da_tars_fs = xr .concat (da_tars_fs , dim = "ipoint" )
147- da_preds_fs = xr .concat (da_preds_fs , dim = "ipoint" )
148154
149- if set (channels ) != set (all_channels ):
150- _logger .debug (
151- f"Restricting targets and predictions to channels { channels } for stream { stream } ..."
152- )
153- available_channels = da_tars_fs .channel .values
154- existing_channels = [ch for ch in channels if ch in available_channels ]
155- if len (existing_channels ) < len (channels ):
156- _logger .warning (
157- f"The following channels were not found: { list (set (channels ) - set (existing_channels ))} . Skipping them."
155+ if da_tars_fs :
156+ da_tars_fs = xr .concat (da_tars_fs , dim = "ipoint" )
157+ da_preds_fs = xr .concat (da_preds_fs , dim = "ipoint" )
158+
159+ if set (channels ) != set (all_channels ):
160+ _logger .debug (
161+ f"Restricting targets and predictions to channels { channels } for stream { stream } ..."
158162 )
163+ available_channels = da_tars_fs .channel .values
164+ existing_channels = [
165+ ch for ch in channels if ch in available_channels
166+ ]
167+ if len (existing_channels ) < len (channels ):
168+ _logger .warning (
169+ f"The following channels were not found: { list (set (channels ) - set (existing_channels ))} . Skipping them."
170+ )
159171
160- da_tars_fs = da_tars_fs .sel (channel = existing_channels )
161- da_preds_fs = da_preds_fs .sel (channel = existing_channels )
172+ da_tars_fs = da_tars_fs .sel (channel = existing_channels )
173+ da_preds_fs = da_preds_fs .sel (channel = existing_channels )
162174
163175 da_tars .append (da_tars_fs )
164176 da_preds .append (da_preds_fs )
165177 if return_counts :
166178 points_per_sample .loc [{"forecast_step" : fstep }] = np .array (pps )
167179
168180 # Safer than a list
169- da_tars = {fstep : da for fstep , da in zip (fsteps , da_tars , strict = False )}
170- da_preds = {fstep : da for fstep , da in zip (fsteps , da_preds , strict = False )}
181+ da_tars = {fstep : da for fstep , da in zip (fsteps_final , da_tars , strict = False )}
182+ da_preds = {
183+ fstep : da for fstep , da in zip (fsteps_final , da_preds , strict = False )
184+ }
171185
172186 return WeatherGeneratorOutput (
173187 target = da_tars , prediction = da_preds , points_per_sample = points_per_sample
@@ -396,6 +410,10 @@ def plot_data(
396410 da_tars = model_output .target
397411 da_preds = model_output .prediction
398412
413+ if not da_tars :
414+ _logger .info (f"Skipping Plot Data for { stream } . Targets are empty." )
415+ return
416+
399417 maps_config = common_ranges (da_tars , da_preds , plot_chs , maps_config )
400418
401419 plot_names = []
0 commit comments