Example #1
0
def test_from_scene_et_fraction_daily_et_reference_date_type_doy(tol=0.01):
    """Test interpolating a daily collection using a reference ET climatology"""
    output_coll = interpolate.from_scene_et_fraction(
        scene_coll(['et_fraction', 'ndvi', 'time', 'mask']),
        start_date='2017-07-01',
        end_date='2017-08-01',
        variables=['et_reference'],
        interp_args={
            'interp_method': 'linear',
            'interp_days': 32
        },
        model_args={
            'et_reference_source':
            'projects/usgs-ssebop/pet/gridmet_median_v1',
            'et_reference_band': 'etr',
            'et_reference_factor': 1.0,
            'et_reference_resample': 'nearest',
            'et_reference_date_type': 'doy'
        },
        t_interval='daily')

    TEST_POINT = (-121.5265, 38.7399)
    output = utils.point_coll_value(output_coll, TEST_POINT, scale=10)
    # pprint.pprint(output)
    assert abs(output['et_reference']['2017-07-01'] - 8.75) <= tol
Example #2
0
def test_from_scene_et_fraction_monthly_values(tol=0.0001):
    output_coll = interpolate.from_scene_et_fraction(
        scene_coll(['et_fraction', 'ndvi', 'time', 'mask']),
        start_date='2017-07-01',
        end_date='2017-08-01',
        variables=['et', 'et_reference', 'et_fraction', 'ndvi', 'count'],
        interp_args={
            'interp_method': 'linear',
            'interp_days': 32
        },
        model_args={
            'et_reference_source': 'IDAHO_EPSCOR/GRIDMET',
            'et_reference_band': 'etr',
            'et_reference_factor': 1.0,
            'et_reference_resample': 'nearest'
        },
        t_interval='monthly')

    TEST_POINT = (-121.5265, 38.7399)
    output = utils.point_coll_value(output_coll, TEST_POINT, scale=10)
    assert abs(output['ndvi']['2017-07-01'] - 0.6) <= tol
    assert abs(output['et_fraction']['2017-07-01'] - 0.4) <= tol
    assert abs(output['et_reference']['2017-07-01'] - 310.3) <= tol
    assert abs(output['et']['2017-07-01'] - (310.3 * 0.4)) <= tol
    # assert abs(output['et_reference']['2017-07-01'] - 303.622559) <= tol
    # assert abs(output['et']['2017-07-01'] - (303.622559 * 0.4)) <= tol
    assert output['count']['2017-07-01'] == 3
Example #3
0
def test_from_scene_et_fraction_values():
    img = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044033_20170716') \
        .select(['B2']).double().multiply(0)
    mask = img.add(1).updateMask(1).uint8()

    time1 = ee.Number(ee.Date.fromYMD(2017, 7, 8).millis())
    time2 = ee.Number(ee.Date.fromYMD(2017, 7, 16).millis())
    time3 = ee.Number(ee.Date.fromYMD(2017, 7, 24).millis())

    # Mask and time bands currently get added on to the scene collection
    #   and images are unscaled just before interpolating
    scene_coll = ee.ImageCollection([
        ee.Image([img.add(0.4), img.add(0.5), img.add(time1), mask]) \
            .rename(['et_fraction', 'ndvi', 'time', 'mask']) \
            .set({'system:index': 'LE07_044033_20170708',
                  'system:time_start': time1}),
        ee.Image([img.add(0.4), img.add(0.5), img.add(time2), mask]) \
            .rename(['et_fraction', 'ndvi', 'time', 'mask']) \
            .set({'system:index': 'LC08_044033_20170716',
                  'system:time_start': time2}),
        ee.Image([img.add(0.4), img.add(0.5), img.add(time3), mask]) \
            .rename(['et_fraction', 'ndvi', 'time', 'mask']) \
            .set({'system:index': 'LE07_044033_20170724',
                  'system:time_start': time3}),
        ])
    # pprint.pprint(utils.getinfo(scene_coll))

    etf_coll = interpolate.from_scene_et_fraction(
        scene_coll,
        start_date='2017-07-01',
        end_date='2017-07-31',
        variables=['et', 'et_reference', 'et_fraction', 'ndvi', 'count'],
        model_args={
            'et_reference_source': 'IDAHO_EPSCOR/GRIDMET',
            'et_reference_band': 'etr',
            'et_reference_resample': 'nearest'
        },
        t_interval='monthly',
        interp_method='linear',
        interp_days=32)

    TEST_POINT = (-121.5265, 38.7399)
    output = utils.point_coll_value(etf_coll, TEST_POINT, scale=10)
    # pprint.pprint(output)

    tol = 0.0001
    # print(output)
    assert abs(output['ndvi']['2017-07-01'] - 0.5) <= tol
    assert abs(output['et_fraction']['2017-07-01'] - 0.4) <= tol
    assert abs(output['et_reference']['2017-07-01'] - 303.622559) <= tol
    assert abs(output['et']['2017-07-01'] - (303.622559 * 0.4)) <= tol
    assert output['count']['2017-07-01'] == 3
def test_Collection_interpolate_monthly_et_reference_date_type_doy(tol=0.01):
    """Test interpolating a monthly collection using a reference ET climatology"""
    output_coll = default_coll_obj(
        collections=['LANDSAT/LC08/C02/T1_L2'],
        geometry=ee.Geometry.Point(TEST_POINT),
        start_date=START_DATE, end_date=END_DATE,
        variables=['et_reference'],
        et_reference_source='projects/usgs-ssebop/pet/gridmet_median_v1',
        et_reference_band='etr', et_reference_factor=1.0,
        et_reference_resample='nearest', et_reference_date_type='doy',
        ).interpolate(t_interval='monthly')
    output = utils.point_coll_value(output_coll, TEST_POINT, scale=10)
    assert abs(output['et_reference'][START_DATE] - 291.56) <= tol
Example #5
0
def test_point_coll_value(tol=0.001):
    expected = 2364.351
    output = utils.point_coll_value(ee.ImageCollection([ee.Image('USGS/NED')]),
                                    [-106.03249, 37.17777])
    assert abs(output['elevation']['2012-04-04'] - expected) <= tol