Skip to content

Commit

Permalink
Merge pull request #4 from Open-ET/tcorr-image
Browse files Browse the repository at this point in the history
Tcorr image support
  • Loading branch information
cgmorton authored Dec 18, 2018
2 parents 05a6422 + 07fdd63 commit a7d06ae
Show file tree
Hide file tree
Showing 12 changed files with 3,059 additions and 169 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SSEBop images can also be built manually by instantiating the class with an ee.I
input_img = ee.Image([ee.Image(lst), ee.Image(ndvi)]) \
.rename(['lst', 'ndvi']) \
.setMulti({
.set({
'system:index': 'LC08_044033_20170716',
'system:time_start': ee.Date().millis()})
etf_img = ssebop.Image(input_img).etf
Expand Down
2 changes: 1 addition & 1 deletion openet/ssebop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .model import Image
from .model import collection

__version__ = "0.0.8"
__version__ = "0.0.9"
393 changes: 289 additions & 104 deletions openet/ssebop/model.py

Large diffs are not rendered by default.

299 changes: 236 additions & 63 deletions openet/ssebop/tests/test_model.py

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions tcorr/cancel_tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#--------------------------------
# Name: cancel_tasks.py
# Purpose: Cancel Earth Engine tasks
#--------------------------------

import argparse
import datetime
import logging
import os
import sys

import ee

import utils


def main(key=None, state='READY'):
"""Cancel Earth Engine tasks
Parameters
----------
key : str, optional
File path to an Earth Engine json key file.
state : str, {'ALL', 'READY', 'RUNNING'}
Task state (the default is to only cancel 'READY' tasks).
"""
logging.info('\nCancelling {} tasks'.format(state.lower()))

if state == 'ALL':
states = ['READY', 'RUNNING']
else:
states = [state]

logging.info('\nInitializing Earth Engine')
if key:
logging.info(' Using service account key file: {}'.format(key))
# The "EE_ACCOUNT" parameter is not used if the key file is valid
ee.Initialize(ee.ServiceAccountCredentials('deadbeef', key_file=key))
else:
ee.Initialize()

# Get current task list
tasks = utils.get_ee_tasks(states=states)

logging.info('\nCancelling tasks:')
for k, v in tasks.items():
logging.info(k)
ee.data.cancelTask(v)


def arg_parse():
""""""
parser = argparse.ArgumentParser(
description='Cancel Earth Engine tasks',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'--key', type=utils.arg_valid_file,
help='JSON key file', metavar='FILE')
parser.add_argument(
'--state', default='READY', choices=['ALL', 'READY', 'RUNNING'],
help='Task state')
parser.add_argument(
'-d', '--debug', default=logging.INFO, const=logging.DEBUG,
help='Debug level logging', action='store_const', dest='loglevel')
args = parser.parse_args()

return args


if __name__ == "__main__":
args = arg_parse()

logging.basicConfig(level=args.loglevel, format='%(message)s')
logging.info('\n{0}'.format('#' * 80))
logging.info('{0:<20s} {1}'.format(
'Run Time Stamp:', datetime.datetime.now().isoformat(' ')))
logging.info('{0:<20s} {1}'.format('Current Directory:', os.getcwd()))
logging.info('{0:<20s} {1}'.format(
'Script:', os.path.basename(sys.argv[0])))

main(key=args.key, state=args.state)
61 changes: 61 additions & 0 deletions tcorr/ini/tcorr_topowx_median_v0.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# TopoWX Median Tcorr Export Input File

[INPUTS]
# Date range
start_date = 1984-01-01
end_date = 2018-12-31

# Landsat flags (these don't do anything yet)
# landsat4_flag = True
# landsat5_flag = True
# landsat7_flag = True
# landsat8_flag = True

# Maximum ACCA cloud cosver percentage (0-100)
cloud_cover = 70


[EXPORT]
# Export Destination (only ASSET is currently supported for Tcorr images)
export_dest = ASSET

# Project folder for the Tcorr image collection
# The collection name is computed from the tmax_source
export_path = projects/usgs-ssebop/tcorr_image

# Image name format
export_id_fmt = tcorr_image_{product}_{date}_{export}

# Output raster cellsize (m)
cell_size = 0.033333333333333333333333
# cell_size = 0.016666666666666666666666
# cell_size = 0.008333333333333333333333


[SSEBOP]
# Tmax choices:
# CIMIS, DAYMET, GRIDMET, TOPOWX,
# CIMIS_MEDIAN_V1, DAYMET_MEDIAN_V1, GRIDMET_MEDIAN_V1, TOPOWX_MEDIAN_V0
tmax_source = TOPOWX_MEDIAN_V0

# Mask pixels with Tdiff (Tmax minus LST) greater than threshold (in K)
tdiff_threshold = 15


[TCORR]
# Tcorr specific inputs
min_pixel_count = 1000
min_scene_count = 10

# Years to include in monthly medians
# years = 1984-1990
# years = 1991-1997
# years = 1998-2004
# years = 2005-2011
# years = 2012-2018
# months = 1-12

years = 2018
months = 1-12

tcorr_default = 0.978
Loading

0 comments on commit a7d06ae

Please sign in to comment.