def test_pgnode_to_dict_subprocess_graphs():
    load_collection = PGNode("load_collection", collection_id="S2")
    band2 = PGNode("array_element", data={"from_argument": "data"}, index=2)
    band2_plus3 = PGNode("add", x={"from_node": band2}, y=2)
    graph = ReduceNode(data=load_collection,
                       reducer=band2_plus3,
                       dimension='bands')

    assert graph.to_dict() == {
        'process_id': 'reduce_dimension',
        'arguments': {
            'data': {
                'from_node': {
                    'process_id': 'load_collection',
                    'arguments': {
                        'collection_id': 'S2'
                    },
                }
            },
            'dimension': 'bands',
            'reducer': {
                'process_graph': {
                    'process_id': 'add',
                    'arguments': {
                        'x': {
                            "from_node": {
                                'process_id': 'array_element',
                                'arguments': {
                                    'data': {
                                        'from_argument': 'data'
                                    },
                                    'index': 2
                                },
                            }
                        },
                        'y': 2
                    },
                }
            }
        },
    }
    assert graph.flat_graph() == {
        "loadcollection1": {
            'process_id': 'load_collection',
            'arguments': {
                'collection_id': 'S2'
            },
        },
        "reducedimension1": {
            'process_id': 'reduce_dimension',
            'arguments': {
                'data': {
                    'from_node': "loadcollection1"
                },
                'dimension': 'bands',
                'reducer': {
                    'process_graph': {
                        "arrayelement1": {
                            'process_id': 'array_element',
                            'arguments': {
                                'data': {
                                    'from_argument': 'data'
                                },
                                'index': 2
                            },
                        },
                        "add1": {
                            'process_id': 'add',
                            'arguments': {
                                'x': {
                                    "from_node": "arrayelement1"
                                },
                                'y': 2
                            },
                            'result': True,
                        }
                    }
                }
            },
            "result": True,
        }
    }
예제 #2
0
                               spatial_extent={
                                   "west": 16.06,
                                   "south": 48.1,
                                   "east": 16.65,
                                   "north": 48.31,
                                   "crs": "EPSG:4326"
                               },
                               temporal_extent=["2017-03-01", "2017-04-01"],
                               bands=["VV", "VH"])

mean = datacube.mean_time()

vh = PGNode("array_element",
            arguments={
                "data": {
                    "from_parameter": "data"
                },
                "label": "VH"
            })
vv = PGNode("array_element",
            arguments={
                "data": {
                    "from_parameter": "data"
                },
                "label": "VV"
            })
reducer = PGNode("subtract",
                 arguments={
                     "x": {
                         "from_node": vh
                     },