|
21 | 21 | metadata_manager_factory, |
22 | 22 | ) |
23 | 23 | import iris.coords |
| 24 | +from iris.exceptions import IrisIgnoringBoundsWarning |
24 | 25 |
|
25 | 26 |
|
26 | 27 | class AuxCoordFactory(CFVariableMixin, metaclass=ABCMeta): |
@@ -441,7 +442,9 @@ def _check_dependencies(pressure_at_top, sigma, surface_air_pressure): |
441 | 442 | f"Coordinate '{coord.name()}' has bounds. These will " |
442 | 443 | "be disregarded" |
443 | 444 | ) |
444 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 445 | + warnings.warn( |
| 446 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 447 | + ) |
445 | 448 |
|
446 | 449 | # Check units |
447 | 450 | if sigma.units.is_unknown(): |
@@ -522,15 +525,17 @@ def make_coord(self, coord_dims_func): |
522 | 525 | if pressure_at_top.shape[-1:] not in [(), (1,)]: |
523 | 526 | warnings.warn( |
524 | 527 | "Pressure at top coordinate has bounds. These are being " |
525 | | - "disregarded" |
| 528 | + "disregarded", |
| 529 | + category=IrisIgnoringBoundsWarning, |
526 | 530 | ) |
527 | 531 | pressure_at_top_pts = nd_points_by_key["pressure_at_top"] |
528 | 532 | bds_shape = list(pressure_at_top_pts.shape) + [1] |
529 | 533 | pressure_at_top = pressure_at_top_pts.reshape(bds_shape) |
530 | 534 | if surface_air_pressure.shape[-1:] not in [(), (1,)]: |
531 | 535 | warnings.warn( |
532 | 536 | "Surface pressure coordinate has bounds. These are being " |
533 | | - "disregarded" |
| 537 | + "disregarded", |
| 538 | + category=IrisIgnoringBoundsWarning, |
534 | 539 | ) |
535 | 540 | surface_air_pressure_pts = nd_points_by_key[ |
536 | 541 | "surface_air_pressure" |
@@ -595,7 +600,9 @@ def __init__(self, delta=None, sigma=None, orography=None): |
595 | 600 | "Orography coordinate {!r} has bounds." |
596 | 601 | " These will be disregarded.".format(orography.name()) |
597 | 602 | ) |
598 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 603 | + warnings.warn( |
| 604 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 605 | + ) |
599 | 606 |
|
600 | 607 | self.delta = delta |
601 | 608 | self.sigma = sigma |
@@ -684,7 +691,7 @@ def make_coord(self, coord_dims_func): |
684 | 691 | warnings.warn( |
685 | 692 | "Orography coordinate has bounds. " |
686 | 693 | "These are being disregarded.", |
687 | | - UserWarning, |
| 694 | + category=IrisIgnoringBoundsWarning, |
688 | 695 | stacklevel=2, |
689 | 696 | ) |
690 | 697 | orography_pts = nd_points_by_key["orography"] |
@@ -739,7 +746,9 @@ def update(self, old_coord, new_coord=None): |
739 | 746 | "Orography coordinate {!r} has bounds." |
740 | 747 | " These will be disregarded.".format(new_coord.name()) |
741 | 748 | ) |
742 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 749 | + warnings.warn( |
| 750 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 751 | + ) |
743 | 752 | self.orography = new_coord |
744 | 753 |
|
745 | 754 |
|
@@ -806,7 +815,9 @@ def _check_dependencies(delta, sigma, surface_air_pressure): |
806 | 815 | "Surface pressure coordinate {!r} has bounds. These will" |
807 | 816 | " be disregarded.".format(surface_air_pressure.name()) |
808 | 817 | ) |
809 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 818 | + warnings.warn( |
| 819 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 820 | + ) |
810 | 821 |
|
811 | 822 | # Check units. |
812 | 823 | if sigma is not None and sigma.units.is_unknown(): |
@@ -898,7 +909,8 @@ def make_coord(self, coord_dims_func): |
898 | 909 | if surface_air_pressure.shape[-1:] not in [(), (1,)]: |
899 | 910 | warnings.warn( |
900 | 911 | "Surface pressure coordinate has bounds. " |
901 | | - "These are being disregarded." |
| 912 | + "These are being disregarded.", |
| 913 | + category=IrisIgnoringBoundsWarning, |
902 | 914 | ) |
903 | 915 | surface_air_pressure_pts = nd_points_by_key[ |
904 | 916 | "surface_air_pressure" |
@@ -1012,7 +1024,9 @@ def _check_dependencies(sigma, eta, depth, depth_c, nsigma, zlev): |
1012 | 1024 | "The {} coordinate {!r} has bounds. " |
1013 | 1025 | "These are being disregarded.".format(term, coord.name()) |
1014 | 1026 | ) |
1015 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1027 | + warnings.warn( |
| 1028 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1029 | + ) |
1016 | 1030 |
|
1017 | 1031 | for coord, term in ((depth_c, "depth_c"), (nsigma, "nsigma")): |
1018 | 1032 | if coord is not None and coord.shape != (1,): |
@@ -1187,7 +1201,9 @@ def make_coord(self, coord_dims_func): |
1187 | 1201 | "The {} coordinate {!r} has bounds. " |
1188 | 1202 | "These are being disregarded.".format(key, name) |
1189 | 1203 | ) |
1190 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1204 | + warnings.warn( |
| 1205 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1206 | + ) |
1191 | 1207 | # Swap bounds with points. |
1192 | 1208 | bds_shape = list(nd_points_by_key[key].shape) + [1] |
1193 | 1209 | bounds = nd_points_by_key[key].reshape(bds_shape) |
@@ -1268,7 +1284,9 @@ def _check_dependencies(sigma, eta, depth): |
1268 | 1284 | "The {} coordinate {!r} has bounds. " |
1269 | 1285 | "These are being disregarded.".format(term, coord.name()) |
1270 | 1286 | ) |
1271 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1287 | + warnings.warn( |
| 1288 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1289 | + ) |
1272 | 1290 |
|
1273 | 1291 | # Check units. |
1274 | 1292 | if sigma is not None and sigma.units.is_unknown(): |
@@ -1349,7 +1367,9 @@ def make_coord(self, coord_dims_func): |
1349 | 1367 | "The {} coordinate {!r} has bounds. " |
1350 | 1368 | "These are being disregarded.".format(key, name) |
1351 | 1369 | ) |
1352 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1370 | + warnings.warn( |
| 1371 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1372 | + ) |
1353 | 1373 | # Swap bounds with points. |
1354 | 1374 | bds_shape = list(nd_points_by_key[key].shape) + [1] |
1355 | 1375 | bounds = nd_points_by_key[key].reshape(bds_shape) |
@@ -1444,7 +1464,9 @@ def _check_dependencies(s, c, eta, depth, depth_c): |
1444 | 1464 | "The {} coordinate {!r} has bounds. " |
1445 | 1465 | "These are being disregarded.".format(term, coord.name()) |
1446 | 1466 | ) |
1447 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1467 | + warnings.warn( |
| 1468 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1469 | + ) |
1448 | 1470 |
|
1449 | 1471 | if depth_c is not None and depth_c.shape != (1,): |
1450 | 1472 | msg = ( |
@@ -1543,7 +1565,9 @@ def make_coord(self, coord_dims_func): |
1543 | 1565 | "The {} coordinate {!r} has bounds. " |
1544 | 1566 | "These are being disregarded.".format(key, name) |
1545 | 1567 | ) |
1546 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1568 | + warnings.warn( |
| 1569 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1570 | + ) |
1547 | 1571 | # Swap bounds with points. |
1548 | 1572 | bds_shape = list(nd_points_by_key[key].shape) + [1] |
1549 | 1573 | bounds = nd_points_by_key[key].reshape(bds_shape) |
@@ -1637,7 +1661,9 @@ def _check_dependencies(s, eta, depth, a, b, depth_c): |
1637 | 1661 | "The {} coordinate {!r} has bounds. " |
1638 | 1662 | "These are being disregarded.".format(term, coord.name()) |
1639 | 1663 | ) |
1640 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1664 | + warnings.warn( |
| 1665 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1666 | + ) |
1641 | 1667 |
|
1642 | 1668 | coords = ((a, "a"), (b, "b"), (depth_c, "depth_c")) |
1643 | 1669 | for coord, term in coords: |
@@ -1740,7 +1766,9 @@ def make_coord(self, coord_dims_func): |
1740 | 1766 | "The {} coordinate {!r} has bounds. " |
1741 | 1767 | "These are being disregarded.".format(key, name) |
1742 | 1768 | ) |
1743 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1769 | + warnings.warn( |
| 1770 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1771 | + ) |
1744 | 1772 | # Swap bounds with points. |
1745 | 1773 | bds_shape = list(nd_points_by_key[key].shape) + [1] |
1746 | 1774 | bounds = nd_points_by_key[key].reshape(bds_shape) |
@@ -1839,7 +1867,9 @@ def _check_dependencies(s, c, eta, depth, depth_c): |
1839 | 1867 | "The {} coordinate {!r} has bounds. " |
1840 | 1868 | "These are being disregarded.".format(term, coord.name()) |
1841 | 1869 | ) |
1842 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1870 | + warnings.warn( |
| 1871 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1872 | + ) |
1843 | 1873 |
|
1844 | 1874 | if depth_c is not None and depth_c.shape != (1,): |
1845 | 1875 | msg = ( |
@@ -1938,7 +1968,9 @@ def make_coord(self, coord_dims_func): |
1938 | 1968 | "The {} coordinate {!r} has bounds. " |
1939 | 1969 | "These are being disregarded.".format(key, name) |
1940 | 1970 | ) |
1941 | | - warnings.warn(msg, UserWarning, stacklevel=2) |
| 1971 | + warnings.warn( |
| 1972 | + msg, category=IrisIgnoringBoundsWarning, stacklevel=2 |
| 1973 | + ) |
1942 | 1974 | # Swap bounds with points. |
1943 | 1975 | bds_shape = list(nd_points_by_key[key].shape) + [1] |
1944 | 1976 | bounds = nd_points_by_key[key].reshape(bds_shape) |
|
0 commit comments