|
45 | 45 | from iris.config import get_logger
|
46 | 46 | import iris.fileformats.cf
|
47 | 47 | import iris.fileformats.pp as pp
|
| 48 | +from iris.loading import LOAD_PROBLEMS |
48 | 49 | import iris.warnings
|
49 | 50 |
|
50 | 51 | from . import helpers as hh
|
@@ -104,6 +105,10 @@ def inner(engine, *args, **kwargs):
|
104 | 105 | @action_function
|
105 | 106 | def action_default(engine):
|
106 | 107 | """Perform standard operations for every cube."""
|
| 108 | + # Future pattern (iris#6319). |
| 109 | + hh.build_and_add_names(engine) |
| 110 | + |
| 111 | + # Legacy pattern. |
107 | 112 | hh.build_cube_metadata(engine)
|
108 | 113 |
|
109 | 114 |
|
@@ -286,6 +291,7 @@ def action_build_dimension_coordinate(engine, providescoord_fact):
|
286 | 291 | cf_var = engine.cf_var.cf_group[var_name]
|
287 | 292 | rule_name = f"fc_build_coordinate_({coord_type})"
|
288 | 293 | coord_grid_class, coord_name = _COORDTYPE_GRIDTYPES_AND_COORDNAMES[coord_type]
|
| 294 | + succeed = None |
289 | 295 | if coord_grid_class is None:
|
290 | 296 | # Coordinates not identified with a specific grid-type class (latlon,
|
291 | 297 | # rotated or projected) are always built, but can have no coord-system.
|
@@ -367,9 +373,28 @@ def action_build_dimension_coordinate(engine, providescoord_fact):
|
367 | 373 | assert coord_grid_class in grid_classes
|
368 | 374 |
|
369 | 375 | if succeed:
|
370 |
| - hh.build_dimension_coordinate( |
| 376 | + hh.build_and_add_dimension_coordinate( |
371 | 377 | engine, cf_var, coord_name=coord_name, coord_system=coord_system
|
372 | 378 | )
|
| 379 | + |
| 380 | + else: |
| 381 | + message = f"Dimension coordinate {var_name} not created. Debug info:\n" |
| 382 | + if succeed is None: |
| 383 | + message += "An unexpected error occurred" |
| 384 | + error = NotImplementedError(message) |
| 385 | + else: |
| 386 | + message += rule_name |
| 387 | + error = ValueError(message) |
| 388 | + |
| 389 | + try: |
| 390 | + raise error |
| 391 | + except error.__class__ as error: |
| 392 | + _ = LOAD_PROBLEMS.record( |
| 393 | + filename=engine.filename, |
| 394 | + loaded=hh.build_raw_cube(cf_var, engine.filename), |
| 395 | + exception=error, |
| 396 | + ) |
| 397 | + |
373 | 398 | return rule_name
|
374 | 399 |
|
375 | 400 |
|
|
0 commit comments