Beispiel #1
0
        coordfile =  OUTPUTDIR + options.coords
    else:
        coordfile = OUTPUTDIR + '/'.join(filepattern.split('/')[:-1]) +\
                    dirstring + fnameroot +\
                    "_goodcoords.npy"
    if not os.path.isfile(coordfile):
        print("need coordinate file ", coordfile)
        sys.exit()
    coords = np.load(coordfile)
    
    # load one image to get size
    if  os.path.isfile(OUTPUTDIR + options.stack):
        img = np.load(OUTPUTDIR + options.stack)
        print("there is a stack", OUTPUTDIR + options.stack)
    else: img = flist[0]
    imsize = findsize(img, filepattern = filepattern)
    img = flist[0]
    img = np.fromfile(img, dtype=np.uint8).reshape(imsize['nrows'],
                                                       imsize['ncols'],
                                                       imsize['nbands']) 
    print("Image size: ", imsize)

    # imshow(np.repeat((windows == l),3).reshape(stack.shape)*stack)

    mask = np.zeros((img.shape[0], img.shape[1]))*False

    # load windows families
    if not os.path.isfile(OUTPUTDIR + options.families):
        print("need coordinate file ", OUTPUTDIR + options.families)
        sys.exit()
Beispiel #2
0
    if len(args) < 1:
        sys.argv.append('--help')
        options, args = parser.parse_args()

        sys.exit(0)

    xmax = 0
    phaseflist = []
    ref = [np.nan, np.nan]
    if options.ref:
        ref = (int(float(options.ref.split(',')[0])),
               int(float(options.ref.split(',')[1])))  #if 2117.12,502.52
        if options.coordfile:
            stack = np.load(options.coordfile.replace("_coords.npy", ".npy"))
            imsize = findsize(stack,
                              filepattern=options.coordfile.replace(
                                  '.npy', '.txt'))
            if PLOTSTACK:
                stackfig = pl.figure()
                axstack2 = stackfig.add_subplot(111)
                axstack2.imshow(stack, interpolation='nearest')
                axstack2.set_xlim(0, axstack2.get_xlim()[1])
                axstack2.set_ylim(axstack2.get_ylim()[0], 0)
                axstack2.axis('off')
                circle1 = pl.Circle(ref, 30, color='r', fill=False, lw=2)
                axstack2.add_artist(circle1)

                stackfig.savefig("reflight_stack.pdf")

            fig = pl.figure(figsize=(20, 10))
            axstack = fig.add_subplot(224)
Beispiel #3
0
    
    options,  args = parser.parse_args()
    if len(args) < 1:
        sys.argv.append('--help')
        options,  args = parser.parse_args()
           
        sys.exit(0)
    
    xmax = 0
    phaseflist = []
    ref = [np.nan,np.nan]
    if options.ref:
        ref = (int(float(options.ref.split(',')[0])), int(float(options.ref.split(',')[1])))   #if 2117.12,502.52
        if options.coordfile:
            stack = np.load(options.coordfile.replace("_coords.npy",".npy"))
            imsize  = findsize(stack,
                           filepattern=options.coordfile.replace('.npy','.txt'))
            if PLOTSTACK:
                stackfig = pl.figure()
                axstack2 = stackfig.add_subplot(111)
                axstack2.imshow(stack,  interpolation='nearest')
                axstack2.set_xlim(0, axstack2.get_xlim()[1])
                axstack2.set_ylim(axstack2.get_ylim()[0], 0)
                axstack2.axis('off')
                circle1 = pl.Circle(ref, 30, color='r', fill=False, lw=2)
                axstack2.add_artist(circle1)
            
                stackfig.savefig("reflight_stack.pdf")

            fig = pl.figure(figsize=(20,10))
            axstack = fig.add_subplot(224)
            axstack.imshow(stack,  interpolation='nearest')
Beispiel #4
0
    flist = glob.glob(impath)
    img = flist[0]

    # extract the filename from the path
    fnameroot = filepattern.split('/')[-1]

    # creates the directory to store the stacks
    os.system('mkdir -p ../outputs/stacks/' + '/'.\
              join(filepattern.split('/')[:-1]))

    # creates the directory to store the other produts
    os.system('mkdir -p ../outputs/'+'/'.join(filepattern.split('/')[:-1]))

    # find image size
    if not options.imsize == '':
        imsize = findsize(img, imsizefile=options.imsize)
    else:
        imsize = findsize(img, filepattern=filepattern)

    rgb = np.zeros((len(flist[:options.nstack]), imsize['nrows'],
                    imsize['ncols'], imsize['nbands']), np.uint8)

    for i, f in enumerate(flist[:options.nstack]):
        try:
            # reads in raw images
            rgb[i] = np.fromfile(f, dtype=np.uint8).clip(0, 255).\
                           reshape(imsize['nrows'],
                                   imsize['ncols'],
                                   imsize['nbands']).astype(float)
        except: pass
Beispiel #5
0
def runit((arg, options)):
    filepattern = arg
    fnameroot = filepattern.split('/')[-1]
    impath = os.getenv("UIdata") + filepattern
    print("\n\nUsing image path: %s\n\n" % impath)
    flist = sorted(glob.glob(impath + "*.raw"))
    ##print (flist)
    if options.stack:
        print("(There is a stack", options.stack, ")")
        stack = np.load(options.stack)
        imsize = findsize(stack,
                          filepattern=options.stack.replace('.npy', '.txt'))
    else:
        print("Please pass a stack with option --stack")

    print("Image size: ", imsize)

    nmax = min(options.nmax, len(flist) - options.skipfiles)
    print("Number of timestamps (files): %d" % (nmax))

    if nmax < 30: return 0
    flist = flist[options.skipfiles:nmax + options.skipfiles]
    imgmask = np.load(options.stack.replace(".npy", "_mask.npy"))
    if not options.lmax:
        lmax = (imgmask.sum(axis=2).sum(axis=1) > 0).sum()
    else:
        lmax = options.lmax
    print(lmax)
    outdir = '/'.join(filepattern.split(
        '/')[:-1]) + '/N%04dW%04dS%04d' % (nmax, lmax, options.skipfiles)

    if not os.path.isdir(outdir):
        subprocess.Popen('mkdir -p %s ' % outdir, shell=True)
        #os.system('mkdir -p %s '%outdir)
    print("Output directory: ", '/'.join(filepattern.split('/')[:-1]), outdir)

    if options.fft:
        #bsoutfile = outdir + "/" + fnameroot + "_bs_fft.npy"
        #coordsoutfile = outdir + "/" + fnameroot + "_coords_fft.npy"
        goodcoordsoutfile = outdir + "/" + fnameroot + "_goodcoords_fft.npy"
        #kmresultfile = outdir + "/" + fnameroot + "_kmresult_fft.pkl"

    else:
        #bsoutfile = outdir + "/" + fnameroot + "_bs.npy"
        #coordsoutfile = outdir + "/" + fnameroot + "_coords.npy"
        goodcoordsoutfile = outdir + "/" + fnameroot + "_goodcoords.npy"
        #kmresultfile = outdir + "/" + fnameroot + "_kmresult.pkl"

    print("")

    print("must read: ", goodcoordsoutfile)

    pl.figure()
    img = np.load(options.stack)
    imgm = imgmask.sum(axis=0)
    pl.imshow(img)
    pl.savefig(filepattern + "_mask.stack.png")
    imgma = np.zeros((img.shape[0], imgm.shape[1], 4))
    imgma[imgm == 1] = [1, 1, 1, 1]
    pl.imshow(imgma)
    pl.savefig(filepattern + "_mask.img.png")

    print("saved figure mask", filepattern + "_mask.img.png")
    gw = np.load(outdir + "/" + filepattern.split('/')[-1] + "_goodcoords.npy")
    imgmagood = np.zeros((img.shape[0], imgm.shape[1], 4))

    for g in gw.T:
        if not np.isnan(g[2]) and not np.isnan(g[3]):
            imgmagood[:, :, 0] = imgmagood[:, :, 0] + (
                imgmask[imgmask[:, int(g[3]), int(g[2])] > 0]).squeeze()
            imgmagood[:, :, 3] = imgmagood[:, :, 3] + (
                imgmask[imgmask[:, int(g[3]), int(g[2])] > 0]).squeeze()
    pl.imshow(img)
    pl.imshow(imgma)
    pl.imshow(imgmagood)
    pl.savefig(filepattern + "_goodmask.img.png")
Beispiel #6
0
def runit((arg, options)):
    filepattern = arg
    fnameroot = filepattern.split('/')[-1]
    impath = os.getenv("UIdata") + filepattern
    print ("\n\nUsing image path: %s\n\n"%impath)    
    flist = sorted(glob.glob(impath+"*.raw"))
    ##print (flist)
    if options.stack:
        print ("(There is a stack", options.stack,")")
        stack = np.load(options.stack)
        imsize  = findsize(stack,
                           filepattern=options.stack.replace('.npy','.txt'))
    else:
        print ("Please pass a stack with option --stack")
    
    print ("Image size: ", imsize)
        
    nmax = min(options.nmax, len(flist)-options.skipfiles)
    print ("Number of timestamps (files): %d"%(nmax))

    if nmax<30: return 0
    flist = flist[options.skipfiles:nmax+options.skipfiles]    
    imgmask = np.load(options.stack.replace(".npy","_mask.npy"))
    if not options.lmax:
        lmax = (imgmask.sum(axis=2).sum(axis=1)>0).sum()
    else: lmax  = options.lmax
    print (lmax)
    outdir = '/'.join(filepattern.split('/')[:-1])+'/N%04dW%04dS%04d'%(nmax,lmax,options.skipfiles)
    
    if not os.path.isdir(outdir):
        subprocess.Popen('mkdir -p %s '%outdir, shell=True)
        #os.system('mkdir -p %s '%outdir)
    print ("Output directory: ",
           '/'.join(filepattern.split('/')[:-1]),  outdir)

    if options.fft:
        #bsoutfile = outdir + "/" + fnameroot + "_bs_fft.npy"
        #coordsoutfile = outdir + "/" + fnameroot + "_coords_fft.npy"
        goodcoordsoutfile = outdir + "/" + fnameroot + "_goodcoords_fft.npy"  
        #kmresultfile = outdir + "/" + fnameroot + "_kmresult_fft.pkl"

        
    else:
        #bsoutfile = outdir + "/" + fnameroot + "_bs.npy"
        #coordsoutfile = outdir + "/" + fnameroot + "_coords.npy"
        goodcoordsoutfile = outdir + "/" + fnameroot + "_goodcoords.npy"
        #kmresultfile = outdir + "/" + fnameroot + "_kmresult.pkl"

    print ("")

    print ("must read: ", goodcoordsoutfile)

    pl.figure()
    img = np.load(options.stack)
    imgm = imgmask.sum(axis=0)
    pl.imshow(img)
    pl.savefig(filepattern+"_mask.stack.png")
    imgma = np.zeros((img.shape[0],imgm.shape[1],4))
    imgma[imgm==1]=[1,1,1,1]
    pl.imshow(imgma)
    pl.savefig(filepattern+"_mask.img.png")
    
    print ("saved figure mask", filepattern+"_mask.img.png")
    gw = np.load(outdir+"/"+filepattern.split('/')[-1]+"_goodcoords.npy")
    imgmagood = np.zeros((img.shape[0],imgm.shape[1],4))

    for g in gw.T:
        if not np.isnan(g[2]) and not np.isnan(g[3]):
            imgmagood[:,:,0] = imgmagood[:,:,0]+(imgmask[imgmask[:,int(g[3]),int(g[2])]>0]).squeeze()
            imgmagood[:,:,3] = imgmagood[:,:,3]+(imgmask[imgmask[:,int(g[3]),int(g[2])]>0]).squeeze()
    pl.imshow(img)
    pl.imshow(imgma)
    pl.imshow(imgmagood)
    pl.savefig(filepattern+"_goodmask.img.png")