diff --git a/openet/sims/tests/test_b_model.py b/openet/sims/tests/test_b_model.py index 84e011b..c42c473 100644 --- a/openet/sims/tests/test_b_model.py +++ b/openet/sims/tests/test_b_model.py @@ -144,12 +144,8 @@ def test_Model_crop_type_source_cdl_image(): def test_Model_crop_type_source_cdl_image_exception(): """Requesting a CDL image that doesn't exist should raise an EE exception""" with pytest.raises(Exception): - utils.getinfo(default_model_obj(crop_type_source='USDA/NASS/CDL/2099')) - # CGM - The exception is raised in the _crop_type() method which is - # in the init. If crop_type is a lazy property then it is necessary - # to request the property in order to raise the exception. - # utils.getinfo(default_model_obj( - # crop_type_source='USDA/NASS/CDL/2099').crop_type) + # Intentionally using .getInfo() since utils.getinfo() might catch the exception + default_model_obj(crop_type_source='USDA/NASS/CDL/2099').crop_type.getInfo() @pytest.mark.parametrize( @@ -157,8 +153,8 @@ def test_Model_crop_type_source_cdl_image_exception(): [ 'projects/openet/assets/crop_type/v2023a', 'projects/openet/assets/crop_type/v2021a', - 'projects/openet/crop_type/v2021a', - 'projects/earthengine-legacy/assets/projects/openet/crop_type/v2021a', + # 'projects/openet/crop_type/v2021a', + # 'projects/earthengine-legacy/assets/projects/openet/crop_type/v2021a', ] ) def test_Model_crop_type_source_openet_crop_type(crop_type_source): diff --git a/openet/sims/tests/test_c_image.py b/openet/sims/tests/test_c_image.py index fc916d0..03c64bd 100644 --- a/openet/sims/tests/test_c_image.py +++ b/openet/sims/tests/test_c_image.py @@ -384,9 +384,9 @@ def test_Image_from_landsat_c2_sr_kc(): def test_Image_from_landsat_c2_sr_et(): """Test if ET can be built from a Landsat images""" + image_id = 'LANDSAT/LC08/C02/T1_L2/LC08_044033_20170716' output = utils.getinfo(sims.Image.from_landsat_c2_sr( - 'LANDSAT/LC08/C02/T1_L2/LC08_044033_20170716', - et_reference_source='IDAHO_EPSCOR/GRIDMET', et_reference_band='etr').et) + image_id, et_reference_source='IDAHO_EPSCOR/GRIDMET', et_reference_band='etr').et) assert output['properties']['system:index'] == image_id.split('/')[-1] @@ -410,7 +410,7 @@ def test_Image_from_landsat_c2_sr_scaling(): 'system:index': ee.String(sr_img.get('system:index')), 'system:time_start': ee.Number(sr_img.get('system:time_start'))}) ) - # cloud score masking do not work with a constant image + # cloud score masking and filter_flag option do not work with a constant image # and must be explicitly set to False output = utils.constant_image_value(sims.Image.from_landsat_c2_sr( input_img, cloudmask_args={'cloud_score_flag': False, 'filter_flag': False}).ndvi) diff --git a/openet/sims/tests/test_d_interpolate.py b/openet/sims/tests/test_d_interpolate.py index 66625f9..70828d7 100644 --- a/openet/sims/tests/test_d_interpolate.py +++ b/openet/sims/tests/test_d_interpolate.py @@ -26,8 +26,10 @@ def scene_coll(variables, et_fraction=[0.4, 0.4, 0.4], et=[5, 5, 5], ndvi=[0.6, ee.ImageCollection """ - img = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044033_20170716') \ + img = ( + ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044033_20170716') .select(['B2']).double().multiply(0) + ) mask = img.add(1).updateMask(1).uint8() # The time band needs to be the 0 UTC time (date) @@ -68,7 +70,7 @@ def test_from_scene_et_fraction_daily_values(tol=0.0001): ) TEST_POINT = (-121.5265, 38.7399) - output = utils.point_coll_value(output_coll, TEST_POINT, scale=10) + output = utils.point_coll_value(output_coll, TEST_POINT, scale=30) assert abs(output['ndvi']['2017-07-01'] - 0.2) <= tol assert abs(output['ndvi']['2017-07-08'] - 0.2) <= tol assert abs(output['ndvi']['2017-07-10'] - 0.25) <= tol @@ -99,7 +101,7 @@ def test_from_scene_et_fraction_monthly_values(tol=0.0001): ) TEST_POINT = (-121.5265, 38.7399) - output = utils.point_coll_value(output_coll, TEST_POINT, scale=10) + output = utils.point_coll_value(output_coll, TEST_POINT, scale=30) 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'] - 236.5) <= tol @@ -121,7 +123,7 @@ def test_from_scene_et_fraction_custom_values(tol=0.0001): ) TEST_POINT = (-121.5265, 38.7399) - output = utils.point_coll_value(output_coll, TEST_POINT, scale=10) + output = utils.point_coll_value(output_coll, TEST_POINT, scale=30) 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'] - 236.5) <= tol @@ -143,7 +145,7 @@ def test_from_scene_et_fraction_monthly_et_reference_factor(tol=0.0001): ) TEST_POINT = (-121.5265, 38.7399) - output = utils.point_coll_value(output_coll, TEST_POINT, scale=10) + output = utils.point_coll_value(output_coll, TEST_POINT, scale=30) 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'] - 236.5 * 0.5) <= tol @@ -166,7 +168,7 @@ def test_from_scene_et_fraction_monthly_et_reference_resample(tol=0.0001): ) TEST_POINT = (-121.5265, 38.7399) - output = utils.point_coll_value(output_coll, TEST_POINT, scale=10) + output = utils.point_coll_value(output_coll, TEST_POINT, scale=30) 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'] - 236.5) <= tol diff --git a/openet/sims/utils.py b/openet/sims/utils.py index a9a9819..a4250b4 100644 --- a/openet/sims/utils.py +++ b/openet/sims/utils.py @@ -23,6 +23,9 @@ def getinfo(ee_obj, n=4): # sleep(i ** 2) # else: # raise e + except Exception as e: + logging.info(e) + break if output: break