diff --git a/openet/ssebop/collection.py b/openet/ssebop/collection.py index 99cec79..d4c6965 100644 --- a/openet/ssebop/collection.py +++ b/openet/ssebop/collection.py @@ -683,7 +683,7 @@ def aggregate_image(agg_start_date, agg_end_date, date_format): if 'count' in variables: count_img = ( aggregate_coll.filterDate(agg_start_date, agg_end_date) - .select(['mask']).count().rename('count').uint8() + .select(['mask']).reduce(ee.Reducer.count()).rename('count').uint8() ) image_list.append(count_img) diff --git a/openet/ssebop/image.py b/openet/ssebop/image.py index b1878d5..9adef93 100644 --- a/openet/ssebop/image.py +++ b/openet/ssebop/image.py @@ -837,11 +837,11 @@ def tcorr_FANO(self): ee.Image of Tcorr values """ - coarse_transform = [5000, 0, 15, 0, -5000, 15] + coarse_transform = [1000, 0, 15, 0, -1000, 15] coarse_transform100 = [100000, 0, 15, 0, -100000, 15] dt_coeff = 0.125 high_ndvi_threshold = 0.9 - water_pct = 10 + water_pct = 50 # max pixels argument for .reduceResolution() m_pixels = 65535 diff --git a/openet/ssebop/tests/test_c_image.py b/openet/ssebop/tests/test_c_image.py index f2315b8..1a32513 100644 --- a/openet/ssebop/tests/test_c_image.py +++ b/openet/ssebop/tests/test_c_image.py @@ -1,5 +1,5 @@ import datetime -import pprint +# import pprint import ee import pytest @@ -607,18 +607,16 @@ def test_Image_from_landsat_c2_sr_lst_source_values(): assert output_img.get('lst_source_id').getInfo().startswith(lst_source) -# # TODO: Find a new missing LST source image -# def test_Image_from_landsat_c2_sr_lst_source_missing(): -# """Test that the LST is masked if the scene is not present in lst_source""" -# # This image does not currently exist in the source collection, -# # but if this test stops working check to see if this image was added -# image_id = 'LANDSAT/LC08/C02/T1_L2/LC08_031034_20160702' -# xy = (-102.08284, 37.81728) -# lst_source = 'projects/openet/assets/lst/landsat/c02' -# output_img = ssebop.Image.from_landsat_c2_sr(image_id, lst_source=lst_source).lst -# output = utils.point_image_value(output_img, xy) -# assert output['lst'] == None -# assert output_img.get('lst_source_id').getInfo() == 'None' +def test_Image_from_landsat_c2_sr_lst_source_missing(): + """Test that the LST is masked if the scene is not present in lst_source""" + # LST source collection is empty so that join will work but not join to anything + image_id = 'LANDSAT/LC08/C02/T1_L2/LC08_031034_20160702' + xy = (-102.08284, 37.81728) + lst_source = 'projects/openet/assets/lst/landsat/empty' + output_img = ssebop.Image.from_landsat_c2_sr(image_id, lst_source=lst_source).lst + output = utils.point_image_value(output_img, xy) + assert output['lst'] is None + assert output_img.get('lst_source_id').getInfo() == 'None' # # DEADBEEF - Keep for now in case approach changes for handling missing scenes in LST source @@ -746,10 +744,16 @@ def test_Image_tcorr_stats_landsat(image_id, tmax_source, expected, tol=0.000001 'tcorr_src, tmax_src, image_id, xy, expected', [ ['FANO', 'projects/usgs-ssebop/tmax/daymet_v4_mean_1981_2010', - 'LANDSAT/LC08/C02/T1_L2/LC08_042035_20150713', SCENE_POINT, 0.9803095962281566], + 'LANDSAT/LC08/C02/T1_L2/LC08_042035_20150713', SCENE_POINT, 0.9820676302928456], ['FANO', 'projects/earthengine-legacy/assets/projects/usgs-ssebop/tmax/daymet_v4_mean_1981_2010', - 'LANDSAT/LC08/C02/T1_L2/LC08_042035_20150713', SCENE_POINT, 0.9803095962281566], + 'LANDSAT/LC08/C02/T1_L2/LC08_042035_20150713', SCENE_POINT, 0.9820676302928456], + # # Old test values for pre 0.5.0 implementation with 5 Km FANO cells and 10% + # ['FANO', 'projects/usgs-ssebop/tmax/daymet_v4_mean_1981_2010', + # 'LANDSAT/LC08/C02/T1_L2/LC08_042035_20150713', SCENE_POINT, 0.9803095962281566], + # ['FANO', + # 'projects/earthengine-legacy/assets/projects/usgs-ssebop/tmax/daymet_v4_mean_1981_2010', + # 'LANDSAT/LC08/C02/T1_L2/LC08_042035_20150713', SCENE_POINT, 0.9803095962281566], ] ) def test_Image_tcorr_fano_source(tcorr_src, tmax_src, image_id, xy, expected, tol=0.000001): @@ -896,9 +900,9 @@ def test_Image_et_reference_properties(): ['IDAHO_EPSCOR/GRIDMET', 'etr', 0.85, TEST_POINT, 9.5730 * 0.85], ['projects/openet/assets/reference_et/california/cimis/daily/v1', 'etr', 1, TEST_POINT, 10.0760], - ['projects/openet/reference_et/california/cimis/daily/v1', - 'etr', 1, TEST_POINT, 10.0760], - # DEADBEEF + # DEADBEEF - Legacy collections have been removed and/or moved to cloud project + # ['projects/openet/reference_et/california/cimis/daily/v1', + # 'etr', 1, TEST_POINT, 10.0760], # ['projects/earthengine-legacy/assets/projects/climate-engine/cimis/daily', # 'ETr_ASCE', 1, TEST_POINT, 10.0220], # CGM - Why are these not the same? diff --git a/pyproject.toml b/pyproject.toml index 1487df3..90a6357 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openet-ssebop" -version = "0.4.5" +version = "0.5.0" authors = [ { name = "Gabe Parrish", email = "gparrish@contractor.usgs.gov" }, { name = "Mac Friedrichs", email = "mfriedrichs@contractor.usgs.gov" }, diff --git a/test.py b/test.py deleted file mode 100644 index a0cd151..0000000 --- a/test.py +++ /dev/null @@ -1,60 +0,0 @@ -"""This script provides a quick way to test issues that are going wrong in a ipynb in the examples folder -without having to throw 'pip install . --no-deps' every time you want to print something or troubleshoot.""" -import openet.ssebop as model -# Import the Earth Engine package -import ee - - -try: - ee.Initialize() - print('worked') -except ee.EEException: - print('trying a second time') - ee.Authenticate() - ee.Initialize() - -ndvi_palette = ['#EFE7E1', '#003300'] -et_palette = [ - 'DEC29B', 'E6CDA1', 'EDD9A6', 'F5E4A9', 'FFF4AD', 'C3E683', '6BCC5C', - '3BB369', '20998F', '1C8691', '16678A', '114982', '0B2C7A'] -viridis_palette = ['440154', '433982', '30678D', '218F8B', '36B677', '8ED542', 'FDE725'] - -image_size = 768 - -# Salinas -# landsat_img = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_043035_20160722') -# Wilcox -# landsat_img = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_035037_20160714') -# Viginia -# landsat_img = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_016033_20160725') -# x = 'LC08_035037_20160714' -x = 'LC08_043035_20160722' -landsat_img = ee.Image(f'LANDSAT/LC08/C02/T1_L2/{x}') -landsat_crs = landsat_img.select('SR_B3').projection().getInfo()['crs'] -landsat_region = landsat_img.geometry().bounds(1, 'EPSG:4326') -landsat_dt = ee.Date(landsat_img.get('system:time_start')) - -# # Build the SSEBop object from the Landsat image -# model_obj = model.Image.from_landsat_c2_sr( -# landsat_img, -# tcorr_source='SCENE_GRIDDED', -# et_reference_source='IDAHO_EPSCOR/GRIDMET', -# et_reference_band='etr', -# et_reference_factor=0.85, -# et_reference_resample='nearest', -# tmax_source='projects/usgs-ssebop/tmax/daymet_v4_mean_1981_2010_elr' -# ) - -## ============== NON-Lapse Rate Adjusted ================= -# Build the SSEBop object from the Landsat image -model_obj = model.Image.from_landsat_c2_sr( - landsat_img, - tcorr_source='SCENE_GRIDDED', - et_reference_source='IDAHO_EPSCOR/GRIDMET', - et_reference_band='etr', - et_reference_factor=0.85, - et_reference_resample='nearest', - tmax_source='projects/usgs-ssebop/tmax/daymet_v4_mean_1981_2010' -) - -et_property = model_obj.et_fraction \ No newline at end of file