Beispiel #1
0
def selectImgs(AP, GTS):
    '''A list of Images of Opportunity available for a given AP and GTS.'''
    from os import listdir
    from read import makePath
    import re

    #Create a list 'allPics' that stores the names of all the pictures in 'raw'
    #for the given AP and GTS.
    try:
        allPics = [
            picture for picture in listdir(makePath(AP, GTS, pics=True))
            if picture[-4:].upper() == ".JPG"
        ]

    except:  #if you can't find anything
        print "No pictures found for AP{0}-{1}".format(AP, GTS)
        return

    if len(allPics) < 1:  #in case there aren't any pictures
        return

    #for example, 'DSC_' or 'IMG_'--we only want the numbers
    head = allPics[0][:-8]

    #strip away the head and .jpg.
    pics = [pic[-8:-4] for pic in allPics]
    #filter the images that are accounted for by the FDS
    FDSImgs = listImgs(AP, GTS)
    pics = [pic for pic in pics if pic not in FDSImgs]

    #put the header and .jpg back on:
    pics = ['*{0}.JPG'.format(pic) for pic in pics]

    return pics
Beispiel #2
0
def selectImgs(AP, GTS):
    '''A list of Images of Opportunity available for a given AP and GTS.'''
    from os import listdir
    from read import makePath
    import re

    #Create a list 'allPics' that stores the names of all the pictures in 'raw'
        #for the given AP and GTS.
    try:
        allPics = [picture for picture in
                   listdir(makePath(AP, GTS, pics = True))
                   if picture[-4:].upper() == ".JPG"]

    except: #if you can't find anything
        print "No pictures found for AP{0}-{1}".format(AP, GTS)
        return

    if len(allPics) < 1: #in case there aren't any pictures
        return

    #for example, 'DSC_' or 'IMG_'--we only want the numbers
    head = allPics[0][:-8]

    #strip away the head and .jpg.
    pics = [pic[-8:-4] for pic in allPics]
    #filter the images that are accounted for by the FDS
    FDSImgs = listImgs(AP, GTS)
    pics = [pic for pic in pics if pic not in FDSImgs]

    #put the header and .jpg back on:
    pics = ['*{0}.JPG'.format(pic) for pic in pics]

    return pics
Beispiel #3
0
def listSS(AP, G, T):
    '''List the available sample stations for a given AP, FIT and Traverse.'''
    from os import listdir
    from read import makePath
    try:
        dirnames = listdir(makePath(AP, 6, T))
    except:
        return #versatility in case no such AP/G/T exists.
    dirnames.remove('Data')
    ss = [int(station[2:]) for station in dirnames]
    return ss
Beispiel #4
0
def listSS(AP, G, T):
    '''List the available sample stations for a given AP, FIT and Traverse.'''
    from os import listdir
    from read import makePath
    try:
        dirnames = listdir(makePath(AP, 6, T))
    except:
        return #versatility in case no such AP/G/T exists.
    dirnames.remove('Data')
    ss = [int(station[2:]) for station in dirnames]
    ss.sort()
    return ss
Beispiel #5
0
def copyIoOs(AP, GTS):
    '''Copy the IoOs of an AP and GTS into a different folder.'''

    from os import mkdir
    from os.path import isdir
    from shutil import copy2
    from read import makePath
    import glob

    loc = makePath(AP, GTS, pics = True) #current pictures directory

    target = '{0}\\Images of Opportunity\\'.format(loc)


    pics = selectImgs(AP, GTS)
    print pics

    if not pics: #again, in case no images were matched
        return

    #The following line has the ability to write in the folders. Be careful.

    if not isdir(target):
        try:
            mkdir(target)
        except WindowsError:
            print '''The directory cannot be created.'''
            return

    ### TODO: ADD WILDCARD SUPPORT

    wentOn = True
    for pic in pics:
        print pic
        picFile = glob.glob('{0}\\{1}'.format(loc, pic))[0]
        print picFile
        
        try:
            copy2(picFile, target)
        except:
            print "Something happened and I'm not quite sure what, but go on anyways."
            wentOn = False #make False if something goes wrong.

    if not wentOn:
        return
    return pics #to give some info to the caller.
Beispiel #6
0
def copyIoOs(AP, GTS):
    '''Copy the IoOs of an AP and GTS into a different folder.'''

    from os import mkdir
    from os.path import isdir
    from shutil import copy2
    from read import makePath
    import glob

    loc = makePath(AP, GTS, pics=True)  #current pictures directory

    target = '{0}\\Images of Opportunity\\'.format(loc)

    pics = selectImgs(AP, GTS)
    print pics

    if not pics:  #again, in case no images were matched
        return

    #The following line has the ability to write in the folders. Be careful.

    if not isdir(target):
        try:
            mkdir(target)
        except WindowsError:
            print '''The directory cannot be created.'''
            return

    ### TODO: ADD WILDCARD SUPPORT

    wentOn = True
    for pic in pics:
        print pic
        picFile = glob.glob('{0}\\{1}'.format(loc, pic))[0]
        print picFile

        try:
            copy2(picFile, target)
        except:
            print "Something happened and I'm not quite sure what, but go on anyways."
            wentOn = False  #make False if something goes wrong.

    if not wentOn:
        return
    return pics  #to give some info to the caller.