Ejemplo n.º 1
0
def test_get_dimensions_cube_dimensions_spatial_xyt_bands():
    dims = CollectionMetadata._parse_dimensions({
        "cube:dimensions": {
            "x": {
                "type": "spatial",
                "extent": [-10, 10]
            },
            "y": {
                "type": "spatial",
                "extent": [-56, 83],
                "reference_system": 123
            },
            "t": {
                "type": "temporal",
                "extent": ["2020-02-20", None]
            },
            "spectral": {
                "type": "bands",
                "values": ["red", "green", "blue"]
            },
        }
    })
    assert_same_dimensions(dims, [
        SpatialDimension(name="x", extent=[-10, 10]),
        SpatialDimension(name="y", extent=[-56, 83], crs=123),
        TemporalDimension(name="t", extent=["2020-02-20", None]),
        BandDimension(name="spectral",
                      bands=[
                          Band("red", None, None),
                          Band("green", None, None),
                          Band("blue", None, None),
                      ])
    ])
Ejemplo n.º 2
0
def test_get_dimensions_cube_dimensions_eo_bands():
    dims = CollectionMetadata._parse_dimensions({
        "cube:dimensions": {
            "x": {"type": "spatial", "extent": [-10, 10]},
            "y": {"type": "spatial", "extent": [-56, 83], "reference_system": 123},
            "t": {"type": "temporal", "extent": ["2020-02-20", None]},
            "spectral": {"type": "bands", "values": ["r", "g", "b"]},
        },
        "summaries": {
            "eo:bands": [
                {"name": "r", "common_name": "red", "center_wavelength": 5},
                {"name": "g", "center_wavelength": 8},
                {"name": "b", "common_name": "blue"},
            ]
        }
    })
    assert_same_dimensions(dims, [
        SpatialDimension(name="x", extent=[-10, 10]),
        SpatialDimension(name="y", extent=[-56, 83], crs=123),
        TemporalDimension(name="t", extent=["2020-02-20", None]),
        BandDimension(name="spectral", bands=[
            Band("r", "red", 5),
            Band("g", None, 8),
            Band("b", "blue", None),
        ])
    ])
Ejemplo n.º 3
0
def test_get_dimensions_cube_dimensions_spatial_xyt():
    dims = CollectionMetadata._parse_dimensions({
        "cube:dimensions": {
            "xx": {"type": "spatial", "extent": [-10, 10]},
            "yy": {"type": "spatial", "extent": [-56, 83], "reference_system": 123},
            "tt": {"type": "temporal", "extent": ["2020-02-20", None]},
        }
    })
    assert_same_dimensions(dims, [
        SpatialDimension(name="xx", extent=[-10, 10]),
        SpatialDimension(name="yy", extent=[-56, 83], crs=123),
        TemporalDimension(name="tt", extent=["2020-02-20", None]),
    ])
Ejemplo n.º 4
0
def test_get_dimensions_no_band_dimension_with_eo_bands():
    logs = []
    dims = CollectionMetadata._parse_dimensions(
        {
            "cube:dimensions": {
                "x": {
                    "type": "spatial",
                    "extent": [-10, 10]
                },
            },
            "summaries": {
                "eo:bands": [
                    {
                        "name": "y",
                        "common_name": "yellow",
                        "center_wavelength": 5
                    },
                    {
                        "name": "c",
                        "center_wavelength": 8
                    },
                    {
                        "name": "m",
                        "common_name": "magenta"
                    },
                ]
            },
        },
        complain=logs.append)
    assert_same_dimensions(dims, [
        SpatialDimension(name="x", extent=[-10, 10]),
    ])
    assert logs == [
        "No 'bands' dimension in 'cube:dimensions' while having 'eo:bands'"
    ]
Ejemplo n.º 5
0
def test_get_dimensions_multiple_band_dimensions_with_eo_bands():
    logs = []
    dims = CollectionMetadata._parse_dimensions(
        {
            "cube:dimensions": {
                "x": {
                    "type": "spatial",
                    "extent": [-10, 10]
                },
                "spectral": {
                    "type": "bands",
                    "values": ["alpha", "beta"]
                },
                "bands": {
                    "type": "bands",
                    "values": ["r", "g", "b"]
                },
            },
            "summaries": {
                "eo:bands": [
                    {
                        "name": "zu",
                        "common_name": "foo"
                    },
                ]
            },
        },
        complain=logs.append)
    assert_same_dimensions(dims, [
        SpatialDimension(name="x", extent=[-10, 10]),
        BandDimension(name="spectral",
                      bands=[
                          Band("alpha", None, None),
                          Band("beta", None, None),
                      ]),
        BandDimension(name="bands",
                      bands=[
                          Band("r", None, None),
                          Band("g", None, None),
                          Band("b", None, None),
                      ]),
    ])
    assert logs == ["Multiple dimensions of type 'bands'"]
Ejemplo n.º 6
0
def test_get_dimensions_cube_dimensions_eo_bands_mismatch():
    logs = []
    dims = CollectionMetadata._parse_dimensions(
        {
            "cube:dimensions": {
                "x": {
                    "type": "spatial",
                    "extent": [-10, 10]
                },
                "spectral": {
                    "type": "bands",
                    "values": ["r", "g", "b"]
                },
            },
            "summaries": {
                "eo:bands": [
                    {
                        "name": "y",
                        "common_name": "yellow",
                        "center_wavelength": 5
                    },
                    {
                        "name": "c",
                        "center_wavelength": 8
                    },
                    {
                        "name": "m",
                        "common_name": "magenta"
                    },
                ]
            }
        },
        complain=logs.append)
    assert_same_dimensions(dims, [
        SpatialDimension(name="x", extent=[-10, 10]),
        BandDimension(name="spectral",
                      bands=[
                          Band("r", None, None),
                          Band("g", None, None),
                          Band("b", None, None),
                      ])
    ])
    assert logs == ["Band name mismatch: ['r', 'g', 'b'] != ['y', 'c', 'm']"]