Ejemplo n.º 1
0
def mainRoutine():

    cmdargs = getCmdargs() # instantiate the get command line function

    imagepath = cmdargs.imagelist #get the image path from the get cmd

    pattern = "*_%sm?.img" % cmdargs.instage # create a file stage pattern to search for.

    newpattern = imagepath + pattern # add the image path the pattern

    filelist = glob.glob(newpattern)# filter the image directory for the chosen stage
      
    filelist.sort(key=lambda x: x.split("_", 2)[-1]) # sort the filtered list on image date.

    for filename in filelist: # loop through the stack of images

        stdmasked = qvf.changeoptionfield(filename, 'z', 'stdmasks') # changesone of the options in the standard mask call
       
        cmd = "qv_applystdmasks.py --infile %s --outfile %s" % (filename, stdmasked) # call the standard mask
        
        os.system(cmd) #call it
Ejemplo n.º 2
0
def mainRoutine():
    cmdargs = getCmdargs()
    imagepath = cmdargs.imagelist
    pattern = "*_%sm?.img" % cmdargs.instage
    newpattern = imagepath + pattern
    filelist = glob.glob(newpattern)
    
    outputlist = []
    imname = []
    imdate = []
    header = []
    listsize = len(filelist)

    counter = 0
    for filename in filelist:
        counter += 1
        stdmasked = qvf.changeoptionfield(filename, 'z', 'stdmasks')
        cmd = "qv_applystdmasks.py --infile %s --outfile %s" % (filename, stdmasked)
        print cmd
        os.system(cmd)

        
        csvfile = "temp.csv"
        cmd = "qv_rastbypoly.py -r %s -v %s -c %s -o %s --doheadings --stats count,nullcount,min,max,mean,stddev" % (stdmasked, cmdargs.vector, cmdargs.uid, csvfile)
        print cmd
        os.system(cmd)

       
        infile = open(csvfile, "rb") 
        reader = csv.reader(infile) 
        head = []
        
        iteration = 0  
        for row in reader: 
            #row = str(row)
            
            #print row
            iteration += 1
            if iteration == 1:
               head.append(row)
            elif iteration > 2: 
                 #newline = row + "," + filename[-34:] + "," + filename[-18:-10]
                 a = filename[-34:],
                 b = filename[-18:-10]
                 year = b[0:4]
                 month = b[4:6]
                 day = b[6:]
                 date = datetime.datetime(year,month,day)
                 outputlist.append(row)
                 imname.append(a)
                 imdate.append(date)
                 


        infile.close()
        if counter == listsize:
           header.append(head)  
        
    
        #convert datetime objects to matplotlib objects

        mplDates = 


    




























    # otuput to text files
    out = open(cmdargs.out,"w")
    wr = csv.writer(out)
    #outputlist.insert(0,header)
    for item in outputlist:
        #output = str(item) + "\n"
        wr.writerow(item)


    out = open("header.csv","w")
    wr = csv.writer(out)  
    wr.writerow(header)


    out = open("imname.csv","w")
    wr = csv.writer(out)  
    wr.writerow(imname)
    
    out = open("imdate.csv","w")
    wr = csv.writer(out)  
    wr.writerow(imdate)