From 824286e000f1ee4da30d1bac27b05cc3804947de Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Thu, 21 Jul 2022 15:32:52 +0100 Subject: [PATCH] Review changes. --- lib/iris/experimental/ugrid/load.py | 2 ++ lib/iris/experimental/ugrid/save.py | 3 +-- lib/iris/fileformats/netcdf/__init__.py | 7 ++++++- lib/iris/fileformats/netcdf/loader.py | 7 ++----- lib/iris/fileformats/netcdf/saver.py | 10 +++++----- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/iris/experimental/ugrid/load.py b/lib/iris/experimental/ugrid/load.py index 1fcb5cecf1..a522d91313 100644 --- a/lib/iris/experimental/ugrid/load.py +++ b/lib/iris/experimental/ugrid/load.py @@ -8,6 +8,8 @@ Extensions to Iris' NetCDF loading to allow the construction of :class:`~iris.experimental.ugrid.mesh.Mesh`\\ es from UGRID data in the file. +Eventual destination: :mod:`iris.fileformats.netcdf`. + """ from contextlib import contextmanager from itertools import groupby diff --git a/lib/iris/experimental/ugrid/save.py b/lib/iris/experimental/ugrid/save.py index 8a5934b939..3c42137905 100644 --- a/lib/iris/experimental/ugrid/save.py +++ b/lib/iris/experimental/ugrid/save.py @@ -8,8 +8,7 @@ Extensions to Iris' NetCDF saving to allow :class:`~iris.experimental.ugrid.mesh.Mesh` saving in UGRID format. -Eventual destination: :mod:`iris.fileformats.netcdf` (plan to split that module -into ``load`` and ``save`` in future). +Eventual destination: :mod:`iris.fileformats.netcdf`. """ from collections.abc import Iterable diff --git a/lib/iris/fileformats/netcdf/__init__.py b/lib/iris/fileformats/netcdf/__init__.py index 37f8b022f0..f2791b1654 100644 --- a/lib/iris/fileformats/netcdf/__init__.py +++ b/lib/iris/fileformats/netcdf/__init__.py @@ -11,7 +11,12 @@ Also refer to document 'NetCDF Climate and Forecast (CF) Metadata Conventions'. """ -from .loader import DEBUG, NetCDFDataProxy, load_cubes, logger +import iris.config + +# Note: *must* be done before importing from submodules, as they also use this ! +logger = iris.config.get_logger(__name__) + +from .loader import DEBUG, NetCDFDataProxy, load_cubes from .saver import ( CF_CONVENTIONS_VERSION, MESH_ELEMENTS, diff --git a/lib/iris/fileformats/netcdf/loader.py b/lib/iris/fileformats/netcdf/loader.py index fa3aef0c4e..a8dd9bd428 100644 --- a/lib/iris/fileformats/netcdf/loader.py +++ b/lib/iris/fileformats/netcdf/loader.py @@ -40,11 +40,8 @@ # Show actions activation statistics. DEBUG = False -# Configure the logger : shared logger for all in 'iris.fileformats.netcdf'. -from .. import __name__ as _parent_module_name - -logger = iris.config.get_logger(_parent_module_name) -del _parent_module_name +# Get the logger : shared logger for all in 'iris.fileformats.netcdf'. +from . import logger def _actions_engine(): diff --git a/lib/iris/fileformats/netcdf/saver.py b/lib/iris/fileformats/netcdf/saver.py index 037e4fb796..5ea84225b0 100644 --- a/lib/iris/fileformats/netcdf/saver.py +++ b/lib/iris/fileformats/netcdf/saver.py @@ -46,12 +46,12 @@ import iris.io import iris.util -# Configure the logger : shared logger for all in 'iris.fileformats.netcdf'. -from .. import __name__ as _parent_module_name - -logger = iris.config.get_logger(_parent_module_name) -del _parent_module_name +# Get the logger : shared logger for all in 'iris.fileformats.netcdf'. +from . import logger +# Avoid warning about unused import. +# We could use an __all__, but we don't want to maintain one here +logger # Standard CML spatio-temporal axis names. SPATIO_TEMPORAL_AXES = ["t", "z", "y", "x"]