def download(envpth: str, sat: str, date: str, days: int = 5): if check_date(date): print(f'download {sat}') if sat == 'viirs': days = 1 download_granules.download_granules.download_granules(envpth, date, sat, int(days)) else: print('ERROR: Date format YYYY.MM.DD')
def process(date: str, sat: str, days: int): if check_date(date): if sat == 'modis': modis.process_modis(date, int(days)) elif sat == 'viirs': viirs.process_viirs(date) else: # Will never reach here due to click.Choice logger.error(f'ERR SAT {sat} NOT VALID INPUT') else: logger.error('ERROR: Date format YYYY.MM.DD')
def process_sentinel(creds: str, date:str, lat: float, lng: float, rgb: str, max_allowable_cloud: int, force_download: str, day_tolerance: int, clean: str): if check_date(date): db_handler = DBHandler() sentinel2.sentinel_pipeline(creds, date, float(lat), float(lng), rgb.lower(), max_allowable_cloud, force_download, day_tolerance, db_handler) db_handler.db_to_csv() if clean == 'true': teardown.clean_intermediate() else: logger.error('ERROR: Date format YYYY.MM.DD') logger.info("sentinal analysis complete")
def daily_pipeline(envpth: str, date: str, clean: str, days: int = 5): if check_date(date): # MODIS/VIIRS NASA server products are about 2 days behind current date logger.info('Daily Pipeline Started') buildup.buildall() db_handler = DBHandler() pst = pytz.timezone('US/Pacific') 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=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) if clean == 'true': teardown.clean_intermediate() else: logger.error('ERROR: Date format YYYY.MM.DD')
def dailypipeline(envpth: str, date: str, sat: str, days: int, db_handler: DBHandler): if check_date(date): if sat == 'viirs': 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)) if sat == 'modis': modis.process_modis(date, int(days)) elif sat == 'viirs': viirs.process_viirs(date) for typ in ['watersheds', 'basins']: analysis.calculate_stats(typ, sat, date, db_handler) buildkml.daily_kml(date, typ.lower(), sat.lower(), db_handler) db_handler.db_to_csv() plotter.plot_handler(date, sat) buildkml.composite_kml(date, sat.lower()) else: logger.error('ERROR: Date format YYYY.MM.DD')
def plot(date: str, sat: str): if check_date(date): plotter.plot_handler(date, sat) else: logger.error('ERROR: Date format YYYY.MM.DD')
def run_analysis(typ: str, sat: str, date: str): if check_date(date): db_handler = DBHandler() analysis.calculate_stats(typ, sat, date, db_handler) else: logger.error('ERROR: Date format YYYY.MM.DD')
def compose_kmls(date: str, sat: str): if check_date(date): buildkml.composite_kml(date, sat.lower()) else: logger.error('ERROR: Date format YYYY.MM.DD')
def build_kml(date: str, typ: str, sat: str): if check_date(date): db_handler = DBHandler() buildkml.daily_kml(date, typ.lower(), sat.lower(), db_handler) else: logger.error('ERROR: Date format YYYY.MM.DD')