def test_from_scene_et_actual_daily_et_fraction_max(tol=0.0001): output_coll = interpolate.from_scene_et_actual( scene_coll(['et', 'time', 'mask'], et=100), start_date='2017-07-01', end_date='2017-08-01', variables=['et', 'et_reference', 'et_fraction'], interp_args={ 'interp_method': 'linear', 'interp_days': 32, 'interp_source': 'IDAHO_EPSCOR/GRIDMET', 'interp_band': 'etr', 'interp_resample': 'nearest', 'et_fraction_min': 0.0, 'et_fraction_max': 1.4, }, model_args={ 'et_reference_source': 'IDAHO_EPSCOR/GRIDMET', 'et_reference_band': 'etr', 'et_reference_resample': 'nearest', 'et_reference_factor': 1.0, }, t_interval='daily') TEST_POINT = (-121.5265, 38.7399) output = utils.point_coll_value(output_coll, TEST_POINT, scale=10) assert abs(output['et_fraction']['2017-07-10'] - 1.4) <= tol
def test_from_scene_et_actual_monthly_et_reference_resample(tol=0.0001): output_coll = interpolate.from_scene_et_actual( scene_coll(['et', 'time', 'mask']), start_date='2017-07-01', end_date='2017-08-01', variables=['et', 'et_reference', 'et_fraction', 'count'], interp_args={ 'interp_method': 'linear', 'interp_days': 32, 'interp_source': 'IDAHO_EPSCOR/GRIDMET', 'interp_band': 'etr', 'interp_resample': 'bilinear' }, model_args={ 'et_reference_source': 'IDAHO_EPSCOR/GRIDMET', 'et_reference_band': 'etr', 'et_reference_factor': 0.5, 'et_reference_resample': 'bilinear' }, t_interval='monthly') TEST_POINT = (-121.5265, 38.7399) output = utils.point_coll_value(output_coll, TEST_POINT, scale=10) assert abs(output['et']['2017-07-01'] - 142.895752) <= tol assert abs(output['et_reference']['2017-07-01'] - 303.622559 * 0.5) <= tol assert abs(output['et_fraction']['2017-07-01'] - 0.47063612937927246 / 0.5) <= tol assert output['count']['2017-07-01'] == 3
def test_from_scene_et_fraction_custom_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='custom') 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'] - 303.622559) <= tol assert abs(output['et']['2017-07-01'] - (303.622559 * 0.4)) <= tol assert output['count']['2017-07-01'] == 3
def test_from_scene_et_actual_daily_values(tol=0.0001): output_coll = interpolate.from_scene_et_actual( scene_coll(['et', 'time', 'mask']), start_date='2017-07-01', end_date='2017-08-01', variables=['et', 'et_reference', 'et_fraction'], interp_args={ 'interp_method': 'linear', 'interp_days': 32, 'interp_source': 'IDAHO_EPSCOR/GRIDMET', 'interp_band': 'etr', 'interp_resample': 'nearest' }, model_args={ 'et_reference_source': 'IDAHO_EPSCOR/GRIDMET', 'et_reference_band': 'etr', 'et_reference_factor': 1.0, 'et_reference_resample': 'nearest' }, t_interval='daily') TEST_POINT = (-121.5265, 38.7399) output = utils.point_coll_value(output_coll, TEST_POINT, scale=10) assert abs(output['et_fraction']['2017-07-10'] - 0.4530041813850403) <= tol assert abs(output['et_reference']['2017-07-10'] - 10.50879955291748) <= tol assert abs(output['et']['2017-07-10'] - 4.7605299949646) <= tol assert abs(output['et']['2017-07-01'] - 3.643141031265259) <= tol assert abs(output['et']['2017-07-31'] - 4.9681010246276855) <= tol assert '2017-08-01' not in output['et'].keys()
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