Skip to content

Commit 861dbf7

Browse files
TonyB9000Anthony Bartolettitomvothecoder
authored
Replace np.nan with FILL_VALUE in clisccp.py for cmor.write (#328)
Co-authored-by: Anthony Bartoletti <[email protected]> Co-authored-by: tomvothecoder <[email protected]>
1 parent 7c7f400 commit 861dbf7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

e3sm_to_cmip/cmor_handlers/vars/clisccp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import xarray as xr
1212

1313
from e3sm_to_cmip._logger import _setup_child_logger
14+
from e3sm_to_cmip.cmor_handlers import FILL_VALUE
1415
from e3sm_to_cmip.util import print_message, setup_cmor
1516

1617
logger = _setup_child_logger(__name__)
@@ -156,6 +157,12 @@ def handle( # noqa: C901
156157

157158
varid = cmor.variable(VAR_NAME, VAR_UNITS, axis_ids)
158159

160+
# Replace NaNs in data with appropriate fill-value for cmor.write,
161+
# which does not support np.nan as a fill value.
162+
data["FISCCP1_COSP"] = np.where(
163+
np.isnan(data["FISCCP1_COSP"]), FILL_VALUE, data["FISCCP1_COSP"]
164+
)
165+
159166
# write out the data
160167
msg = f"{VAR_NAME}: time {data['time_bnds'][0][0]:1.1f} - {data['time_bnds'][-1][-1]:1.1f}"
161168
logger.info(msg)

0 commit comments

Comments
 (0)