Skip to content

Commit

Permalink
Modified offsets
Browse files Browse the repository at this point in the history
* Satellite data has a lag before it becomes available.
* The script has been modified so that the offset days for downloading and
processing of the data can be controlled from environment variables
(VIIRS_OFFSET and MODIS_OFFSET)
  • Loading branch information
franTarkenton committed May 26, 2021
1 parent 3f00c25 commit 67c5083
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"files.trimTrailingWhitespace": true,
"files.associations": {
"*.jenkins": "Jenkinsfile"
}
},
"python.pythonPath": "/home/kjnether/proj/rfc/envs/snowpack/bin/python"
}
10 changes: 10 additions & 0 deletions admin/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,13 @@
VIIRS_DAILY_20YR = os.path.join(VIIRS_DAILY_NORM, '20yr')

AOI = os.path.join(os.path.dirname(__file__), '..', 'aoi')

# set default values and then override with what is in the
# env vars if populated with a valid value
VIIRS_OFFSET = 1
if ('VIIRS_OFFSET' in os.environ ) and os.environ['VIIRS_OFFSET']:
VIIRS_OFFSET=os.environ['VIIRS_OFFSET']

MODIS_OFFSET = 3
if ('MODIS_OFFSET' in os.environ) and os.environ['MODIS_OFFSET']:
MODIS_OFFSET=os.environ['MODIS_OFFSET']
4 changes: 2 additions & 2 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def daily_pipeline(envpth: str, date: str, clean: str, days: int = 5):
date_l = date.split('.')
target_date = datetime.datetime(int(date_l[0]), int(date_l[1]), int(date_l[2]))
if target_date.date() == datetime.datetime.now(pst).date():
date = datetime.datetime.strftime(target_date - datetime.timedelta(days=4), '%Y.%m.%d')
date = datetime.datetime.strftime(target_date - datetime.timedelta(days=const.MODIS_OFFSET), '%Y.%m.%d')
for sat in ['modis','viirs']:
logger.info(f'Daily Pipeline running {sat} process')
dailypipeline(envpth, date, sat, int(days), db_handler)
Expand All @@ -179,7 +179,7 @@ def daily_pipeline(envpth: str, date: str, clean: str, days: int = 5):
def dailypipeline(envpth: str, date: str, sat: str, days: int, db_handler: DBHandler):
if check_date(date):
if sat == 'viirs':
days = 1
days = const.VIIRS_OFFSET #1
#print(type())
#logger.debug(f'download granules: {download_granules} - {download_granules.download_granules}')
download_granules.download_granules.download_granules(envpth, date, sat, int(days))
Expand Down

0 comments on commit 67c5083

Please sign in to comment.