示例#1
0
def getparser():
    stat_choices = ['first', 'last', 'min', 'max', 'stddev', 'count', 'median']
    parser = argparse.ArgumentParser(
        description='Wrapper for dem_mosaic that will only write valid tiles')
    parser.add_argument('--tr',
                        default='min',
                        help='Output resolution (default: %(default)s)')
    parser.add_argument('--t_projwin',
                        default='union',
                        help='Output extent (default: %(default)s)')
    parser.add_argument('--t_srs',
                        default='first',
                        help='Output projection (default: %(default)s)')
    parser.add_argument('--georef_tile_size',
                        type=float,
                        default=100000.,
                        help='Output tile width (meters)')
    parser.add_argument('--threads',
                        type=int,
                        default=iolib.cpu_count(),
                        help='Number of simultaneous jobs to run')
    parser.add_argument('--stat',
                        type=str,
                        default=None,
                        choices=stat_choices,
                        help='Statistic to use (default: weighted mean)')
    parser.add_argument('-o',
                        type=str,
                        default=None,
                        help='Output mosaic prefix')
    parser.add_argument('src_fn_list',
                        type=str,
                        nargs='+',
                        help='Input filenames (img1.tif img2.tif ...)')
    return parser
示例#2
0
文件: vmap.py 项目: whigg/vmap
def getparser():
    parser = argparse.ArgumentParser(description="Generate velocity map via feature-tracking")
    parser.add_argument('-outdir', default=None, help='Output directory')
    parser.add_argument('-threads', type=int, default=iolib.cpu_count(), help='Number of threads to use(default: %(default)s)')
    parser.add_argument('-tr', default='min', help='Output resolution (default: %(default)s)')
    #Set correlator kernel size
    parser.add_argument('-kernel', type=int, default=35, help='Correlator kernel size. Smaller kernels offer more detail but are prone to more noise. Odd integers required (~9-51 px recommended). (default: %(default)s)')
    align_choices = ['AffineEpipolar', 'Homography', 'Epipolar', 'None']
    parser.add_argument('-align', default='None', choices=align_choices, help='Alignment method to warp second image to match first image, if not already orthorectified. Provides flexibility for L1B inputs')
    #Integer correlator seeding
    #D_sub is low-resolution correlation (default), which works well for most situations
    #sparse_disp will use sparse seeding from full-res chips, useful for ice sheets with limited low-frequency texture
    #existing_velocity will accept existing vx and vy rasters.  Useful for limiting search range and limiting blunders.  Measures products are useful for ice sheets.
    seedmode_choices = ['D_sub', 'sparse_disp', 'existing_velocity']
    parser.add_argument('-seedmode', type=str, choices=seedmode_choices, default='D_sub', help='Seeding option (default: %(default)s)')
    parser.add_argument('-vx_fn', type=str, default=None, help='Seed E-W velocity map filename')
    parser.add_argument('-vy_fn', type=str, default=None, help='Seed N-S velocity map filename')
    
    #Sub-pixel refinement
    #0) None, 1) Parabolic, 2) Bayes, 3) AffineAdaptive
    #See ASP doc or Shean et al, ISPRS, (2016)
    #1 is fast but lower quality
    #2 is slow but highest quality, 
    #3 is a good compromise for speed and quality
    refinement_choices = list(range(12))
    parser.add_argument('-refinement', type=int, default=1, help='Sub-pixel refinement type (see ASP doc): 0) None, 1) Parabolic, 2) Bayes, 3) AffineAdaptive 4) LK, 5) Bayes w/gamma, 6) SGM Linear, 7) SGM Poly4, 8) SGM Cos, 9) SGM Parabola, 10) SGM None, 11) SGM Blend (default: %(default)s)')
    #Numer of gaussian pyramids to use
    #Can look at texture in GDAL overviews to make a decision
    #If you can see plenty of texture at 1/32 resolution, go with 5 
    #For featureless areas, limiting to 2 can help, or even 0
    parser.add_argument('-pyramid-levels', type=int, default=5, help='Number of pyramid levels for correlation (default: %(default)s)')
    #This helps get rid of bogus "islands" in the disparity maps
    parser.add_argument('-erode', type=int, default=1024, help='Erode isolated blobs smaller than this many pixels. Set to 0 to disable (default: %(default)s)')
    parser.add_argument('-filter', action='store_true', help='Filter the output F.tif, smoothing with Gaussian filter')
    #This masks input images to improve performance.  Useful for forested areas.
    parser.add_argument('-mask_input', action='store_true', help='Mask any vegetation/water in input images. Requires demcoreg')
    parser.add_argument('-remove_offsets', action='store_true', help='Remove median horizontal and vertical offsets over stable control surfaces')
    parser.add_argument('-dt', type=str, choices=['yr','day','none'], default='yr', help='Time increment (default: %(default)s)')

    #Inputs can be images, DEMs, shaded relief maps
    #Personal experience suggests multi-directional hillshades with identical illumination work well
    #Only 2 input datsets allowed for this - want to stay modular
    parser.add_argument('fn1', type=str, help='Raster filename 1')
    parser.add_argument('fn2', type=str, help='Raster filename 2')
    return parser
示例#3
0
def getparser():
    stat_choices = [
        'first', 'firstindex', 'last', 'lastindex', 'min', 'max', 'mean',
        'stddev', 'count', 'median', 'medianindex', 'nmad', 'wmean'
    ]
    parser = argparse.ArgumentParser(
        description='Wrapper for dem_mosaic that will only write valid tiles')
    parser.add_argument('--tr',
                        default='min',
                        help='Output resolution (default: %(default)s)')
    parser.add_argument('--t_projwin',
                        default='union',
                        help='Output extent (default: %(default)s)')
    parser.add_argument('--t_srs',
                        default='first',
                        help='Output projection (default: %(default)s)')
    parser.add_argument('--georef_tile_size',
                        type=float,
                        default=100000.,
                        help='Output tile width (meters)')
    parser.add_argument(
        '--threads',
        type=int,
        default=iolib.cpu_count(logical=False),
        help='Number of simultaneous dem_mosaic processes to run')
    parser.add_argument('--stat', type=str, nargs='*', default=None, choices=stat_choices, \
            help='Specify space-delimited list of output statistics to pass to dem_mosaic (e.g., "count stddev", default: wmean)')
    parser.add_argument('-o',
                        type=str,
                        default=None,
                        help='Output mosaic prefix')
    #parser.add_argument('-i', type=str, default=None, help='Input file list (e.g., fn_list.txt)')
    parser.add_argument('src_fn_list',
                        type=str,
                        nargs='+',
                        help='Input filenames (img1.tif img2.tif ...)')
    return parser
示例#4
0
                    mos_fn = os.path.join(
                        stackdir,
                        'stack_seasonal_summer/%s_stack_seasonal_summer' %
                        site_name)
                    cmd = geolib.get_dem_mosaic_cmd(stack_fn_list,
                                                    mos_fn,
                                                    tr=res,
                                                    t_srs=dst_srs,
                                                    t_projwin=site_extent,
                                                    threads=8)
                    dz_cmd_list.append(cmd)

if make_stacks:
    from concurrent.futures import ThreadPoolExecutor
    #threads = 8
    threads = iolib.cpu_count()
    iolib.setstripe(outdir, threads)
    delay = 3.0
    outf = open(os.devnull, 'w')

    if mos_cmd_list:
        with ThreadPoolExecutor(max_workers=threads) as executor:
            for cmd in mos_cmd_list:
                #print(cmd)
                #executor.submit(subprocess.call, cmd, stdout=outf, stderr=subprocess.STDOUT)
                executor.submit(subprocess.call, cmd)
                time.sleep(delay)

    if std_cmd_list:
        with ThreadPoolExecutor(max_workers=threads) as executor:
            for cmd in std_cmd_list:
示例#5
0
#Filter glacier poly - let's stick with big glaciers for now
#min_glac_area = 0.1 #km^2
min_glac_area = 10.  #km^2
#Minimum percentage of glacier poly covered by valid dz
min_valid_area_perc = 0.80
#Write out DEMs and dz map
writeout = True
#Generate figures
mb_plot = True
#Run in parallel, set to False for serial loop
parallel = True
#Verbose for debugging
verbose = False
#Number of parallel processes
nproc = iolib.cpu_count() - 1
#Shortcut to use existing glacfeat_list.p if found
use_existing_glacfeat = True

global z1_date
global z2_date
z1_date = None
z2_date = None
z1_srtm_penetration_corr = False
z2_srtm_penetration_corr = False

if site == 'conus':
    #Glacier shp
    #glac_shp_fn = os.path.join(topdir,'data/rgi60/regions/rgi60_merge.shp')
    #ogr2ogr -t_srs '+proj=aea +lat_1=36 +lat_2=49 +lat_0=43 +lon_0=-115 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ' 24k_selection_aea.shp 24k_selection_32610.shp
    #glac_shp_fn = '/nobackupp8/deshean/conus/shp/24k_selection_aea.shp'