Managing/suppressing xcdat warning statements #597
-
Question criteria
Describe your questionWe have been working on a demo notebook and are keen to suppress annoying warnings that alert users to file issues but still allow files and their contents to be opened and read. Long story short, none of the methods that I have used in the past can suppress what originates as a Are there are any possible answers you came across?I have tried several previously effective methods, the I'd be keen to understand how best to catch or suppress these Minimal Complete Verifiable Example (MVCE)import xcdat as xc
# set inFile
inFile = "/p/user_pub/pmp/demo/sea-ice/EUMETSAT/OSI-SAF-450-a-3-0/v20231201/ice_conc_nh_ease2-250_cdr-v3p0_198801-202012.nc"
# attempt to suppress through warnings
import warnings, os
warnings.filterwarnings('ignore')
warnings.simplefilter("ignore") # Change the filter in this process
os.environ["PYTHONWARNINGS"] = "ignore" # Also affect subprocesses
fH = xc.open_dataset(inFile)
# returns
2024-02-02 04:32:11,980 [WARNING]: bounds.py(add_missing_bounds:188) >> The yc coord variable has a 'units' attribute that is not in degrees.
2024-02-02 04:32:11,980 [WARNING]: bounds.py(add_missing_bounds:188) >> The yc coord variable has a 'units' attribute that is not in degrees.
# attempt to suppress through contextlib
from contextlib import suppress
with suppress(ValueError):
fH = xc.open_dataset(inFile)
# returns
2024-02-02 04:32:13,796 [WARNING]: bounds.py(add_missing_bounds:188) >> The yc coord variable has a 'units' attribute that is not in degrees.
2024-02-02 04:32:13,796 [WARNING]: bounds.py(add_missing_bounds:188) >> The yc coord variable has a 'units' attribute that is not in degrees. Relevant log outputNo response Environmentxc: 0.6.1 INSTALLED VERSIONScommit: None xarray: 2024.1.1 Anything else we need to know?No response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think this should work:
|
Beta Was this translation helpful? Give feedback.
I think this should work: