|
11 | 11 | from abc import ABCMeta, abstractmethod
|
12 | 12 | import warnings
|
13 | 13 |
|
| 14 | +import cf_units |
14 | 15 | import dask.array as da
|
15 | 16 | import numpy as np
|
16 | 17 |
|
@@ -619,6 +620,10 @@ def _check_dependencies(delta, sigma, surface_air_pressure):
|
619 | 620 | warnings.warn(msg, UserWarning, stacklevel=2)
|
620 | 621 |
|
621 | 622 | # Check units.
|
| 623 | + if sigma is not None and sigma.units.is_unknown(): |
| 624 | + # Be graceful, and promote unknown to dimensionless units. |
| 625 | + sigma.units = cf_units.Unit("1") |
| 626 | + |
622 | 627 | if sigma is not None and not sigma.units.is_dimensionless():
|
623 | 628 | raise ValueError("Invalid units: sigma must be dimensionless.")
|
624 | 629 | if (
|
@@ -863,6 +868,10 @@ def _check_dependencies(sigma, eta, depth, depth_c, nsigma, zlev):
|
863 | 868 | )
|
864 | 869 | raise ValueError(msg)
|
865 | 870 |
|
| 871 | + if sigma is not None and sigma.units.is_unknown(): |
| 872 | + # Be graceful, and promote unknown to dimensionless units. |
| 873 | + sigma.units = cf_units.Unit("1") |
| 874 | + |
866 | 875 | if sigma is not None and not sigma.units.is_dimensionless():
|
867 | 876 | msg = (
|
868 | 877 | "Invalid units: sigma coordinate {!r} "
|
@@ -1127,6 +1136,10 @@ def _check_dependencies(sigma, eta, depth):
|
1127 | 1136 | warnings.warn(msg, UserWarning, stacklevel=2)
|
1128 | 1137 |
|
1129 | 1138 | # Check units.
|
| 1139 | + if sigma is not None and sigma.units.is_unknown(): |
| 1140 | + # Be graceful, and promote unknown to dimensionless units. |
| 1141 | + sigma.units = cf_units.Unit("1") |
| 1142 | + |
1130 | 1143 | if sigma is not None and not sigma.units.is_dimensionless():
|
1131 | 1144 | msg = (
|
1132 | 1145 | "Invalid units: sigma coordinate {!r} "
|
@@ -1335,6 +1348,10 @@ def _check_dependencies(s, c, eta, depth, depth_c):
|
1335 | 1348 | # Check units.
|
1336 | 1349 | coords = ((s, "s"), (c, "c"))
|
1337 | 1350 | for coord, term in coords:
|
| 1351 | + if coord is not None and coord.units.is_unknown(): |
| 1352 | + # Be graceful, and promote unknown to dimensionless units. |
| 1353 | + coord.units = cf_units.Unit("1") |
| 1354 | + |
1338 | 1355 | if coord is not None and not coord.units.is_dimensionless():
|
1339 | 1356 | msg = (
|
1340 | 1357 | "Invalid units: {} coordinate {!r} "
|
@@ -1551,6 +1568,10 @@ def _check_dependencies(s, eta, depth, a, b, depth_c):
|
1551 | 1568 | raise ValueError(msg)
|
1552 | 1569 |
|
1553 | 1570 | # Check units.
|
| 1571 | + if s is not None and s.units.is_unknown(): |
| 1572 | + # Be graceful, and promote unknown to dimensionless units. |
| 1573 | + s.units = cf_units.Unit("1") |
| 1574 | + |
1554 | 1575 | if s is not None and not s.units.is_dimensionless():
|
1555 | 1576 | msg = (
|
1556 | 1577 | "Invalid units: s coordinate {!r} "
|
@@ -1776,6 +1797,10 @@ def _check_dependencies(s, c, eta, depth, depth_c):
|
1776 | 1797 | # Check units.
|
1777 | 1798 | coords = ((s, "s"), (c, "c"))
|
1778 | 1799 | for coord, term in coords:
|
| 1800 | + if coord is not None and coord.units.is_unknown(): |
| 1801 | + # Be graceful, and promote unknown to dimensionless units. |
| 1802 | + coord.units = cf_units.Unit("1") |
| 1803 | + |
1779 | 1804 | if coord is not None and not coord.units.is_dimensionless():
|
1780 | 1805 | msg = (
|
1781 | 1806 | "Invalid units: {} coordinate {!r} "
|
|
0 commit comments