|
59 | 59 | ] |
60 | 60 |
|
61 | 61 |
|
62 | | -def create_viewer(root_dir, parameters): |
| 62 | +def create_viewer(root_dir, parameters): # noqa: C901 |
63 | 63 | """ |
64 | 64 | Given a set of parameters for a certain set of diagnostics, |
65 | 65 | create a single page. |
@@ -99,7 +99,16 @@ def create_viewer(root_dir, parameters): |
99 | 99 | # ref_name-variable-plev'mb'-season-region |
100 | 100 | ref_name = getattr(parameter, "ref_name", "") |
101 | 101 | for var in parameter.variables: |
102 | | - for season in parameter.seasons: |
| 102 | + # Handle either seasons or time_slices |
| 103 | + time_periods = ( |
| 104 | + parameter.time_slices |
| 105 | + if ( |
| 106 | + hasattr(parameter, "time_slices") and len(parameter.time_slices) > 0 |
| 107 | + ) |
| 108 | + else parameter.seasons |
| 109 | + ) |
| 110 | + |
| 111 | + for season in time_periods: |
103 | 112 | for region in parameter.regions: |
104 | 113 | # Since some parameters have plevs, there might be |
105 | 114 | # more than one row_name, filename pair. |
@@ -177,10 +186,25 @@ def create_viewer(root_dir, parameters): |
177 | 186 | "..", "{}".format(set_name), parameter.case_id, fnm |
178 | 187 | ) |
179 | 188 | print( |
180 | | - os.path.join( |
| 189 | + f"DEBUG VIEWER: var={var}, season={season}, region={region}" |
| 190 | + ) |
| 191 | + print(f"DEBUG VIEWER: fnm={fnm}") |
| 192 | + print( |
| 193 | + "DEBUG VIEWER: expected_path=" |
| 194 | + + os.path.join( |
181 | 195 | "..", "{}".format(set_name), parameter.case_id, fnm |
182 | 196 | ) |
183 | 197 | ) |
| 198 | + |
| 199 | + # Check what files actually exist |
| 200 | + actual_dir = os.path.join( |
| 201 | + parameter.results_dir, set_name, parameter.case_id |
| 202 | + ) |
| 203 | + if os.path.exists(actual_dir): |
| 204 | + actual_files = os.listdir(actual_dir) |
| 205 | + print(f"DEBUG VIEWER: actual files: {actual_files}") |
| 206 | + else: |
| 207 | + print(f"DEBUG VIEWER: directory missing: {actual_dir}") |
184 | 208 | ROW_INFO[set_name][parameter.case_id][row_name][season][ |
185 | 209 | "metadata" |
186 | 210 | ] = create_metadata(parameter) |
@@ -224,11 +248,28 @@ def create_viewer(root_dir, parameters): |
224 | 248 |
|
225 | 249 | def seasons_used(parameters): |
226 | 250 | """ |
227 | | - Get a list of the seasons used for this set of parameters. |
| 251 | + Get a list of the seasons/time_slices used for this set of parameters. |
| 252 | + Supports either seasons OR time_slices (mutually exclusive). |
228 | 253 | """ |
229 | | - seasons_used = set([s for p in parameters for s in p.seasons]) |
230 | | - # Make sure this list is ordered by SEASONS. |
231 | | - return [season for season in SEASONS if season in seasons_used] |
| 254 | + # Check if any parameter uses time_slices |
| 255 | + uses_time_slices = any( |
| 256 | + hasattr(p, "time_slices") and len(p.time_slices) > 0 for p in parameters |
| 257 | + ) |
| 258 | + |
| 259 | + if uses_time_slices: |
| 260 | + # Collect all time slices |
| 261 | + time_slices_used = set() |
| 262 | + for p in parameters: |
| 263 | + if hasattr(p, "time_slices"): |
| 264 | + time_slices_used.update(p.time_slices) |
| 265 | + |
| 266 | + # Sort time slices for consistent ordering |
| 267 | + return sorted(time_slices_used) |
| 268 | + else: |
| 269 | + # Use standard seasons logic |
| 270 | + seasons_used = set([s for p in parameters for s in p.seasons]) |
| 271 | + # Make sure this list is ordered by SEASONS. |
| 272 | + return [season for season in SEASONS if season in seasons_used] |
232 | 273 |
|
233 | 274 |
|
234 | 275 | def _get_description(var, parameters): |
|
0 commit comments