Example #1
0
def test_refet_daily_nldas_etr():
    """Generate a fake NLDAS image from the test values

    Convert the test Rs from MJ m-2 d-1 to W m-2, then allocate half to each image

    """
    band_names = [
        'temperature', 'specific_humidity', 'shortwave_radiation', 'wind_u',
        'wind_v'
    ]

    wind_u = d_args['uz'] / (2**0.5)
    nldas_coll = ee.ImageCollection.fromImages([
        ee.Image.constant([d_args['tmin'], d_args['q_asce'],
                           0.0, wind_u, wind_u]) \
            .double().rename(band_names) \
            .set({'system:time_start': ee.Date('2015-07-01T00:00:00', 'UTC').millis()}),
        ee.Image.constant([d_args['tmax'], d_args['q_asce'],
                           d_args['rs'] / 0.0036, wind_u, wind_u]) \
            .double().rename(band_names) \
            .set({'system:time_start': ee.Date('2015-07-01T12:00:00', 'UTC').millis()})
    ])

    refet = Daily.nldas(nldas_coll,
                        elev=ee.Number(s_args['elev']),
                        lat=ee.Number(s_args['lat']),
                        zw=ee.Number(s_args['zw']),
                        method='asce')
    output = refet.etr()\
        .reduceRegion(ee.Reducer.first(), geometry=constant_geom, scale=1)\
        .getInfo()
    assert float(output['etr']) == pytest.approx(d_args['etr_asce'])
Example #2
0
def test_refet_daily_nldas_eto():
    """Compare values to previous calculations"""
    test_point = ee.Geometry.Point(-120.113, 36.336)

    nldas_coll = ee.ImageCollection('NASA/NLDAS/FORA0125_H002')\
        .filterDate('2017-07-01T06:00:00', '2017-07-02T06:00:00')
    output = Daily.nldas(nldas_coll, method='asce').eto() \
        .reduceRegion(ee.Reducer.first(), geometry=test_point, scale=1)\
        .getInfo()['eto']

    expected = ee.Image('projects/eddi-noaa/nldas/daily/20170701')\
        .select(['ETo'])\
        .reduceRegion(ee.Reducer.first(), geometry=test_point, scale=1)\
        .getInfo()['ETo']

    assert output == pytest.approx(expected, rel=0.001)