From b1f91f26c620496368f27a9048aba30f9c626493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carmen=20Pi=C3=B1ero=20Meg=C3=ADas?= Date: Tue, 1 Oct 2024 11:54:07 +0200 Subject: [PATCH 1/2] Add info flag to suppress annoying warnings --- nes/nc_projections/default_nes.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/nes/nc_projections/default_nes.py b/nes/nc_projections/default_nes.py index 399968f..c942f99 100644 --- a/nes/nc_projections/default_nes.py +++ b/nes/nc_projections/default_nes.py @@ -3763,7 +3763,7 @@ class Nes(object): return None - def to_shapefile(self, path, time=None, lev=None, var_list=None): + def to_shapefile(self, path, time=None, lev=None, var_list=None, info=True): """ Create shapefile from NES data. @@ -3781,6 +3781,8 @@ class Nes(object): Vertical level to select. var_list : List, str, None List (or single string) of the variables to be loaded and saved in the shapefile. + info: bool + Flag to suppress warnings when 'time' and 'lev' are None """ # If list is not defined, get all variables @@ -3801,9 +3803,10 @@ class Nes(object): # Select first vertical level (if needed) if lev is None: - msg = "No vertical level has been specified. The first one will be selected." - warn(msg) - sys.stderr.flush() + if info: + msg = "No vertical level has been specified. The first one will be selected." + warn(msg) + sys.stderr.flush() idx_lev = 0 else: if lev not in self.lev["data"]: @@ -3812,9 +3815,10 @@ class Nes(object): # Select first time (if needed) if time is None: - msg = "No time has been specified. The first one will be selected." - warn(msg) - sys.stderr.flush() + if info: + msg = "No time has been specified. The first one will be selected." + warn(msg) + sys.stderr.flush() idx_time = 0 else: if time not in self.time: -- GitLab From 2aa54f96a34bd45fd039185cab9c16d2f1c1ef18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carmen=20Pi=C3=B1ero=20Meg=C3=ADas?= Date: Tue, 1 Oct 2024 16:53:04 +0200 Subject: [PATCH 2/2] Improve docstring in to_shapefile method --- nes/nc_projections/default_nes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nes/nc_projections/default_nes.py b/nes/nc_projections/default_nes.py index c942f99..68e087a 100644 --- a/nes/nc_projections/default_nes.py +++ b/nes/nc_projections/default_nes.py @@ -3782,7 +3782,7 @@ class Nes(object): var_list : List, str, None List (or single string) of the variables to be loaded and saved in the shapefile. info: bool - Flag to suppress warnings when 'time' and 'lev' are None + Flag to allow/suppress warnings when the 'time' or 'lev' parameters are None. Default is True. """ # If list is not defined, get all variables -- GitLab