def main(): title = Colors.BOLD + 'GIPS Data Processing (v%s)' % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser() parser0.add_process_parser() args = parser0.parse_args() try: print title cls = import_data_class(args.command) extents = SpatialExtent.factory(cls, args.site, args.key, args.where, args.tiles, args.pcov, args.ptile) for extent in extents: inv = DataInventory(cls, extent, TemporalExtent(args.dates, args.days), **vars(args)) inv.process(overwrite=args.overwrite) except Exception, e: import traceback VerboseOut(traceback.format_exc(), 4) print 'Data processing error: %s' % e
def main(): title = Colors.BOLD + 'GIPS Data Processing (v%s)' % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser() parser0.add_process_parser() args = parser0.parse_args() try: print title cls = import_data_class(args.command) extents = SpatialExtent.factory( cls, args.site, args.key, args.where, args.tiles, args.pcov, args.ptile ) batchargs = None if args.batchout: tdl = [] batchargs = '--chunksize ' + str(args.chunksize) batchargs += ' --format ' + str(args.format) if args.overwrite: batchargs += ' --overwrite ' if args.products: batchargs += ' -p ' + ' '.join(args.products) for extent in extents: inv = DataInventory( cls, extent, TemporalExtent(args.dates, args.days), **vars(args) ) if args.batchout: tdl = reduce( list.__add__, map( lambda tiles: [ args.command + ' -t ' + str(tile) + ' -d ' + str(tiles.date) + ' ' + batchargs + '\n' for tile in tiles.tiles.keys() ], inv.data.values(), ), tdl ) else: inv.process(overwrite=args.overwrite) if args.batchout: with open(args.batchout, 'w') as ofile: ofile.writelines(tdl) except Exception, e: import traceback VerboseOut(traceback.format_exc(), 4) print 'Data processing error: %s' % e
def main(): title = Colors.BOLD + 'GIPS Data Project (v%s)' % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser(site_required=True) parser0.add_process_parser() parser0.add_project_parser() parser0.add_warp_parser() args = parser0.parse_args() try: print title cls = import_data_class(args.command) extents = SpatialExtent.factory(cls, args.site, args.key, args.where, args.tiles, args.pcov, args.ptile) # create tld: SITENAME--KEY_DATATYPE_SUFFIX if args.notld: tld = args.outdir else: key = '' if args.key == '' else '--' + args.key suffix = '' if args.suffix == '' else '_' + args.suffix res = '' if args.res is None else '_%sx%s' % (args.res[0], args.res[1]) bname = (extents[0].site.LayerName() + key + res + '_' + args.command + suffix) tld = os.path.join(args.outdir, bname) for extent in extents: t_extent = TemporalExtent(args.dates, args.days) inv = DataInventory(cls, extent, t_extent, **vars(args)) datadir = os.path.join(tld, extent.site.Value()) if inv.numfiles > 0: inv.mosaic( datadir=datadir, tree=args.tree, overwrite=args.overwrite, res=args.res, interpolation=args.interpolation, crop=args.crop, alltouch=args.alltouch, ) inv = ProjectInventory(datadir) inv.pprint() else: VerboseOut( 'No data found for {} within temporal extent {}'.format( str(t_extent), str(t_extent)), 2, ) except Exception as e: import traceback VerboseOut(traceback.format_exc(), 4) print 'Data Project error: %s' % e
def main(): title = Colors.BOLD + 'GIPS Tiles (v%s)' % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser() parser0.add_process_parser() parser0.add_project_parser() parser0.add_warp_parser() args = parser0.parse_args() cls = utils.gips_script_setup(args.command, args.stop_on_error) print title with utils.error_handler(): # create output directory if needed # tld is "{}_tiles_{}_{}".format(DATATYPE, RESOLUTION, SUFFIX) if args.notld: tld = args.outdir else: tld = os.path.join(args.outdir, '%s_tiles' % args.command) if args.res is not None: tld = tld + '_%sx%s' % (args.res[0], args.res[1]) if args.suffix != '': tld = tld + '_' + args.suffix mkdir(tld) extents = SpatialExtent.factory(cls, site=args.site, rastermask=args.rastermask, key=args.key, where=args.where, tiles=args.tiles, pcov=args.pcov, ptile=args.ptile) for extent in extents: inv = DataInventory(cls, extent, TemporalExtent(args.dates, args.days), **vars(args)) for date in inv.dates: for tid in inv[date].tiles: # make sure back-end tiles are processed inv[date].tiles[tid].process(args.products, overwrite=False) # warp the tiles & copy into place in the output dir inv[date].tiles[tid].copy(tld, args.products, inv.spatial.site, args.res, args.interpolation, args.crop, args.overwrite, args.tree) utils.gips_exit( ) # produce a summary error report then quit with a proper exit status
def main(): title = Colors.BOLD + "GIPS Data Project (v%s)" % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser(site_required=True) parser0.add_process_parser() parser0.add_project_parser() parser0.add_warp_parser() args = parser0.parse_args() try: print title cls = import_data_class(args.command) extents = SpatialExtent.factory(cls, args.site, args.key, args.where, args.tiles, args.pcov, args.ptile) # create tld: SITENAME--KEY_DATATYPE_SUFFIX if args.notld: tld = args.outdir else: key = "" if args.key == "" else "--" + args.key suffix = "" if args.suffix == "" else "_" + args.suffix res = "" if args.res is None else "_%sx%s" % (args.res[0], args.res[1]) bname = extents[0].site.LayerName() + key + res + "_" + args.command + suffix tld = os.path.join(args.outdir, bname) for extent in extents: t_extent = TemporalExtent(args.dates, args.days) inv = DataInventory(cls, extent, t_extent, **vars(args)) datadir = os.path.join(tld, extent.site.Value()) if inv.numfiles > 0: inv.mosaic( datadir=datadir, tree=args.tree, overwrite=args.overwrite, res=args.res, interpolation=args.interpolation, crop=args.crop, alltouch=args.alltouch, ) inv = ProjectInventory(datadir) inv.pprint() else: VerboseOut("No data found for {} within temporal extent {}".format(str(t_extent), str(t_extent)), 2) except Exception as e: import traceback VerboseOut(traceback.format_exc(), 4) print "Data Project error: %s" % e
def main(): title = Colors.BOLD + 'GIPS Tiles (v%s)' % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser() parser0.add_process_parser() parser0.add_project_parser() parser0.add_warp_parser() args = parser0.parse_args() try: print title cls = import_data_class(args.command) # create tld: DATATYPE_tiles_RESOLUTION_SUFFIX if args.notld: tld = args.outdir else: tld = os.path.join(args.outdir, '%s_tiles' % args.command) if args.res is not None: tld = tld + '_%sx%s' % (args.res[0], args.res[1]) if args.suffix != '': tld = tld + '_' + args.suffix mkdir(tld) extents = SpatialExtent.factory(cls, args.site, args.key, args.where, args.tiles, args.pcov, args.ptile) for extent in extents: inv = DataInventory(cls, extent, TemporalExtent(args.dates, args.days), **vars(args)) for date in inv.dates: for tid in inv[date].tiles: # make sure back-end tiles are processed inv[date].tiles[tid].process(args.products, overwrite=False) # warp the tiles inv[date].tiles[tid].copy(tld, args.products, inv.spatial.site, args.res, args.interpolation, args.crop, args.overwrite, args.tree) except Exception, e: import traceback VerboseOut(traceback.format_exc(), 4) print 'Warp Tiles error: %s' % e
def main(): title = Colors.BOLD + 'GIPS Tiles (v%s)' % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser() parser0.add_process_parser() parser0.add_project_parser() parser0.add_warp_parser() args = parser0.parse_args() try: print title cls = data_class(args.command) # create tld: DATATYPE_tiles_RESOLUTION_SUFFIX if args.notld: tld = args.outdir else: tld = os.path.join(args.outdir, '%s_tiles' % args.command) if args.res is not None: tld = tld + '_%sx%s' % (args.res[0], args.res[1]) if args.suffix != '': tld = tld + '_' + args.suffix mkdir(tld) extents = SpatialExtent.factory(cls, args.site, args.key, args.where, args.tiles, args.pcov, args.ptile) for extent in extents: inv = DataInventory(cls, extent, TemporalExtent(args.dates, args.days), **vars(args)) for date in inv.dates: for tid in inv[date].tiles: # make sure back-end tiles are processed inv[date].tiles[tid].process(args.products, overwrite=False) # warp the tiles inv[date].tiles[tid].copy(tld, args.products, inv.spatial.site, args.res, args.interpolation, args.crop, args.overwrite, args.tree) except Exception, e: import traceback VerboseOut(traceback.format_exc(), 4) print 'Warp Tiles error: %s' % e
def main(): title = Colors.BOLD + 'GIPS Data Project (v%s)' % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser(site_required=True) parser0.add_process_parser() parser0.add_project_parser() parser0.add_warp_parser() args = parser0.parse_args() try: print title cls = import_data_class(args.command) extents = SpatialExtent.factory(cls, args.site, args.key, args.where, args.tiles, args.pcov, args.ptile) # create tld: SITENAME--KEY_DATATYPE_SUFFIX if args.notld: tld = args.outdir else: key = '' if args.key == '' else '--' + args.key suffix = '' if args.suffix == '' else '_' + args.suffix res = '' if args.res is None else '_%sx%s' % (args.res[0], args.res[1]) bname = extents[0].site.LayerName() + key + res + '_' + args.command + suffix tld = os.path.join(args.outdir, bname) for extent in extents: inv = DataInventory(cls, extent, TemporalExtent(args.dates, args.days), **vars(args)) datadir = os.path.join(tld, extent.site.Value()) if inv.numfiles > 0: inv.mosaic(datadir=datadir, tree=args.tree, overwrite=args.overwrite, res=args.res, interpolation=args.interpolation, crop=args.crop) if not args.tree: inv = ProjectInventory(datadir) inv.pprint() except Exception, e: import traceback VerboseOut(traceback.format_exc(), 4) print 'Data Project error: %s' % e
def main(): title = Colors.BOLD + 'GIPS Data Export (v%s)' % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser(site_required=True) parser0.add_process_parser() parser0.add_project_parser() parser0.add_warp_parser() args = parser0.parse_args() cls = utils.gips_script_setup(args.command, args.stop_on_error) print title with utils.error_handler(): extents = SpatialExtent.factory(cls, site=args.site, rastermask=args.rastermask, key=args.key, where=args.where, tiles=args.tiles, pcov=args.pcov, ptile=args.ptile) # create tld: SITENAME--KEY_DATATYPE_SUFFIX if args.notld: tld = args.outdir else: key = '' if args.key == '' else '--' + args.key suffix = '' if args.suffix == '' else '_' + args.suffix res = '' if args.res is None else '_%sx%s' % (args.res[0], args.res[1]) bname = (extents[0].site.LayerName() + key + res + '_' + args.command + suffix) tld = os.path.join(args.outdir, bname) for extent in extents: t_extent = TemporalExtent(args.dates, args.days) inv = DataInventory(cls, extent, t_extent, **vars(args)) datadir = os.path.join(tld, extent.site.Value()) if inv.numfiles > 0: inv.mosaic( datadir=datadir, tree=args.tree, overwrite=args.overwrite, res=args.res, interpolation=args.interpolation, crop=args.crop, alltouch=args.alltouch, process=(not args.dont_process), ) inv = ProjectInventory(datadir) inv.pprint() else: VerboseOut( 'No data found for {} within temporal extent {}'.format( str(t_extent), str(t_extent)), 2, ) utils.gips_exit( ) # produce a summary error report then quit with a proper exit status
def main(): title = Colors.BOLD + 'GIPS Data Processing (v%s)' % __version__ + Colors.OFF # argument parsing parser0 = GIPSParser(description=title) parser0.add_inventory_parser() parser0.add_process_parser() args = parser0.parse_args() cls = utils.gips_script_setup(args.command, args.stop_on_error) print title with utils.error_handler(): extents = SpatialExtent.factory( cls, site=args.site, rastermask=args.rastermask, key=args.key, where=args.where, tiles=args.tiles, pcov=args.pcov, ptile=args.ptile ) batchargs = None if args.batchout: tdl = [] batchargs = '--chunksize ' + str(args.chunksize) batchargs += ' --format ' + str(args.format) batchargs += ' --numprocs ' + str(args.numprocs) batchargs += ' --verbose ' + str(args.verbose) if args.overwrite: batchargs += ' --overwrite ' if args.products: batchargs += ' -p ' + ' '.join(args.products) for extent in extents: inv = DataInventory( cls, extent, TemporalExtent(args.dates, args.days), **vars(args) ) if args.batchout: def get_commands(tiles_obj): commands = [] for tile in tiles_obj.tiles.keys(): needed = any([p not in [k for sen, k in tiles_obj.tiles[tile].filenames.keys()] for p in args.products]) if not needed: continue commands.append(args.command + ' -t ' + str(tile) + ' -d ' + str(tiles_obj.date) + ' ' + batchargs + '\n') return commands tdl = reduce( list.__add__, map( get_commands, inv.data.values() ), tdl ) else: inv.process(overwrite=args.overwrite) if args.batchout: with open(args.batchout, 'w') as ofile: ofile.writelines(tdl) utils.gips_exit() # produce a summary error report then quit with a proper exit status