Example #1
0
def test_build_parameterized_cube_load_collection_band(con100):
    layer = Parameter.string("layer")
    bands = [Parameter.string("band8"), Parameter.string("band12")]
    cube = con100.load_collection(layer, bands=bands)

    assert cube.flat_graph() == {
        "loadcollection1": {
            "process_id": "load_collection",
            "arguments": {
                "id": {
                    "from_parameter": "layer"
                },
                "temporal_extent":
                None,
                "spatial_extent":
                None,
                "bands": [{
                    "from_parameter": "band8"
                }, {
                    "from_parameter": "band12"
                }]
            },
            "result": True,
        }
    }
Example #2
0
def test_build_parameterized_cube_load_collection(con100):
    layer = Parameter.string("layer")
    dates = Parameter.string("dates")
    bbox = Parameter("bbox", schema="object")
    cube = con100.load_collection(layer,
                                  spatial_extent=bbox,
                                  temporal_extent=dates)

    assert cube.flat_graph() == {
        "loadcollection1": {
            "process_id": "load_collection",
            "arguments": {
                "id": {
                    "from_parameter": "layer"
                },
                "temporal_extent": {
                    "from_parameter": "dates"
                },
                "spatial_extent": {
                    "from_parameter": "bbox"
                }
            },
            "result": True,
        }
    }
Example #3
0
def test_parameter_string():
    assert Parameter.string("color").to_dict() == {
        "name": "color", "description": "color", "schema": {"type": "string"}
    }
    assert Parameter.string("color", description="The color.").to_dict() == {
        "name": "color", "description": "The color.", "schema": {"type": "string"}
    }
    assert Parameter.string("color", default="red").to_dict() == {
        "name": "color", "description": "color", "schema": {"type": "string"}, "optional": True, "default": "red"
    }
Example #4
0
def test_build_parameterized_cube_single_date(con100):
    layer = Parameter.string("layer")
    date = Parameter.string("date")
    bbox = Parameter("bbox", schema="object")
    cube = con100.load_collection(layer).filter_temporal(
        date, date).filter_bbox(bbox)

    assert cube.flat_graph() == {
        "loadcollection1": {
            "process_id": "load_collection",
            "arguments": {
                "id": {
                    "from_parameter": "layer"
                },
                "temporal_extent": None,
                "spatial_extent": None
            },
        },
        "filtertemporal1": {
            "process_id": "filter_temporal",
            "arguments": {
                "data": {
                    "from_node": "loadcollection1"
                },
                "extent": [{
                    "from_parameter": "date"
                }, {
                    "from_parameter": "date"
                }]
            },
        },
        "filterbbox1": {
            "process_id": "filter_bbox",
            "arguments": {
                "data": {
                    "from_node": "filtertemporal1"
                },
                "extent": {
                    "from_parameter": "bbox"
                }
            },
            "result": True,
        }
    }
Example #5
0
def test_build_parameterized_cube_band_math(con100):
    layer = Parameter.string("layer")
    bands = [Parameter.string("band8"), Parameter.string("band12")]
    cube = con100.load_collection(layer, bands=bands)
    x = cube.band(0) * cube.band(1)
    assert x.flat_graph() == {
        "loadcollection1": {
            "process_id": "load_collection",
            "arguments": {
                "id": {"from_parameter": "layer"},
                "spatial_extent": None,
                "temporal_extent": None,
                "bands": [{"from_parameter": "band8"}, {"from_parameter": "band12"}],
            },
        },
        "reducedimension1": {
            "process_id": "reduce_dimension",
            "arguments": {
                "data": {"from_node": "loadcollection1"},
                "dimension": "bands",
                "reducer": {"process_graph": {
                    "arrayelement1": {
                        "process_id": "array_element",
                        "arguments": {"data": {"from_parameter": "data"}, "index": 0},
                    },
                    "arrayelement2": {
                        "process_id": "array_element",
                        "arguments": {"data": {"from_parameter": "data"}, "index": 1},
                    },
                    "multiply1": {
                        "process_id": "multiply",
                        "arguments": {
                            "x": {"from_node": "arrayelement1"},
                            "y": {"from_node": "arrayelement2"}},
                        "result": True
                    }
                }}
            },
            "result": True
        }
    }