Exemplo n.º 1
0
    def test_log_level(self):
        """Test the `log_level` function."""
        original = self.__class__.original  # original to module i.e. default

        self.assertEqual(original, "WARNING")  # test default
        cfdm.LOG_LEVEL(original)  # reset from setUp() value to avoid coupling

        # Now test getting and setting for all valid values in turn,
        # where use fact that setting returns old value hence set
        # value on next call:
        previous = cfdm.log_level()
        for value in self.valid_log_values_ci:
            self.assertEqual(cfdm.LOG_LEVEL(value), previous)
            previous = cfdm.LOG_LEVEL()  # update previous value

            # Some conversions to equivalent, standardised return value:
            if isinstance(value, int) and cfdm._is_valid_log_level_int(
                value
            ):  # str from LOG_LEVEL
                value = cfdm.constants.ValidLogLevels(value).name  # convert
            if isinstance(value, str):  # LOG_LEVEL returns all caps string
                value = value.upper()
            self.assertEqual(previous, value)

        with self.assertRaises(ValueError):
            cfdm.log_level(4)
            cfdm.LOG_LEVEL(4)  # check alias too
        with self.assertRaises(ValueError):
            cfdm.log_level("ERROR")  # notable as is valid Python logging level
            cfdm.LOG_LEVEL("ERROR")
Exemplo n.º 2
0
    def setUp(self):
        """Preparations called immediately before each test method."""
        # Disable log messages to silence expected warnings
        cfdm.log_level("DISABLE")
        # Note: to enable all messages for given methods, lines or
        # calls (those without a 'verbose' option to do the same)
        # e.g. to debug them, wrap them (for methods, start-to-end
        # internally) as follows:
        #
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        nc_group_structure_names = [
            None,
            "/",
            "group/...",
            "group/",
            "group/.../",
            "/group/.../",
        ]
        self.nc_grouped_dimension_names = [
            obj.replace("...", "ncdim")
            for obj in nc_group_structure_names
            if obj is not None
        ]
        self.nc_grouped_variable_names = [
            obj.replace("...", "ncvar")
            for obj in nc_group_structure_names
            if obj is not None
        ]
Exemplo n.º 3
0
    def setUp(self):
        """Preparations called immediately before each test method."""
        # Disable log messages to silence expected warning, but
        # save original state for test on logging (see test_log_level)
        cfdm.log_level("DISABLE")
        # Note that test_log_level has been designed so the the above
        # call will not influence it, so it may be adjusted without
        # changing that test

        # Note: to enable all messages for given methods, lines or
        # calls (those without a 'verbose' option to do the same)
        # e.g. to debug them, wrap them (for methods, start-to-end
        # internally) as follows:
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        # Cover all below except lower-case, not supported in some
        # functions:
        valid_log_values = [-1, "INFO", 3, 2, 1, "DEBUG", "DETAIL", "WARNING"]
        # 'DISABLE' (0) is special case so exclude from levels list:
        self.valid_level_values = copy.copy(valid_log_values)
        # Cover string names, numeric code equivalents, & case
        # sensitivity:
        self.valid_log_values_ci = valid_log_values[:-2] + [
            "Detail",
            0,
            "DISABLE",
            "warning",
        ]
Exemplo n.º 4
0
    def test_disable_logging(self):
        """Test the `_disable_logging` internal function."""
        # Re-set to avoid coupling; use set level to check it is
        # restored after
        cfdm.log_level("DETAIL")
        below_detail_values = [logging.DEBUG]
        at_or_above_detail_values = [
            cfdm.logging._nameToLevel["DETAIL"],
            logging.INFO,
            logging.WARNING,
        ]

        # Does it disable logging correctly?
        cfdm.functions._disable_logging()

        for value in below_detail_values + at_or_above_detail_values:
            self.assertFalse(cfdm.logging.getLogger().isEnabledFor(value))

        # And does it re-enable after having disabled logging if use
        # 'NOTSET'?
        cfdm.functions._disable_logging("NOTSET")  # should re-enable

        # Re-enabling should revert emergence in line with log
        # severity level:
        for value in at_or_above_detail_values:  # as long as level >= 'DETAIL'
            self.assertTrue(cfdm.logging.getLogger().isEnabledFor(value))
        # 'DEBUG' is effectively not "enabled" as is less severe than
        # 'DETAIL'
        self.assertFalse(cfdm.logging.getLogger().isEnabledFor(logging.DEBUG))
Exemplo n.º 5
0
    def setUp(self):
        """Preparations called immediately before each test method."""
        # Disable log messages to silence expected warnings
        cfdm.log_level("DISABLE")
        # Note: to enable all messages for given methods, lines or
        # calls (those without a 'verbose' option to do the same)
        # e.g. to debug them, wrap them (for methods, start-to-end
        # internally) as follows:
        #
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        self.geometry_1_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "geometry_1.nc")
        self.geometry_2_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "geometry_2.nc")
        self.geometry_3_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "geometry_3.nc")
        self.geometry_4_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "geometry_4.nc")
        self.geometry_interior_ring_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            "geometry_interior_ring.nc",
        )
        self.geometry_interior_ring_file_2 = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            "geometry_interior_ring_2.nc",
        )
Exemplo n.º 6
0
 def setUp(self):
     # Disable log messages to silence expected warnings
     cfdm.log_level('DISABLE')
     # Note: to enable all messages for given methods, lines or calls (those
     # without a 'verbose' option to do the same) e.g. to debug them, wrap
     # them (for methods, start-to-end internally) as follows:
     # cfdm.log_level('DEBUG')
     # < ... test code ... >
     # cfdm.log_level('DISABLE')
     self.i = cfdm.implementation()
Exemplo n.º 7
0
 def setUp(self):
     # Disable log messages to silence expected warnings
     cfdm.log_level('DISABLE')
     # Note: to enable all messages for given methods, lines or
     # calls (those without a 'verbose' option to do the same)
     # e.g. to debug them, wrap them (for methods, start-to-end
     # internally) as follows:
     #
     # cfdm.LOG_LEVEL('DEBUG')
     # < ... test code ... >
     # cfdm.log_level('DISABLE')
     self.f = cfdm.read(self.filename)[0]
Exemplo n.º 8
0
    def setUp(self):
        """Preparations called immediately before each test method."""
        # Disable log messages to silence expected warnings
        cfdm.log_level("DISABLE")
        # Note: to enable all messages for given methods, lines or calls (those
        # without a 'verbose' option to do the same) e.g. to debug them, wrap
        # them (for methods, start-to-end internally) as follows:
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        self.filename = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "test_file.nc")
Exemplo n.º 9
0
    def setUp(self):
        """Preparations called immediately before each test method."""
        # Disable log messages to silence expected warnings
        cfdm.log_level("DISABLE")
        # Note: to enable all messages for given methods, lines or
        # calls (those without a 'verbose' option to do the same)
        # e.g. to debug them, wrap them (for methods, start-to-end
        # internally) as follows:
        #
        # cfdm.LOG_LEVEL('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        self.gathered = "gathered.nc"
Exemplo n.º 10
0
    def setUp(self):
        """TODO DOCS."""
        # Disable log messages to silence expected warnings
        cfdm.log_level("DISABLE")
        # Note: to enable all messages for given methods, lines or
        # calls (those without a 'verbose' option to do the same)
        # e.g. to debug them, wrap them (for methods, start-to-end
        # internally) as follows:
        #
        # cfdm.LOG_LEVEL('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        self.indexed = "DSG_timeSeries_indexed.nc"
Exemplo n.º 11
0
    def setUp(self):
        """Preparations called immediately before each test method."""
        # Disable log messages to silence expected warnings
        cfdm.log_level("DISABLE")
        # Note: to enable all messages for given methods, lines or calls (those
        # without a 'verbose' option to do the same) e.g. to debug them, wrap
        # them (for methods, start-to-end internally) as follows:
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        compressed_data = cfdm.Data([280.0, 281.0, 279.0, 278.0, 279.5])
        index = cfdm.Index(data=[0, 1, 1, 1])
        self.r = cfdm.RaggedIndexedArray(
            compressed_data, shape=(2, 3), size=6, ndim=2, index_variable=index
        )
Exemplo n.º 12
0
    def setUp(self):
        # Disable log messages to silence expected warnings
        cfdm.log_level('DISABLE')
        # Note: to enable all messages for given methods, lines or calls (those
        # without a 'verbose' option to do the same) e.g. to debug them, wrap
        # them (for methods, start-to-end internally) as follows:
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        self.filename = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'test_file.nc')
        f = cfdm.read(self.filename)
        self.assertEqual(len(f), 1, 'f={!r}'.format(f))
        self.f = f[0]

        self.test_only = []
Exemplo n.º 13
0
    def setUp(self):
        # Disable log messages to silence expected warnings
        cfdm.log_level('DISABLE')
        # Note: to enable all messages for given methods, lines or
        # calls (those without a 'verbose' option to do the same)
        # e.g. to debug them, wrap them (for methods, start-to-end
        # internally) as follows:
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        self.geometry_interior_ring_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            'geometry_interior_ring.nc')
        self.geometry_interior_ring_file_2 = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            'geometry_interior_ring_2.nc')
Exemplo n.º 14
0
    def setUp(self):
        # Disable log messages to silence expected warnings
        cfdm.log_level('DISABLE')
        # Note: to enable all messages for given methods, lines or calls (those
        # without a 'verbose' option to do the same) e.g. to debug them, wrap
        # them (for methods, start-to-end internally) as follows:
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        compressed_data = cfdm.Data([280.0, 281.0, 279.0, 278.0, 279.5])
        count = cfdm.Count(data=[1, 3])
        self.r = cfdm.RaggedContiguousArray(compressed_data,
                                            shape=(2, 3),
                                            size=6,
                                            ndim=2,
                                            count_variable=count)
Exemplo n.º 15
0
    def setUp(self):
        # Disable log messages to silence expected warnings
        cfdm.log_level('DISABLE')
        # Note: to enable all messages for given methods, lines or calls (those
        # without a 'verbose' option to do the same) e.g. to debug them, wrap
        # them (for methods, start-to-end internally) as follows:
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        self.filename = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'test_file.nc')

        try:
            os.remove(self.filename)
        except Exception:
            pass
Exemplo n.º 16
0
    def setUpClass(cls):
        # Need to run this per-class, not per-method, to access the
        # original value of log_level to use to test the default (see
        # test_log_level)
        cls.original = cfdm.log_level('DISABLE')

        # When this module is run as part of full test-suite, the
        # value set in previous test is picked up above, not the
        # default. For now skip this test (effectively) for test suite
        # run. TODO: find way round this.
        if __name__ != '__main__':
            cls.original = 'WARNING'
Exemplo n.º 17
0
 def setUp(self):
     """TODO DOCS."""
     # Disable log messages to silence expected warnings
     cfdm.log_level("DISABLE")
Exemplo n.º 18
0
print("\n**Tutorial**\n")

print("\n**Import**\n")

import cfdm

cfdm.log_level('INFO')
cfdm.CF()

print("\n**Field construct**\n")

print("\n**Reading field constructs from datasets**\n")

x = cfdm.read('file.nc')
print(type(x))
len(x)

print("\n**Inspection**\n")

x
q = x[0]
t = x[1]
q
print(q)
print(t)
q.dump()
t.dump()

print("\n**Properties**\n")

t.properties()
Exemplo n.º 19
0
    def test_manage_log_level_via_verbosity(self):
        """Test the `_manage_log_level_via_verbosity` decorator."""
        # Order of decreasing severity/verbosity is crucial to one test below
        levels = ["WARNING", "INFO", "DETAIL", "DEBUG"]

        # Note we test assertions on the root logger object, which is the
        # one output overall at runtime, but the specific module logger name
        # should be registered within the log message:
        log_message = [
            f"WARNING:{log_name}:{WARNING_MSG}",
            f"INFO:{log_name}:{INFO_MSG}",
            f"DETAIL:{log_name}:{DETAIL_MSG}",
            f"DEBUG:{log_name}:{DEBUG_MSG}",
        ]

        test_class = dummyClass()
        # 1. First test it works for methods using test_class to test with
        # 2. Then test it works for functions (not bound to a class)
        functions_to_call_to_test = [
            test_class.decorated_logging_method,  # Case 1 as described above
            decorated_logging_func,  # Case 2
        ]

        for level, function_to_call_to_test in itertools.product(
                levels, functions_to_call_to_test):
            cfdm.log_level(level)  # reset to level

            # Default verbose(=None) cases: log_level should determine output
            with self.assertLogs(level=cfdm.log_level().value) as catch:
                function_to_call_to_test()

                for msg in log_message:
                    # log_level should prevent messages less severe appearing:
                    if levels.index(level) >= log_message.index(msg):
                        self.assertIn(msg, catch.output)
                    else:  # less severe, should be effectively filtered out
                        self.assertNotIn(msg, catch.output)

            # Cases where verbose is set; value should override log_level...

            # Highest verbosity case (note -1 == 'DEBUG', highest verbosity):
            # all messages should appear, regardless of global log_level:
            for argument in (-1, "DEBUG", "debug", "Debug", "DeBuG"):
                with self.assertLogs(level=cfdm.log_level().value) as catch:
                    function_to_call_to_test(verbose=argument)
                    for msg in log_message:
                        self.assertIn(msg, catch.output)

            # Lowest verbosity case ('WARNING' / 1) excluding special case of
            # 'DISABLE' (see note above): only warning messages should appear,
            # regardless of global log_level value set:
            for argument in (1, "WARNING", "warning", "Warning", "WaRning"):
                with self.assertLogs(level=cfdm.log_level().value) as catch:
                    function_to_call_to_test(verbose=argument)
                    for msg in log_message:
                        if msg.split(":")[0] == "WARNING":
                            self.assertIn(msg, catch.output)
                        else:
                            self.assertNotIn(msg, catch.output)

            # Boolean cases for testing backwards compatibility...

            # ... verbose=True should be equivalent to verbose=3 now:
            with self.assertLogs(level=cfdm.log_level().value) as catch:
                function_to_call_to_test(verbose=True)
                for msg in log_message:
                    if msg.split(":")[0] == "DEBUG":
                        self.assertNotIn(msg, catch.output)
                    else:
                        self.assertIn(msg, catch.output)

            # ... verbose=False should be equivalent to verbose=0 now, so
            # test along with 'DISABLE' special case below...

            # Special 'DISABLE' (0) case: note this needs to be last as we
            # reset the log_level to it but need to use 'NOTSET' for the
            # assertLogs level, which sends all log messages through:
            for argument in (0, "DISABLE", "disable", "Disable", "DisAblE"):
                with self.assertLogs(level="NOTSET") as catch:
                    # Note: get 'AssertionError' if don't log anything at all,
                    # so to avoid this and allow check for disabled logging,
                    # first log something then disable and check that no other
                    # messages emerge:
                    logger.info(
                        "Purely to keep 'assertLog' happy: see comment!")
                    cfdm.log_level("DISABLE")
                    function_to_call_to_test(verbose=argument)
                    for msg in log_message:  # nothing else should be logged
                        self.assertNotIn(msg, catch.output)

            # verbose=False should be equivalent in behaviour to verbose=0
            with self.assertLogs(level="NOTSET") as catch:
                logger.info("Purely to keep 'assertLog' happy: see previous!")
                function_to_call_to_test(verbose=False)
                for msg in log_message:  # nothing else should be logged
                    self.assertNotIn(msg, catch.output)
 def setUp(self):
     # Disable log messages to silence expected warnings
     cfdm.log_level('DISABLE')
Exemplo n.º 21
0
    def test_manage_log_level_via_verbosity(self):
        if self.test_only and inspect.stack()[0][3] not in self.test_only:
            return

        test_class = dummyClass()

        # Order of decreasing severity/verbosity is crucial to one test below
        levels = ['WARNING', 'INFO', 'DETAIL', 'DEBUG']

        # Note we test assertions on the root logger object, which is the
        # one output overall at runtime, but the specific module logger name
        # should be registered within the log message:
        log_message = [
            'WARNING:{}:{}'.format(log_name, test_class.warning_message),
            'INFO:{}:{}'.format(log_name, test_class.info_message),
            'DETAIL:{}:{}'.format(log_name, test_class.detail_message),
            'DEBUG:{}:{}'.format(log_name, test_class.debug_message)
        ]

        for level in levels:
            cfdm.log_level(level)  # reset to level

            # Default verbose(=None) cases: log_level should determine output
            with self.assertLogs(level=cfdm.log_level()) as catch:
                test_class.decorated_logging_func()

                for msg in log_message:
                    # log_level should prevent messages less severe appearing:
                    if levels.index(level) >= log_message.index(msg):
                        self.assertIn(msg, catch.output)
                    else:  # less severe, should be effectively filtered out
                        self.assertNotIn(msg, catch.output)

            # Cases where verbose is set; value should override log_level...

            # Highest verbosity case (note -1 == 'DEBUG', highest verbosity):
            # all messages should appear, regardless of global log_level:
            for argument in (-1, 'DEBUG', 'debug', 'Debug', 'DeBuG'):
                with self.assertLogs(level=cfdm.log_level()) as catch:
                    test_class.decorated_logging_func(verbose=argument)
                    for msg in log_message:
                        self.assertIn(msg, catch.output)

            # Lowest verbosity case ('WARNING' / 1) excluding special case of
            # 'DISABLE' (see note above): only warning messages should appear,
            # regardless of global log_level value set:
            for argument in (1, 'WARNING', 'warning', 'Warning', 'WaRning'):
                with self.assertLogs(level=cfdm.log_level()) as catch:
                    test_class.decorated_logging_func(verbose=argument)
                    for msg in log_message:
                        if msg.split(":")[0] == 'WARNING':
                            self.assertIn(msg, catch.output)
                        else:
                            self.assertNotIn(msg, catch.output)

            # Boolean cases for testing backwards compatibility...

            # ... verbose=True should be equivalent to verbose=3 now:
            with self.assertLogs(level=cfdm.log_level()) as catch:
                test_class.decorated_logging_func(verbose=True)
                for msg in log_message:
                    if msg.split(":")[0] == 'DEBUG':
                        self.assertNotIn(msg, catch.output)
                    else:
                        self.assertIn(msg, catch.output)

            # ... verbose=False should be equivalent to verbose=0 now, so
            # test along with 'DISABLE' special case below...

            # Special 'DISABLE' (0) case: note this needs to be last as we
            # reset the log_level to it but need to use 'NOTSET' for the
            # assertLogs level, which sends all log messages through:
            for argument in (0, 'DISABLE', 'disable', 'Disable', 'DisAblE'):
                with self.assertLogs(level='NOTSET') as catch:
                    # Note: get 'AssertionError' if don't log anything at all,
                    # so to avoid this and allow check for disabled logging,
                    # first log something then disable and check that no other
                    # messages emerge:
                    logger.info(
                        "Purely to keep 'assertLog' happy: see comment!")
                    cfdm.log_level('DISABLE')
                    test_class.decorated_logging_func(verbose=argument)
                    for msg in log_message:  # nothing else should be logged
                        self.assertNotIn(msg, catch.output)

            # verbose=False should be equivalent in behaviour to verbose=0
            with self.assertLogs(level='NOTSET') as catch:
                logger.info("Purely to keep 'assertLog' happy: see previous!")
                test_class.decorated_logging_func(verbose=False)
                for msg in log_message:  # nothing else should be logged
                    self.assertNotIn(msg, catch.output)
Exemplo n.º 22
0
    def setUp(self):
        """Preparations called immediately before each test method."""
        # Disable log messages to silence expected warnings
        cfdm.log_level("DISABLE")
        # Note: to enable all messages for given methods, lines or
        # calls (those without a 'verbose' option to do the same)
        # e.g. to debug them, wrap them (for methods, start-to-end
        # internally) as follows:
        #
        # cfdm.log_level('DEBUG')
        # < ... test code ... >
        # cfdm.log_level('DISABLE')

        self.gathered = "gathered.nc"

        a = numpy.ma.masked_all((4, 9), dtype=float)
        a[0, 0:3] = [0.0, 1.0, 2.0]
        a[1, 0:7] = [1.0, 11.0, 21.0, 31.0, 41.0, 51.0, 61.0]
        a[2, 0:5] = [2.0, 102.0, 202.0, 302.0, 402.0]
        a[3, 0:9] = [
            3.0,
            1003.0,
            2003.0,
            3003.0,
            4003.0,
            5003.0,
            6003.0,
            7003.0,
            8003.0,
        ]
        self.a = a

        b = numpy.ma.array([
            [
                [207.12345561172262, -99, -99, -99],
                [
                    100.65758285427566,
                    117.72137430364056,
                    182.1893456150461,
                    -99,
                ],
                [109.93898265295516, 117.76872282697526, -99, -99],
                [163.020681064712, 200.09702526477145, -99, -99],
                [138.25879722836117, 182.59075988956565, -99, -99],
                [159.28122555425304, -99, -99, -99],
                [157.0114286059841, 212.14056704399377, -99, -99],
                [225.09002846189756, -99, -99, -99],
                [179.99301151546493, -99, -99, -99],
                [125.56310968736936, 216.60367471282225, -99, -99],
                [
                    105.12035147782414,
                    129.460917520233,
                    210.13998569368403,
                    -99,
                ],
                [159.75007622045126, 197.101264162631, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
            ],
            [
                [
                    52.1185292100177,
                    57.51542658633939,
                    108.49584371709457,
                    137.7109686243953,
                ],
                [26.433960062549616, 91.57049700941819, -99, -99],
                [7.015322103368953, 39.551765142093345, -99, -99],
                [157.047493027102, -99, -99, -99],
                [25.18033994582771, 159.67348686580374, -99, -99],
                [45.84635421577662, 97.86781970832622, -99, -99],
                [5.61560792556281, 31.182013232254985, -99, -99],
                [37.78941964121314, -99, -99, -99],
                [
                    57.2927165845568,
                    129.40831355790502,
                    181.2962705331917,
                    -99,
                ],
                [
                    38.714266913107686,
                    69.34591875157382,
                    169.26193063629765,
                    -99,
                ],
                [
                    72.52507309225012,
                    138.22169348672838,
                    159.82855521564647,
                    -99,
                ],
                [
                    45.23406469185547,
                    97.66633738254326,
                    112.64049631761776,
                    -99,
                ],
                [14.920937817653984, -99, -99, -99],
                [
                    9.071979535527532,
                    42.527916794472986,
                    61.8685137936187,
                    -99,
                ],
                [17.175098751913993, 99.00403750149574, -99, -99],
                [92.95097491537247, -99, -99, -99],
                [7.11997786817564, -99, -99, -99],
                [156.81807261767003, -99, -99, -99],
                [6.832599021190903, 12.446963835216742, -99, -99],
                [
                    45.19734905410353,
                    124.30321995608465,
                    130.4780046562618,
                    -99,
                ],
                [
                    35.18924597876244,
                    68.36858129904569,
                    78.88837365755683,
                    -99,
                ],
                [81.15820119504805, 122.41242448019014, -99, -99],
                [58.95866448059819, -99, -99, -99],
                [10.465638726626635, 96.11859001483036, -99, -99],
                [
                    55.64766876004607,
                    78.37174486781481,
                    91.09175506350066,
                    -99,
                ],
                [
                    71.46930436420837,
                    90.43816256387788,
                    103.76781788802138,
                    -99,
                ],
            ],
            [
                [351.97770529376936, -99, -99, -99],
                [
                    347.0644742747811,
                    388.5698490238134,
                    481.0692542795372,
                    -99,
                ],
                [
                    352.42430719766776,
                    393.20047319955916,
                    395.71509960367075,
                    -99,
                ],
                [
                    402.8689447636048,
                    403.74922883226424,
                    479.8582815909853,
                    -99,
                ],
                [300.0199333154121, 365.124061660449, -99, -99],
                [333.35006535728564, 433.143904011861, -99, -99],
                [376.9480484244583, -99, -99, -99],
                [334.99329771076077, -99, -99, -99],
                [319.36684737542186, 337.20913311790446, -99, -99],
                [
                    340.66500823697623,
                    353.52589668400094,
                    410.44418671572373,
                    -99,
                ],
                [
                    301.9005914473572,
                    337.2055422899861,
                    386.9573429761627,
                    -99,
                ],
                [324.3747437305056, 424.04244158178483, -99, -99],
                [
                    331.52095586074626,
                    349.4826244342738,
                    396.81256849354895,
                    -99,
                ],
                [331.99043697116906, -99, -99, -99],
                [384.76674803938937, -99, -99, -99],
                [373.0334288724908, 399.47980750739197, -99, -99],
                [300.0106221314076, 390.6371376624527, -99, -99],
                [
                    364.25269358741537,
                    391.19723635099535,
                    456.466622863717,
                    -99,
                ],
                [410.1246758522543, -99, -99, -99],
                [310.59214185542953, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
                [-99, -99, -99, -99],
            ],
        ])

        b = numpy.ma.where(b == -99, numpy.ma.masked, b)
        self.b = b
Exemplo n.º 23
0
 def setUp(self):
     """Preparations called immediately before each test method."""
     # Disable log messages to silence expected warnings
     cfdm.log_level("DISABLE")
Exemplo n.º 24
0
print("\n**Tutorial**\n")

print("\n**Import**\n")

import cfdm

cfdm.log_level("INFO")
cfdm.CF()

print("\n**Field construct**\n")

print("\n**Reading field constructs from datasets**\n")

x = cfdm.read("file.nc")
print(type(x))
len(x)

print("\n**Inspection**\n")

x
q = x[0]
t = x[1]
q
print(q)
print(t)
q.dump()
t.dump()

print("\n**Properties**\n")

t.properties()