diff --git a/.cruft.json b/.cruft.json index 18b6ca49..dc35eb84 100644 --- a/.cruft.json +++ b/.cruft.json @@ -11,7 +11,7 @@ "project_slug": "xscen", "project_short_description": "A climate change scenario-building analysis framework, built with xclim/xarray.", "pypi_username": "RondeauG", - "version": "0.4.1-beta", + "version": "0.4.2-beta", "use_pytest": "y", "use_black": "y", "use_pypi_deployment_with_travis": "n", diff --git a/HISTORY.rst b/HISTORY.rst index 14020a46..4ab922bf 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,6 +8,7 @@ Contributors to this version: Gabriel Rondeau-Genesse (:user:`RondeauG`), Juliet New features and enhancements ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +* Possibility of excluding variables read from file from the catalog produced by ``parse_directory``. (:pull:`107`). * New "timeout_cleanup" option for ``save_to_zarr``, which removes variables that were in the process of being written when receiving a ``TimeoutException``. (:pull:`106`). * New ``scripting.skippable`` context, allowing the use of CTRL-C to skip code sections. (:pull:`106`) diff --git a/setup.cfg b/setup.cfg index a98a4b04..68855a30 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.4.1-beta +current_version = 0.4.2-beta commit = True tag = False parse = (?P\d+)\.(?P\d+).(?P\d+)(\-(?P[a-z]+))? diff --git a/setup.py b/setup.py index 758f2cb7..807f9edf 100644 --- a/setup.py +++ b/setup.py @@ -61,6 +61,6 @@ test_suite="tests", tests_require=["pytest", "pytest-cov"], url="https://github.com/Ouranosinc/xscen", - version="0.4.1-beta", + version="0.4.2-beta", zip_safe=False, ) diff --git a/xscen/__init__.py b/xscen/__init__.py index 19f4bbb9..fa991ea8 100644 --- a/xscen/__init__.py +++ b/xscen/__init__.py @@ -41,7 +41,7 @@ __author__ = """Gabriel Rondeau-Genesse""" __email__ = "rondeau-genesse.gabriel@ouranos.ca" -__version__ = "0.4.1-beta" +__version__ = "0.4.2-beta" # monkeypatch so that warnings.warn() doesn't mention itself diff --git a/xscen/catalog.py b/xscen/catalog.py index df0b6173..48cf75b6 100644 --- a/xscen/catalog.py +++ b/xscen/catalog.py @@ -883,6 +883,7 @@ def parse_directory( Dictionary with mapping from parsed name to controlled names for each column. May have an additionnal "attributes" entry which maps from attribute names in the files to official column names. The attribute translation is done before the rest. + In the "variable" entry, if a name is mapped to None (null), that variable will not be listed in the catalog. xr_open_kwargs: dict If needed, arguments to send xr.open_dataset() when opening the file to read the attributes. parallel_depth: int @@ -1014,8 +1015,12 @@ def read_first_file(grp, cols): # Variable can be a tuple, we still want to replace individual names through the cvs df["variable"] = df.variable.apply( lambda vs: vs - if isinstance(vs, str) - else tuple(cvs["variable"].get(v, v) for v in vs) + if isinstance(vs, str) or pd.isnull(vs) + else tuple( + cvs["variable"].get(v, v) + for v in vs + if cvs["variable"].get(v, v) is not None + ) ) # translate xrfreq into frequencies and vice-versa