Beispiel #1
0
def test_map_eq(eodatareaders_file, eodatareaders_params):

    process = [
        {
            "process_id": "eq",
            "arguments": {
                "x": {"from_node": "node_1"},
                "y": 576,
            }
        },
        {
            "process_id": "eq",
            "arguments": {
                "x": {"from_node": "node_1"},
                "y": 577,
                "delta": 1
            }
        }
    ]

    for proc in process:
        eodatareaders_params2 = deepcopy(eodatareaders_params)
        params = map_eq(proc)
        eodatareaders_params2.extend(params)
        eo = EODataProcessor([eodatareaders_file], eodatareaders_params2)
        assert eo.get_data(band='B04')[0,0] == 576 and eo.get_data(band='eq')[0,0] == 1
Beispiel #2
0
def test_map_mask(eodatareaders_file, eodatareaders_params):
    """

    """

    S2_filepath, mask_filepath = create_mask(eodatareaders_file,
                                             eodatareaders_params,
                                             mask_val=1000)

    # Remove filter_bands and crop from params (done when creting mask)
    eodatareaders_params = [eodatareaders_params[0]]

    process = {
        "process_id": "mask",
        "arguments": {
            "data": {
                "from_node": "node_1"
            },
            "mask": {
                "from_node": "node_2"
            },
            "replacement": 0
        }
    }
    process['wrapper_dimension'] = 'band'

    params = map_mask(process)
    eodatareaders_params.extend(params)
    eo = EODataProcessor([S2_filepath, mask_filepath], eodatareaders_params)
    assert eo.get_data(band='mask')[0, 0] == 0
    assert eo.get_data(band='mask')[-1, -1] == 2567
Beispiel #3
0
def test_map_lt(eodatareaders_file, eodatareaders_params):

    process = {
        "process_id": "lt",
        "arguments": {
            "x": {"from_node": "node_1"},
            "y": 567,
        }
    }

    params = map_lt(process)
    eodatareaders_params.extend(params)
    eo = EODataProcessor([eodatareaders_file], eodatareaders_params)
    assert eo.get_data(band='B04')[0,0] == 576 and eo.get_data(band='lt')[0,0] == 0
    assert eo.get_data(band='B04')[-1,-1] == 2567 and eo.get_data(band='lt')[-1,-1] == 0
Beispiel #4
0
def test_map_linear_scale_range(eodatareaders_file, eodatareaders_params):

    process = {
        "process_id": "linear_scale_range",
        "arguments": {
            "x": {
                "from_node": "dc"
            },
            "inputMin": 0,
            "inputMax": 65535
        }
    }

    params = map_linear_scale_range(process)
    eodatareaders_params.extend(params)

    eo = EODataProcessor([eodatareaders_file], eodatareaders_params)
    assert np.min(
        eo.get_data(band='linearscalerange')) == np.float32(0.004303044)
    assert np.max(
        eo.get_data(band='linearscalerange')) == np.float32(0.31313038)
Beispiel #5
0
def test_map_absolute(eodatareaders_file, eodatareaders_params):

    process = {
        "process_id": "absolute",
        "arguments": {
            "x": {
                "from_node": "dc"
            }
        }
    }

    params = map_absolute(process)
    eodatareaders_params.extend(params)

    eo = EODataProcessor([eodatareaders_file], eodatareaders_params)

    assert eo.get_data(band='absolute')[0, 0] == 576
Beispiel #6
0
def test_map_multiply(eodatareaders_file, eodatareaders_params):

    factor = 10
    process = {
        "process_id": "multiply",
        "arguments": {
            "x": {
                "from_node": "dc"
            },
            "y": factor
        }
    }

    params = map_multiply(process)
    eodatareaders_params.extend(params)

    eo = EODataProcessor([eodatareaders_file], eodatareaders_params)
    assert eo.get_data(band='multiply')[0, 0] == 576 * factor
Beispiel #7
0
def test_map_divide(eodatareaders_file, eodatareaders_params):

    factor = 10
    process = {
        "process_id": "divide",
        "arguments": {
            "x": {
                "from_node": "dc"
            },
            "y": factor
        }
    }
    process['wrapper_dimension'] = 'band'

    params = map_divide(process)
    eodatareaders_params.extend(params)

    eo = EODataProcessor([eodatareaders_file], eodatareaders_params)
    assert eo.get_data(band='divideB04')[0, 0] == np.float32(576 / factor)
Beispiel #8
0
def test_map_absolute(eodatareaders_file, eodatareaders_params):

    process = {
        "process_id": "clip",
        "arguments": {
            "x": {
                "from_node": "dc"
            },
            "min": 600,
            "max": 900
        }
    }

    params = map_clip(process)
    eodatareaders_params.extend(params)

    eo = EODataProcessor([eodatareaders_file], eodatareaders_params)
    assert np.min(eo.get_data(band='clip')) == 600
    assert np.max(eo.get_data(band='clip')) == 900